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); }