How to Forcefully terminate a Gatling Simulation after certain defined period when there are multiple dependent gatling simulation running

Below is my Gatling Scala code where I am running two simulations: importSimulation and retrieveSimulation.

Currently, importSimulation runs for 3 minutes but continues to execute until all requests are completed, which can take 5 to 6 minutes. As a result, retrieveSimulation gets very little time to run because the total maximum duration for both scenarios is set to 7 minutes.

I want importSimulation to run with 300 concurrent users for exactly 3 minutes and then force stop. After that, the next simulation, retrieveSimulation, should be triggered. How can I achieve this?

setUp(
  importSimulation.inject(constantConcurrentUsers(300).during(3.minutes))
    .andThen(
      retrieveSimulation.inject(constantConcurrentUsers(PerfConfiguration.concurrency).during(4.minutes))
    )
)
  .assertions(
    global.successfulRequests.percent.is(100)
  )
  .protocols(httpProtocol).maxDuration(7.minutes)

Hello Vishesh,

I see that you use a close model, can you explain your use case?

Hi samir

Thanks for replying.

Actually we need to link two scenarios. The first scenario is used for generating test data while the second scenario is the actual test where we need to check the performance against the generated Test Data.

We want to run the second scenario for exactly 5 minutes.

Currently, firstScenario runs for 3 minutes but continues to execute until all requests are completed, which can take 5 to 6 minutes. As a result, second scenariosgets very little time to run because the total maximum duration for both scenarios is set to 8 minutes. Is there any way where I can forceStop 1st scenario after exactly 3 minutes so that second scenario runs for 5 minutes by setting maxDuration to 8 minutes (3 min first scenario + 5 mins second scenario)

Hello,

Thank for you answer, can you try to do this:

  setUp(
    admins.inject(constantConcurrentUsers(300).during(3.minutes)),
    users.inject(
      constantConcurrentUsers(0).during(10.minutes),
      constantConcurrentUsers(500).during(4.minutes)
    )
  ).maxDuration(10.minutes + 5.minutes)

This will give you enough time for scn1 (admins) to naturally stop and a bounded time for scn2 (users)

Thanks Samir, I will surely try it

Thanks samir, It worked. Thanks a lot for the help.

2 Likes

No problem, thank you for using Gatling

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.