-
Notifications
You must be signed in to change notification settings - Fork 7
/
test-frontend.js
49 lines (44 loc) · 1.13 KB
/
test-frontend.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
import http from 'k6/http';
import { check } from 'k6';
import { ServiceDisruptor } from 'k6/x/disruptor'
export const options = {
thresholds: {
checks: ['rate>0.99'],
},
scenarios: {
load: {
executor: 'constant-arrival-rate',
rate: 20,
preAllocatedVUs: 5,
maxVUs: 100,
exec: 'requestProduct',
startTime: '0s',
duration: '30s',
},
inject: {
executor: 'shared-iterations',
iterations: 1,
vus: 1,
exec: 'injectFaults',
startTime: '0s',
}
}
}
export function requestProduct() {
const res = http.get(`http://${__ENV.SVC_URL}/product/OLJCESPC7Z`);
check(res, {
'No errors': (res) => res.status === 200,
});
}
export function injectFaults(data) {
if (__ENV.INJECT_FAULTS != "1") {
return
}
const fault = {
port: 3550,
errorRate: 0.1,
statusCode: 10,
};
const svcDisruptor = new ServiceDisruptor('productcatalogservice', 'boutique');
svcDisruptor.injectGrpcFaults(fault, "30s");
}