Generate k6 performance test scripts with scenarios, thresholds, and checks.
HTTP 요청, 시나리오, 임계값, 체크를 설정하여 k6 성능 테스트 스크립트를 생성합니다. 생성된 스크립트를 k6 run script.js로 실행할 수 있습니다.
import http from 'k6/http';
import { check } from 'k6';
export const options = {
scenarios: {
default_1: {
executor: 'ramping-vus',
stages: [
{ duration: '10s', target: 10 },
{ duration: '20s', target: 20 },
{ duration: '10s', target: 0 },
],
},
},
thresholds: {
'http_req_duration': ['p(95)<500'],
'http_req_failed': ['rate<0.01'],
},
};
export default function () {
const res = http.get('https://test.k6.io');
check(res, {
'status is 200': (res) => res.status === 200,
});
}