-
Notifications
You must be signed in to change notification settings - Fork 392
/
Copy pathsingle-request.js
73 lines (33 loc) · 1.16 KB
/
single-request.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
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
import http from 'k6/http';
import { sleep, check } from 'k6';
import { Counter } from 'k6/metrics';
// A simple counter for http requests
export const requests = new Counter('http_reqs');
export function setup() {
// 2. setup code, you can pass data to VU and teardown
sleep(3)
return true
}
// you can specify stages of your test (ramp up/down patterns) through the options object
// target is the number of VUs you are aiming for
export const options = {
stages: [
{ target: 20, duration: '1m' },
{ target: 15, duration: '1m' },
{ target: 0, duration: '1m' },
],
thresholds: {
requests: ['count < 100'],
http_req_failed: ['rate<0.01'], // http errors should be less than 1%
http_req_duration: ['p(95)<200'], // 95% of requests should be below 200ms
},
};
export default function () {
// our HTTP request, note that we are saving the response to res, which can be accessed later
const res = http.get('http://web:8000/status');
//sleep(1);
const checkRes = check(res, {
'status is 200': (r) => r.status === 200,
'response body': (r) => r.body.indexOf('Up and running') !== -1,
});
}