To run http requests sequentially

Hello community. I have to create following scenario:
Involved services: service 1 → service 2 → service 3 → mock service.

  1. Sending request ‘A’ to service 1.
  2. Sending request to mock servise
  3. Assert outbound requests (from scenario) == inbound requests at mock service, by request A.
  4. Sending request ‘B’ to service 1.
  5. Sending request to mock servise
  6. Assert outbound requests (from scenario) == inbound requests at mock service, by request B.

The problem is it is impossible to assert number of calls due to async. calls of Gatling and number of them e.g. i am expecting 1 request to be sent from scenario and within time i see 5 in mock service.

Code: (Java)

ScenarioBuilder sendAndReplyScenario = scenario((String) payloadData.get("sms_template")  + UUID.randomUUID())

                    .exec(
                            http("Send to endpoint A")
                                    .post("localhost/servise1/endpointA")
                                    .header("Content-Type", "application/json")
                                    .body(
                                            StringBody(
                                                    "Payload request A"
                                            ))
                                    .check(status().is(200))
                    ).pause(1)
                    .exec(
                            http("Send to assertion -> mock service")
                                    .get("localhost/mock/getCountEndPointA")
                                    .header("accept", "application/json")
                                    .asJson()
                                    .check(status().is(200),
                                            jsonPath("$.numberOfRequests").is(String.valueOf(expectedNumOfRequestsA)))
                    )
                    .exec( http("Send to endpoint B")
                            .post("localhost/servise1/endpointB")
                            .header("Content-Type", "application/json")
                            .body(StringBody(
                                    "Payload request B"
                            ))
                            .check(status().is(200)))
                    .pause(1)
                    .exec(http("Send to assertion -> mock service")
                            .get("localhost/mock/getCountEndPointB")
                            .header("accept", "application/json")
                            .asJson()
                            .check(status().is(200),
                                    jsonPath("$.numberOfRequests").is(String.valueOf(expectedNumOfRequestsB)))
                    );

Thx guys in advance.

Where did you get this idea from? A given virtual user would execute these requests sequentially.

1 Like

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