How to run gatling simulation sequentially?

How to run gatling simulation sequentially ?

I have two simulation files, and I would like to run the files sequentially, I would like to run SimulationFile_2 to run after SimulationFile_1 .

Hi @Banu,

The gatling Simulation describe a full test. They are not meant to be run sequentially.
Obviously, you can run one, then another from the commandline.

What I understand is that your first SimulationFile_1 contains a scenario and your SimulationFile_2 contains a second scenario.

You can create SimulationFile_3 that reference SimulationFile_1.scenario and SimulationFile_2.scenario, creating a whole new full test.

But I really suggest that you extract your scenarios in their own files and import them in the wanted Simulation(s).

(in that case, andThen will be useful)

Cheers!

Hi @sbrevet ,
would like to clarify a few questions, In my case, Simulation 2 needs test data , from simulation 1 file at the end of execution. hence simulation 2 has to wait until simulation 1 is done execution and import the test data to the file in the csv format. and i then feed the csv -test data to simulation 2 and execute, below is the command i use now to execute both the simulations.

./gradlew clean gatlingRun-BiddingSimulation_Round1 && ./gradlew clean gatlingRun-BiddingSimulation_Round2

when you say to create a new full test, do you mean to create the new simulation 3 file and add the setup block only in simulation file 3? when you say reference ,do i have to extend simulation 1 and 2 file to Simulation 3 file and add the setup block only in simulation 3 file and use andThen to first execute simulation 1then 2?
Should simulation 1 and 2 file not have setup block ?

Our scenario - usually simulation 1 and 2- order submission round 1 and round 2 submission in real time gets executed sequentially , but round 2 occurs 4 or 5 months after round 1 submission, which is the reason we do not want to keep both simulation 1 and 2 in the same simulation file to mimic real time order submission. hence we want to keep them separated to mimic production behaviour. Can you please recommend if we should still have simulation1 and 2 execute right after the other in the same simulation 3 file?

This is the setup block in simulation 1:

  setUp(
    AuctionOrder_round1.inject(
      nothingFor(1),
      atOnceUsers(1),
    ).andThen(openOrders_round1.inject(nothingFor(1),
      atOnceUsers(1)).
      andThen(submitOrders_round1.inject(nothingFor(1),
        atOnceUsers(1),
        rampUsers(5).during(50))).
      andThen(closeOrders_round1.inject(nothingFor(1),
        atOnceUsers(1)))))

Simulation 2 setup block:

  setUp(
    openOrders_Round2.inject(
      nothingFor(1),
      atOnceUsers(1),
    ).andThen(submitOrders_round2.inject(nothingFor(1),
      atOnceUsers(1),
      rampUsers(5).during(50)).
      andThen(closeOrders_Round2.inject(nothingFor(1),
        atOnceUsers(1)))))

can you please clarify if you meant to keep scenarios in the simulation 1 and 2, (without setup block) and import those scenarios in the simulation 3 and run simulation 1 andThen simulation 2?

Hi @Banu,

As you already use andThen I don’t where is your issue.

In your Simulation3, you can put:

  setUp(
     /* copy paste from Simulation1 setUp */.andThen(/* copy paste from Simulation2 setUp*/)
  )

Hi @sbrevet ,
would like to clarify, if i leave setup block in simulation file 1 and 2, then copy and paste to simulation 3, will it not cause to run simulation 1 and 2 files also to execute separately in addition to simulation 3?

or if i execute only simulation 3 using the below command , will it execute only simulation3?
or ./gradlew clean gatlingRun-Simulation3

(or)

do i have to remove setup block from simulation1 and 2 file? i want only simulation 3 setup to execute. -simulation 1 then 2. what should i have inside setup block in simulation file 1 and 2? can you please advise?

i use andThen already within the simulation 1 and 2 file, as the scenarios within simulation 1 and 2 file also have to be executed sequentially .

and Simulation file 1 and 2 also needs to be executed sequentially.

Honestly, I think you’re not using simulations properly.
Simulations are supposed to be independent test cases.
It really feel like you should have multiple scenarios executed from the same simulation, not multiple simulations.

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