-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk6.js
More file actions
60 lines (56 loc) · 1.65 KB
/
k6.js
File metadata and controls
60 lines (56 loc) · 1.65 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
scenarios: {
main_load: {
executor: 'ramping-arrival-rate',
startRate: 5,
timeUnit: '1s',
stages: [
{ duration: '1m', target: 20 },
{ duration: '2m', target: 50 },
{ duration: '3m', target: 100 },
{ duration: '4m', target: 150 },
{ duration: '3m', target: 75 },
{ duration: '2m', target: 25 },
],
preAllocatedVUs: 50,
maxVUs: 200,
},
spike_test: {
executor: 'ramping-arrival-rate',
startTime: '8m',
startRate: 0,
timeUnit: '1s',
stages: [
{ duration: '30s', target: 200 },
{ duration: '1m', target: 200 },
{ duration: '30s', target: 0 },
],
preAllocatedVUs: 30,
maxVUs: 100,
},
background: {
executor: 'constant-arrival-rate',
rate: 5,
timeUnit: '1s',
duration: '15m',
preAllocatedVUs: 10,
maxVUs: 20,
}
}
};
export default function () {
const res = http.get('http://host.docker.internal:3000/summation');
check(res, {
'response has data field with numeric value': (r) => {
try {
const body = JSON.parse(r.body);
return body.hasOwnProperty('data') && typeof body.data === 'number';
} catch (e) {
return false;
}
},
});
sleep(1);
}