-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk6-load-test.ts
36 lines (30 loc) · 1.01 KB
/
k6-load-test.ts
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 { sleep } from "k6";
import http from "k6/http";
export const options = {
stages: [
{ duration: "30s", target: 100 }, // simulate ramp-up of traffic from 1 to 100 users over 5 minutes.
{ duration: "5m", target: 100 }, // stay at 100 users for 10 minutes
{ duration: "30s", target: 0 }, // ramp-down to 0 users
],
thresholds: {
http_req_duration: ["p(99)<1500"], // 99% of requests must complete below 1.5s
// "logged in successfully": ["p(99)<1500"], // 99% of requests must complete below 1.5s
},
};
const BASE_URL = "http://localhost:3000";
export default () => {
// const loginRes = http.post(`${BASE_URL}/auth/token/login/`, {
// username: USERNAME,
// password: PASSWORD,
// });
// check(loginRes, {
// "logged in successfully": (resp) => resp.json("access") !== "",
// });
// const authHeaders = {
// headers: {
// Authorization: `Bearer ${loginRes.json("access")}`,
// },
// };
http.get(`${BASE_URL}`);
sleep(1);
};