Menu
Open source
Response
Caution
Starting on k6
v0.49
, the experimental modulek6/experimental/grpc
has been graduated, and its functionality is now available in thek6/net/grpc
module. Thek6/experimental/grpc
is deprecated and will be removed inv0.51.0
.To migrate your scripts, replace all
k6/experimental/grpc
imports withk6/net/grpc
.
Name | Type | Description |
---|---|---|
Response.status | number | The response gRPC status code. Use the gRPC status constants to check equality. |
Response.message | object | The successful protobuf message, serialized to JSON. Will be null if status !== grpc.StatusOK . |
Response.headers | object | Key-value pairs representing all the metadata headers returned by the gRPC server. |
Response.trailers | object | Key-value pairs representing all the metadata trailers returned by the gRPC server. |
Response.error | object | If status !== grpc.StatusOK then the error protobuf message, serialized to JSON; otherwise null . |
Example
JavaScript
import grpc from 'k6/experimental/grpc';
import { check, sleep } from 'k6';
const client = new grpc.Client();
client.load(['definitions'], 'hello.proto');
export default () => {
client.connect('grpcbin.test.k6.io:9001', {
// plaintext: false
});
const data = { greeting: 'Bert' };
const response = client.invoke('hello.HelloService/SayHello', data);
check(response, {
'status is OK': (r) => r && r.status === grpc.StatusOK,
});
client.close();
sleep(1);
};
Was this page helpful?
Related documentation
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video
Performance testing and observability in Grafana Cloud
In this webinar, learn how Grafana Cloud k6 offers you the best developer experience for performance testing.
User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.