- loadtests: centraliser scripts (backend, stream, chat) - backend: health, auth, tracks, uploads, playlists, marketplace - stream: http health, healthz, readyz - chat: WebSocket load (register -> login -> chat token -> WS) - ci: workflow nightly load-test-nightly.yml - docs: README loadtests - make: load-test-smoke, load-test-backend, load-test-all - fix: veza-backend-api Makefile load-test (scripts/load_test_uploads.js -> loadtests)
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
/**
|
|
* Load test: Stream server health, healthz, readyz
|
|
* Usage: k6 run loadtests/stream/http.js
|
|
* Requires: Stream server running (default localhost:8082)
|
|
*/
|
|
import http from 'k6/http';
|
|
import { check, sleep } from 'k6';
|
|
import { Rate, Trend } from 'k6/metrics';
|
|
|
|
const errorRate = new Rate('stream_errors');
|
|
const healthDuration = new Trend('stream_health_duration');
|
|
|
|
const STREAM_ORIGIN = __ENV.STREAM_ORIGIN || 'http://localhost:8082';
|
|
|
|
export const options = {
|
|
scenarios: {
|
|
stream_health: {
|
|
executor: 'constant-arrival-rate',
|
|
rate: 10,
|
|
timeUnit: '1s',
|
|
duration: '2m',
|
|
preAllocatedVUs: 20,
|
|
maxVUs: 50,
|
|
},
|
|
},
|
|
thresholds: {
|
|
http_req_duration: ['p(95)<500', 'p(99)<1000'],
|
|
stream_errors: ['rate<0.05'],
|
|
stream_health_duration: ['p(95)<200', 'p(99)<500'],
|
|
},
|
|
};
|
|
|
|
export default function () {
|
|
const start = Date.now();
|
|
const healthRes = http.get(`${STREAM_ORIGIN}/health`);
|
|
healthDuration.add(Date.now() - start);
|
|
|
|
const ok = check(healthRes, {
|
|
'stream health returns 200': (r) => r.status === 200,
|
|
});
|
|
errorRate.add(!ok);
|
|
sleep(0.5);
|
|
|
|
const healthzRes = http.get(`${STREAM_ORIGIN}/healthz`);
|
|
check(healthzRes, { 'stream healthz returns 200': (r) => r.status === 200 });
|
|
errorRate.add(healthzRes.status !== 200);
|
|
sleep(0.5);
|
|
|
|
const readyzRes = http.get(`${STREAM_ORIGIN}/readyz`);
|
|
check(readyzRes, { 'stream readyz returns 200': (r) => r.status === 200 });
|
|
sleep(1);
|
|
}
|