-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenario2.js
52 lines (38 loc) · 1.4 KB
/
scenario2.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
import { group } from "k6";
import http from "k6/http";
import { check, sleep } from "k6";
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.1/index.js";
export const options = {
vus: 1000,
iterations: 3500,
thresholds: {
'http_req_duration': ['p(95)<2000'],
},
};
export default function(postResponse, putResponse) {
group('postScenario', function () {
postResponse = http.post('https://reqres.in/api/users/', '{"name":"morpheus","job":"leader"}', {
headers: {
'content-type': 'application/json',
},
});
check(postResponse, { 'status equals 201': postResponse => postResponse.status.toString() === '201' })
});
group('putScenario', function () {
putResponse = http.put('https://reqres.in/api/users/2', '{"name":"morpheus","job":"pedagang"}', {
headers: {
'Content-Type': 'application/json',
},
});
check(putResponse, { 'status equals 200': putResponse => putResponse.status.toString() === '200' });
});
// Automatically added sleep
sleep(2)
};
export function handleSummary(data) {
return {
"scenario2-result.html": htmlReport(data),
stdout: textSummary(data, { indent: " ", enableColors: true }),
};
};