Conditionally chaining requests

Hello Gatling community,

Is there example or documentation how to performance test with Gatling following request/response flow:

  • send a request, e.g. to /foo endpoint

  • validate response, e.g. that response code is one of acceptable ones

  • if validation fails, consider request/response as failure

  • else if response code was one of the valid ones, then extract from response body content and use it as parameter in a different request to endpoint /bar, chained to previous /foo request

  • else if /foo response code was another of the valid ones, in this case response body is empty content, just count the initial /foo request as successful one, and do not make the request to /bar

Currently we’re (I think ab)using Gatling check API to do the check and extract parameter from /foo request body (put it in a session). Extraction can fail when body is not present, even though request to /foo in that case we would like to be counted as success. So it’s far from ideal.

Kind regards,

Stevo Slavic.


This is indeed a workflow Gatling can handle, I suggest you look at the official documentation and cheat-sheet here: It contains a sample simulation over an application we deployed.

For your last question, there is an element in the check DSL called “optional” that let you capture anything from the request and won’t fail if the engine did not find it. You can then match the content to decide what to do from there, using “doIf” for example.