Files
crawlapi/load-tests/stress.js
Developer 62994d4f3d
Some checks failed
CI / Test (push) Has been cancelled
Deploy / Deploy to Staging (push) Has been cancelled
CI / Build & Push (push) Has been cancelled
Deploy / Deploy to Production (push) Has been cancelled
Initial commit: Full Crawl API implementation
2026-04-29 07:03:48 +00:00

41 lines
917 B
JavaScript

import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '2m', target: 50 },
{ duration: '5m', target: 50 },
{ duration: '2m', target: 100 },
{ duration: '5m', target: 100 },
{ duration: '2m', target: 200 },
{ duration: '5m', target: 200 },
{ duration: '2m', target: 0 },
],
thresholds: {
http_req_duration: ['p(95)<10000'],
http_req_failed: ['rate<0.2'],
},
};
const API_URL = __ENV.API_URL || 'http://localhost:3000';
const API_KEY = __ENV.API_KEY || 'test-key';
export default function () {
const res = http.post(
`${API_URL}/api/content`,
JSON.stringify({ url: 'https://example.com' }),
{
headers: {
'Content-Type': 'application/json',
'x-api-key': API_KEY,
},
}
);
check(res, {
'status is 200': (r) => r.status === 200,
});
sleep(Math.random() * 2);
}