- Add constant-arrival-rate scenarios to all 4 service scripts (api,
darkwatch, spamshield, voiceprint) to enforce 500 req/s target
- Fix defaultThresholds() to return { thresholds: {...} } so
http_req_duration and errors thresholds are actually applied
- Rewrite run-all.sh: per-service summary files, proper env var
passing (DURATION, API_TOKEN), fixed threshold aggregation
- Update CI workflow threshold check jq to match new threshold-results
structure (.services.<name>.exitCode)
Co-Authored-By: Paperclip <noreply@paperclip.ing>
72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
import http from 'k6/http';
|
|
import { check, group } from 'k6';
|
|
import { Rate, Trend } from 'k6/metrics';
|
|
import { getBaseUrl, getTargetRps, getDuration, defaultThresholds, checkResponse, randomString } from '../lib/common.js';
|
|
|
|
const errorRate = new Rate('errors');
|
|
const enrollmentLatency = new Trend('enrollment_p99');
|
|
const verificationLatency = new Trend('verification_p99');
|
|
const modelLatency = new Trend('model_retrieval_p99');
|
|
|
|
const TARGET_RPS = getTargetRps();
|
|
const DURATION = getDuration();
|
|
|
|
export const options = {
|
|
scenarios: {
|
|
sustained_load: {
|
|
executor: 'constant-arrival-rate',
|
|
duration: DURATION,
|
|
rate: TARGET_RPS,
|
|
preAllocatedVUs: 20,
|
|
maxVUs: 100,
|
|
startTime: '0s',
|
|
exec: 'default',
|
|
tags: { scenario: 'sustained_load' },
|
|
},
|
|
},
|
|
thresholds: {
|
|
...defaultThresholds(250).thresholds,
|
|
enrollment_p99: ['p(99)<500'],
|
|
verification_p99: ['p(99)<250'],
|
|
model_retrieval_p99: ['p(99)<100'],
|
|
},
|
|
};
|
|
|
|
const BASE_URL = getBaseUrl();
|
|
const AUTH_TOKEN = __ENV.API_TOKEN || 'test-token';
|
|
|
|
const headers = {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': `Bearer ${AUTH_TOKEN}`,
|
|
};
|
|
|
|
export default function () {
|
|
group('Voiceprint Enrollment', function () {
|
|
const payload = JSON.stringify({
|
|
userId: `loadtest-${randomString()}`,
|
|
audioSample: 'base64-encoded-audio-data-placeholder',
|
|
sampleRate: 16000,
|
|
});
|
|
const res = http.post(`${BASE_URL}/voiceprint/enroll`, payload, { headers });
|
|
checkResponse(res, 200);
|
|
enrollmentLatency.add(res.timings.duration);
|
|
});
|
|
|
|
group('Voiceprint Verification', function () {
|
|
const payload = JSON.stringify({
|
|
userId: `loadtest-${randomString()}`,
|
|
audioSample: 'base64-encoded-audio-data-placeholder',
|
|
sampleRate: 16000,
|
|
});
|
|
const res = http.post(`${BASE_URL}/voiceprint/verify`, payload, { headers });
|
|
checkResponse(res, 200);
|
|
verificationLatency.add(res.timings.duration);
|
|
});
|
|
|
|
group('Model Retrieval', function () {
|
|
const res = http.get(`${BASE_URL}/voiceprint/model/${randomString()}`, { headers });
|
|
checkResponse(res, 200);
|
|
modelLatency.add(res.timings.duration);
|
|
});
|
|
}
|