Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup Gatling tests to limit by number of requests

So, I've written a few Gatling tests and know how to write test setup for a max duration.

setUp(testScenario.inject(atOnceUsers(3))).maxDuration(5 minutes)

Now, I want to achieve something along this:

setUp(testScenario.inject(atOnceUsers(3))).maxRequests(1000 requests)

How should I approach that?

Here instead of limiting my time, I'm limiting my test setup by achieving a number of requests.

Any assistance is appreciated. Thanks.

like image 598
Viv Avatar asked Oct 19 '25 05:10

Viv


1 Answers

In general there is no maxRequests() option. You should think of each injected user as of actual user that independently executes some steps and finish his work rather than a thread that executes steps in loop. With that approach it is as simple as setting up certain injection strategy fe.: inject(constantUsersPerSec(10) during(100 seconds)). This way you will simulate actual users behavior (real users are independent and do not relay on other users). Of course there may be some cases where you want simulate users that makes lot of requests but in that case you should write scenario that executes certain number of requests fe.: with repeat loop:

val floodingScenario = scenario("Flood").repeat(250){
  // some execs here
}

setUp(
  floodingScenario.inject(
    atOnceUsers(4) // each user executes steps 250 times = 1000 executes total
  )
)
like image 133
Mateusz Gruszczynski Avatar answered Oct 22 '25 03:10

Mateusz Gruszczynski