-
Notifications
You must be signed in to change notification settings - Fork 15
/
03.with-browser.js
53 lines (45 loc) · 1.02 KB
/
03.with-browser.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
48
49
50
51
52
53
import { LoadAndCheck } from "../foundations/lib/frontend/basic.js";
import { ServiceDisruptor } from "k6/x/disruptor";
const BASE_URL = __ENV.BASE_URL || "http://localhost:3333";
const scenarios = {
disrupt: {
executor: "shared-iterations",
iterations: 1,
vus: 1,
exec: "disrupt",
},
browser: {
executor: "constant-vus",
vus: 1,
duration: "10s",
startTime: "10s",
exec: "browser",
options: {
browser: {
type: "chromium",
},
},
},
};
if (__ENV.DISABLE_DISRUPT) {
delete scenarios["disrupt"];
}
export const options = {
scenarios,
};
const fault = {
averageDelay: "1000ms",
errorRate: 0.1,
errorCode: 500,
}
export function disrupt() {
const disruptor = new ServiceDisruptor("pizza-info", "pizza-ns");
const targets = disruptor.targets();
if (targets.length == 0) {
throw new Error("expected list to have one target");
}
disruptor.injectHTTPFaults(fault, "20s");
}
export async function browser() {
await LoadAndCheck(BASE_URL, false);
}