Hello community. I have to create following scenario:
Involved services: service 1 → service 2 → service 3 → mock service.
- Sending request ‘A’ to service 1.
- Sending request to mock servise
- Assert outbound requests (from scenario) == inbound requests at mock service, by request A.
- Sending request ‘B’ to service 1.
- Sending request to mock servise
- 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.