-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathk6_http.js
More file actions
53 lines (48 loc) · 1.56 KB
/
k6_http.js
File metadata and controls
53 lines (48 loc) · 1.56 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
import http from 'k6/http';
import { check, sleep } from 'k6';
// Options for the test
export const options = {
scenarios: {
basic: {
executor: 'constant-vus',
vus: 5,
duration: '10s',
},
load: {
/*
Ramping up the number of virtual users (VUs) over time.
- Start with 0 VUs.
- Ramp up to 15 VUs over 1 minute.
- Maintain 15 VUs for another minute.
- Ramp down to 0 VUs over 30 seconds.
- Gracefully ramp down over 5 seconds.
*/
executor: 'ramping-vus',
startVUs: 0,
stages: [
{ duration: '1m', target: 15 },
{ duration: '1m', target: 15 },
{ duration: '30s', target: 0 },
],
// This is the time to wait before starting the ramp down phase.
gracefulRampDown: '5s',
},
},
thresholds: {
'checks': ['rate>0.95'],
'http_req_duration': ['p(95)<600'],
},
};
export default function () {
// Make HTTP GET request to summation endpoint
const response = http.get('http://localhost:8082/api/summation');
// Check if the response status is 200 OK
check(response, {
'is status 200': (r) => r.status === 200,
'response body is valid number': (r) => !isNaN(parseInt(r.body))
});
// Log the summation value
console.log(`Summation value: ${response.body}`);
// Add a small pause between requests
sleep(1);
}