import grpc from 'k6/net/grpc';
import { check } from 'k6';
import { SharedArray } from 'k6/data';
import exec from 'k6/execution';
// note: the services in this example don't exist. If you would like
// to run this example, make sure to replace the URLs, and
// the cacerts, cert, key, and password variables.
const grpcArgs = new SharedArray('grpc', () => {
// Using SharedArray here so that not every VU gets a copy of every certificate a key
return [
{
host: 'foo1.grpc-quickpizza.grafana.com:443',
plaintext: false,
params: {
tls: {
cacerts: [open('cacerts0.pem')],
cert: open('cert0.pem'),
key: open('key0.pem'),
},
},
},
{
host: 'foo2.grpc-quickpizza.grafana.com:443',
params: {
plaintext: false,
tls: {
cacerts: open('cacerts1.pem'),
cert: open('cert1.pem'),
key: open('key1.pem'),
password: 'cert1-passphrase',
},
},
},
];
});
const client = new grpc.Client(null, 'quickpizza.proto');
export default () => {
if (__ITER === 0) {
// Take one config and use it for this one VU
const grpcArg = grpcArgs[exec.vu.idInTest % grpcArgs.length];
client.connect(grpcArg.host, grpcArg.params);
}
const response = client.invoke('quickpizza.GRPC/Status');
check(response, {
'status is OK': (r) => r && r.status === grpc.StatusOK,
});
console.log(JSON.stringify(response.message));
};
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4