Initial commit: Full Crawl API implementation
This commit is contained in:
43
load-tests/load.js
Normal file
43
load-tests/load.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import http from 'k6/http';
|
||||
import { check, sleep } from 'k6';
|
||||
|
||||
export const options = {
|
||||
stages: [
|
||||
{ duration: '2m', target: 10 }, // Ramp up
|
||||
{ duration: '5m', target: 10 }, // Steady state
|
||||
{ duration: '2m', target: 20 }, // Ramp up more
|
||||
{ duration: '5m', target: 20 }, // Steady state
|
||||
{ duration: '2m', target: 0 }, // Ramp down
|
||||
],
|
||||
thresholds: {
|
||||
http_req_duration: ['p(95)<5000'], // 95% of requests under 5s
|
||||
http_req_failed: ['rate<0.1'], // Less than 10% errors
|
||||
},
|
||||
};
|
||||
|
||||
const API_URL = __ENV.API_URL || 'http://localhost:3000';
|
||||
const API_KEY = __ENV.API_KEY || 'test-key';
|
||||
|
||||
const endpoints = ['content', 'json', 'links'];
|
||||
|
||||
export default function () {
|
||||
const endpoint = endpoints[Math.floor(Math.random() * endpoints.length)];
|
||||
|
||||
const res = http.post(
|
||||
`${API_URL}/api/${endpoint}`,
|
||||
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,
|
||||
'response has success': (r) => r.json('success') === true,
|
||||
});
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
Reference in New Issue
Block a user