import http from 'k6/http'; import { check, sleep, group } from 'k6'; const BASE = 'http://172.31.12.249'; const API = BASE + ':18080/api/hss'; const WEB = BASE + ':3080'; export const options = { stages: [ { duration: '10s', target: 5 }, // Ramp up to 5 users { duration: '30s', target: 20 }, // Ramp up to 20 users { duration: '30s', target: 20 }, // Stay at 20 users { duration: '10s', target: 0 }, // Ramp down ], thresholds: { http_req_duration: ['p(95)<2000'], // 95% requests < 2s http_req_failed: ['rate<0.05'], // < 5% error rate }, }; const H = { 'Content-Type': 'application/json', 'X-Tenant-Id': '1', 'X-Org-Id': '1', 'X-User-Role': 'ADMIN', }; export default function () { group('Marketing Pages', () => { for (const p of ['/', '/demo', '/solution', '/contact', '/about', '/capabilities', '/service-loop']) { const r = http.get(WEB + p); check(r, { [`${p} is 200`]: (r) => r.status === 200 }); } }); group('Platform Pages', () => { for (const p of ['/platform/login', '/platform']) { const r = http.get(WEB + p); check(r, { [`${p} is 200`]: (r) => r.status === 200 || r.status === 301 || r.status === 302 }); } }); group('API - Dashboard', () => { const r = http.get(API + '/admin/dashboard', { headers: H }); check(r, { 'dashboard 200': (r) => r.status === 200 }); }); group('API - Analytics', () => { for (const ep of ['/analytics/summary', '/analytics/quality', '/capacity/dashboard', '/performance/ranking']) { const r = http.get(API + ep, { headers: H }); check(r, { [`${ep} 200`]: (r) => r.status === 200 }); } }); group('API - Lists', () => { const r = http.get(API + '/applications?page=1&size=10', { headers: H }); check(r, { 'applications 200': (r) => r.status === 200 }); const r2 = http.get(API + '/admin/work-orders?page=1&size=10', { headers: H }); check(r2, { 'work-orders 200': (r) => r.status === 200 }); }); group('API - Master Data', () => { for (const ep of ['/master/service-items', '/master/price-rules', '/master/regions', '/master/staff']) { const r = http.get(API + ep, { headers: H }); check(r, { [`${ep} 200`]: (r) => r.status === 200 }); } }); group('API - POST Leads', () => { const r = http.post(API + '/leads', JSON.stringify({ type: 'demo', name: 'K6 Load', orgName: 'LoadTest', phone: '13800000000', source: 'k6' }), { headers: { ...H, 'Idempotency-Key': 'k6-' + __VU + '-' + __ITER + '-' + Date.now() } }); check(r, { 'leads 200': (r) => r.status === 200 }); }); sleep(1); }