-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadTest.js
36 lines (32 loc) · 915 Bytes
/
loadTest.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
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '30s', target: 20 },
{ duration: '30s', target: 30 },
{ duration: '20s', target: 0 },
],
};
export default function () {
const res = http.get('http://host.docker.internal:8080/event');
check(res, {
'status was 200': (r) => r.status === 200,
'event count was greater than 0': (r) => r.body.length > 0
});
sleep(1);
}
export function setup() {
const url = 'http://host.docker.internal:8080/event';
const payload = JSON.stringify({
date: '2023-01-26',
start: '18:00',
end: '20:00'
});
const params = {
headers: {
'Content-Type': 'application/json',
},
};
const res = http.post(url, payload, params);
check(res, { 'status was 201': (r) => r.status === 201 });
}