This repository was archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
76 lines (70 loc) · 1.8 KB
/
script.js
File metadata and controls
76 lines (70 loc) · 1.8 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import http from 'k6/http';
import { group, check } from 'k6';
// Base config
const host = `${__ENV.HOST}` || 'localhost';
const protocol = 'https://';
const port = `${__ENV.PORT}` || 8080;
export const options = {
discardResponseBodies: true,
scenarios: {
freefly: {
executor: 'ramping-arrival-rate',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 50,
maxVUs: 100,
exec: 'free',
stages: [
{ target: 5, duration: '3s' },
{ target: 5, duration: '10s' },
{ target: 0, duration: '2s' },
],
},
hardfly: {
executor: 'ramping-arrival-rate',
startRate: 50,
timeUnit: '1s',
preAllocatedVUs: 50,
maxVUs: 100,
exec: 'hard',
stages: [
{ target: 5, duration: '3s' },
{ target: 10, duration: '10s' },
{ target: 0, duration: '2s' },
],
},
},
thresholds: {
http_req_failed: ['rate<0.01'],
http_req_duration: ['p(95)<200'],
},
};
// Groups
export function free() {
group('GET_/', () => {
const getRoot = http.get(protocol.concat(host, ':', port));
check(getRoot, {
'status code is 200': (res) => res.status === 200,
});
});
group('GET_/secret', () => {
const getSecret = http.get(protocol.concat(host, ':', port, '/secret'));
check(getSecret, {
'status code is 200': (res) => res.status === 200,
});
});
group('POST_/', () => {
const postRoot = http.post(protocol.concat(host, ':', port));
check(postRoot, {
'status code is 200': (res) => res.status === 200,
});
});
}
export function hard() {
group('GET_/random', () => {
const getRandom = http.get(protocol.concat(host, ':', port, '/random-number'));
check(getRandom, {
'status code is 200': (res) => res.status === 200,
});
});
}