Grpc Server Streaming assertions/checks

Gatling version: 3.11.5
Gatling flavor: java
Gatling build tool: maven

Hello, I am using the gatling grpc dependency with java.
I want to load test a grpc server streaming operation that is exposed by my application.
As I understand I can only apply checks when declaring my

GrpcServerStreamingServiceBuilder<Request, Response> as follows:
GrpcServerStreamingServiceBuilder<Request, Response> stream = GrpcDsl.grpc("Query")
            .serverStream(QueryServiceGrpc.getQueryMethod())
            .check(GrpcDsl.statusCode().is(Status.Code.OK))
            .check(GrpcDsl.statusCode().saveAs("statusCode"))
            .check(response(o -> {
                applyCustomChecks((Response) o );
                return response;
            }))

CoreDsl.scenario("Query")
                .exec(
                        session -> {
                            Request request = getRequest();
                            log.info(id + " Session " + session.userId());
                            log.info(id + " Headers " + scenario.getHeaders());
                            log.info(id + " Request Body " + request);
                            session = session.set("request", request);
                            return session;
                        })
                .exec(
                        stream.send(session -> (QueryRequest) session.get("request")),
                        stream.awaitStreamEnd()
                )
                .exec(session -> {
                       if(responseIterator> getExpectedNumberOfResponses()) {
                        session=session.markAsFailed();
                       }
                    return session;
                });

These checks are applied in each response. However I want to also apply some checks in the overall process. For example, I want to assert that the total number of responses is equal to 5.
How can I apply checks in the end of all the responses? I tried adding an exec block in which i make the session as failed. However the requests and responses keep being displayed as OK instead of KO.

Thank you in advance,
George

Hello,

You are looking for a different feature: assertions. Gatling assertions scripting reference

Hello,
Thank you for the quick reply.
Arent assertions more specific to the metrics and the number of the successful or failed requests?
I want to apply the check of number of responses included in a grcp server streaming operations, in order to mark the scenario execution as failed.
So, i want it to be applied on request/response level.
My use case is this:

When query operation is successfully executed i expect a stream of 5 responses.
I want to verify that when I load test the server using this operation, i receive 5 responses each time that operation is used.
So, i want to mark each call to that operation that does not produce 5 responses as failed.
I dont want to make the assertion on the metrics of my simulation.

I hope it is clearer now :stuck_out_tongue:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.