import http from 'k6/http'; import { check, sleep } from 'k6'; export const options = { stages: [ { duration: '30s', target: 20 }, { duration: '1m', target: 50 }, { duration: '30s', target: 0 }, ], thresholds: { http_req_duration: ['p(95)<500'], http_req_failed: ['rate<0.01'], }, }; export default function () { const BASE_URL = __ENV.ORCH_URL || 'http://localhost:8080'; // Test plan creation const planPayload = JSON.stringify({ creator: 'test-user', steps: [ { type: 'borrow', asset: 'CBDC_USD', amount: 100000 }, ], }); const createRes = http.post(`${BASE_URL}/api/plans`, planPayload, { headers: { 'Content-Type': 'application/json' }, }); check(createRes, { 'plan created': (r) => r.status === 201, 'response time < 500ms': (r) => r.timings.duration < 500, }); if (createRes.status === 201) { const planId = JSON.parse(createRes.body).plan_id; // Test getting plan const getRes = http.get(`${BASE_URL}/api/plans/${planId}`); check(getRes, { 'plan retrieved': (r) => r.status === 200, }); } sleep(1); }