Search code examples
testingconcurrencygatling

Gatling, testing concurrency issues


We have a concurrency issue in our system. This one occurs mainly during burst load through our API from an external system and is not reproducible manually.

So I would like to create a Gatling test to 1) reproduce it whenever I want and 2) check that we have solved the issue.

1) I am done for the first point. I have created two requests checking for the status 201 and I run them with many users.

2) This issue allow the creation of two resources with the same unique value. The expected behaviour is to have one that is created and the others should fail with the status 409. But I have no idea on how we can check that any of the request, but at least once, complete with 201 while all the others are failing with 409.

Can we do a kind of post-check on all requests with Gatling ?

Thanks


Solution

  • I don't think you can achieve what you're after with a check on the call itself as gatling users have no visibility of results returned to other users, so you have no way of knowing whether the successful (201) request has already been made (short of some very messy hacking using a check transformer)

    But you could use simulation level assertions to do this. So you have your request where you assert that you expect a 201 response

    http("my request")
      .get("myUrl")
      .check(status.is(201))
    

    this should result in all but one of these requests failing in a simulation, which you can specify using the assertion...

    setUp(
      myScenario.inject(
        ...
      )
    )
    .assertions(
      details("my request").successfulRequests.count.is(1))