-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathscript.js
More file actions
57 lines (47 loc) · 1.08 KB
/
Copy pathscript.js
File metadata and controls
57 lines (47 loc) · 1.08 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
54
55
56
57
import http from "k6/http";
import { check, group } from "k6";
const baseURL = "http://127.0.0.1:1378";
export let options = {
stages: [
{
target: 35,
duration: "2m",
},
],
thresholds: {
http_req_duration: ["avg<10000", "p(100)<30000"],
http_req_failed: ["rate<0.01"],
},
};
export default function () {
group("healthz", () => {
let res = http.get(`${baseURL}/healthz`);
check(res, {
success: (res) => res.status === 204,
});
});
group("short", () => {
let name = "";
group("create", () => {
let payload = JSON.stringify({
url: "https://elahe-dastan.github.io",
});
let res = http.post(`${baseURL}/api/urls`, payload, {
headers: {
"Content-Type": "application/json",
},
});
check(res, {
success: (res) => res.status == 200,
});
name = res.json();
});
console.log(name);
group("fetch", () => {
let res = http.get(`${baseURL}/api/${name}`);
check(res, {
success: (res) => res.status == 200,
});
});
});
}