-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
47 lines (39 loc) · 1.06 KB
/
script.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
import http from "k6/http";
import { Httpx } from "https://jslib.k6.io/httpx/0.1.0/index.js";
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
import { sleep } from "k6";
export const options = {
vus: 5,
duration: "30s",
summaryTrendStats: ["med", "p(99)", "p(99.9)", "p(99.99)"],
};
const session = new Httpx();
session.setBaseUrl("http://192.168.50.241:8080");
function generateRandomString(length) {
let result = [];
const alphabet = "abcdefghijklmnopqrstuvwxyz".split("");
for (let i = 0; i <= length; i++) {
result.push(alphabet[Math.floor(Math.random() * alphabet.length)]);
}
return result;
}
export default function () {
session.get("/randStr");
session.get("/slow");
const params = {
headers: {
"Content-Type": "application/json",
},
};
session.post(
"/postData",
{ field1: generateRandomString(15), field2: generateRandomString(15) },
params
);
sleep(1);
}
export function handleSummary(data) {
return {
"summary.html": htmlReport(data),
};
}