-
Notifications
You must be signed in to change notification settings - Fork 0
/
stress_test.js
38 lines (34 loc) · 1.25 KB
/
stress_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import http from 'k6/http';
import { check, group, sleep } from 'k6';
export const options = {
stages: [
{ duration: '10s', target: 200 }, // simulate ramp-up of traffic from 1 to 200 users over 10s.
{ duration: '10s', target: 200 }, // stay at 200 users for 10 seconds
{ duration: '10s', target: 300 }, // rumpup to 300 users over 10 seconds
{ duration: '10s', target: 400 }, // rumpup to 400 users over 10 seconds
{ duration: '30s', target: 400 }, // stay at 400 users for 30 seconds
{ duration: '10s', target: 0 }, // ramp-down to 0 users
],
thresholds: {
'http_req_duration': ['p(99)<1500'], // 99% of requests must complete below 1.5s
'checks{myTag:status200less1500}': ['rate>0.99'],
},
};
const BASE_URL = 'http://localhost:5000';
export default () => {
let urls = [
['GET', `${BASE_URL}/health_check`, null],
//['GET', `${BASE_URL}/long_duration`, null],
['GET', `${BASE_URL}/short_duration`, null],
]
const responses = http.batch(urls);
for (let i = 0; i < responses.length; i++) {
check(
responses[i], {
'status was 200': (res) => res.status === 200,
},
{ myTag: 'status200less1500' }
);
}
sleep(1);
};