43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
|
|
/**
|
||
|
|
* Smoke test rapide pour validation (< 1 min)
|
||
|
|
* Usage: k6 run loadtests/smoke.js
|
||
|
|
*/
|
||
|
|
import http from 'k6/http';
|
||
|
|
import { check, sleep } from 'k6';
|
||
|
|
|
||
|
|
const BASE_URL = __ENV.BASE_URL || __ENV.API_ORIGIN || 'http://localhost:8080';
|
||
|
|
|
||
|
|
export const options = {
|
||
|
|
vus: 2,
|
||
|
|
duration: '30s',
|
||
|
|
thresholds: {
|
||
|
|
http_req_failed: ['rate<0.2'],
|
||
|
|
http_req_duration: ['p(95)<2000'],
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
export default function () {
|
||
|
|
// 1. Health check
|
||
|
|
const healthRes = http.get(`${BASE_URL}/health`);
|
||
|
|
check(healthRes, { 'health status 200': (r) => r.status === 200 });
|
||
|
|
sleep(0.5);
|
||
|
|
|
||
|
|
// 2. Readiness check
|
||
|
|
const readyzRes = http.get(`${BASE_URL}/readyz`);
|
||
|
|
check(readyzRes, { 'readyz status 200': (r) => r.status === 200 });
|
||
|
|
sleep(0.5);
|
||
|
|
|
||
|
|
// 3. Auth login (invalid credentials -> 401 attendu)
|
||
|
|
const loginPayload = JSON.stringify({
|
||
|
|
email: 'test@example.com',
|
||
|
|
password: 'invalid_password',
|
||
|
|
});
|
||
|
|
const loginRes = http.post(`${BASE_URL}/api/v1/auth/login`, loginPayload, {
|
||
|
|
headers: { 'Content-Type': 'application/json' },
|
||
|
|
});
|
||
|
|
check(loginRes, {
|
||
|
|
'login returns 401 or 400': (r) => r.status === 401 || r.status === 400,
|
||
|
|
});
|
||
|
|
sleep(1);
|
||
|
|
}
|