- Add load-test job to ci.yml that runs after docker-build on push to main - Create combined load test runner (scripts/load-test/run-all.sh) for all services - Create k6 load test scripts for api, darkwatch, spamshield, and voiceprint - Add shared k6 utilities (lib/common.js) - Update load-test.yml to support all services and report artifacts - Configure k6 cloud output and P99 threshold validation - Generate load test report as CI artifact Co-Authored-By: Paperclip <noreply@paperclip.ing>
57 lines
1.8 KiB
JavaScript
57 lines
1.8 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');
|
|
|
|
export const options = {
|
|
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);
|
|
});
|
|
}
|