-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk6.js
More file actions
32 lines (29 loc) · 991 Bytes
/
k6.js
File metadata and controls
32 lines (29 loc) · 991 Bytes
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
import http from "k6/http";
import { check } from "k6";
export const options = {
thresholds: {
http_req_failed: [{ threshold: "rate<0.01", abortOnFail: true }], // availability threshold for error rate
http_req_duration: ["p(99)<1000"], // Latency threshold for percentile
},
scenarios: {
constant_request_rate: {
executor: "constant-arrival-rate",
rate: 30000,
timeUnit: "1s", // 1000 iterations per second, i.e. 1000 RPS
duration: "10s",
preAllocatedVUs: 100, // how large the initial pool of VUs would be
maxVUs: 20000, // if the preAllocatedVUs are not enough, we can initialize more
},
},
};
function rand(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
export default function () {
const res = http.post(`http://localhost:3490/test2/${rand(0,999)}/foo/123`);
check(res, {
"response code was 200": (res) => res.status == 200,
});
}