-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.js
More file actions
58 lines (47 loc) · 1.56 KB
/
Copy pathexample.js
File metadata and controls
58 lines (47 loc) · 1.56 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
58
import grpc from 'k6/net/grpc';
import { check, group, sleep } from 'k6';
export let options = {
summaryTrendStats: ["min", "max", "avg", "p(90)", "p(95)", "p(99)"],
stages: [
{ duration: '1s', target: 1 },
{ duration: '120s', target: 50 },
{ duration: '10s', target: 0 },
]
};
const client = new grpc.Client();
client.load(['.'], 'helloworld.proto');
const client2 = new grpc.Client();
client2.load(['.'], 'helloworld.proto');
export default () => {
// Connect the gRPC client/s on first iteration
if (__ITER == 0) {
client.connect(`k8s:///${__ENV.GRPC_SERVER}:50051`, {
plaintext: true
});
if (__ENV.GRPC_SERVER_2) {
client2.connect(`k8s:///${__ENV.GRPC_SERVER_2}:50051`, {
plaintext: true
});
}
}
group('demoGrpcGroup', function () {
const data = { name: `ICaRUS client=1 VU=${__VU} Iter=${__ITER}` };
const response = client.invoke('helloworld.Greeter/SayHello', data);
check(response, {
'status is OK': (r) => r && r.status === grpc.StatusOK,
});
});
if (__ENV.GRPC_SERVER_2) {
group('demoGrpcGroup2', function () {
const data = { name: `ICaRUS client=2 VU=${__VU} Iter=${__ITER}` };
const response = client2.invoke('helloworld.Greeter/SayHello', data);
check(response, {
'status2 is OK': (r) => r && r.status === grpc.StatusOK,
});
});
}
sleep(0.3);
};
export function teardown(data) {
client.close();
}