3

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.

Viv
  • 1,706
  • 1
  • 18
  • 27

1 Answers1

2

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
  )
)
Mateusz Gruszczynski
  • 1,421
  • 10
  • 18