Files
ai-ops/test/perf/drilldown_k6.js
2026-05-12 17:48:22 +08:00

33 lines
876 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import http from 'k6/http';
import { check, sleep } from 'k6';
// AI-Ops 下钻性能压测脚本
// 目标:验证下钻加载 < 3s并发 20 用户
export const options = {
stages: [
{ duration: '30s', target: 20 },
{ duration: '2m', target: 20 },
{ duration: '30s', target: 0 },
],
thresholds: {
http_req_duration: ['p(95)<3000'], // P95 < 3s
http_req_failed: ['rate<0.01'], // 失败率 < 1%
},
};
export default function () {
const service = `service_${Math.floor(Math.random() * 10)}`;
const url = `http://localhost:8080/api/v1/ai-ops/metrics/drilldown?service=${service}&window=5m`;
const res = http.get(url, {
headers: { 'Authorization': 'Bearer ${__ENV.AI_OPS_TOKEN}' },
});
check(res, {
'status is 200': (r) => r.status === 200,
'response time < 3s': (r) => r.timings.duration < 3000,
});
sleep(2);
}