Parallel execution of multiple scenarios
Asked Answered
R

3

33

What ist the best practice for parallel execution of multiple scenarios? For example 30% Users execute scenario1 and 70% users scenario2.

Is the code below the right way or is it better to have one scenario with contional executions of REST calls?

class MySimulation extends Simulation {

  val userIdsData = csv(userIdsCSV).queue



  ...



  val scenario1 = scenario("Scenario 1")

    .feed(userIdsData)

    .get(...)



  val scenario2 = scenario("Scenario 2")

    .feed(userIdsData)

    .get(...)

    .post(...)



  setUp(scenario1.inject(rampUsers(30) over (ramp seconds))

      .protocols(HttpConfig.value(baseURL)),

    scenario2.inject(rampUsers(70) over (ramp seconds))

      .protocols(HttpConfig.value(baseURL))

  )

}
Riorsson answered 5/12, 2016 at 8:48 Comment(0)
R
24

Whatever you are doing is absolutely fine.

The way you are running the setup you will see that the requests are running in parallel.

Ratal answered 5/12, 2016 at 18:30 Comment(5)
Does a scenario composed as: scenario("Scenario Name").exec(Search.search, Browse.browse, Edit.edit) run in parallel ? Or the three components will be executed sequentially ?Pancratium
@Pancratium Runs in parallel and not in sequence.Ratal
Thanks. It is still a bit confusing when should I use the idiom above for parallel execution, and when should I use instead distinct "users", as in: setUp(users.inject(atOnceUsers(1), admin.inject(atOnceUsers(1)).protocols(httpConf)) Could you clarify ?Pancratium
what about doing one-time POST request before and after scenario - #63386659 - I am not getting POST requests at all - how can I even debugResemblance
Could you explain why exactly this runs in parallel?Acervate
R
14

Gatling will run each item within SetUp in parallel where as each item defined in a scenario will be run sequentially. As you can see from the link

The definition of the injection profile of users is done with the inject method. This method takes as argument a sequence of injection steps that will be processed sequentially.

So your above code will run scenario01 ramp to 30 over x seconds and scenario02 ramp to 70 over y seconds in parallel.

Redbug answered 6/12, 2016 at 11:7 Comment(0)
L
1

You can also try with below code .

scenario1.inject(rampConcurrentUsers(0) to (6) during(10),constantConcurrentUsers(6) during(60 seconds)),

scenario2.inject(rampConcurrentUsers(0) to (4) during(10),constantConcurrentUsers(4) during(60 seconds))
Litman answered 18/10, 2019 at 7:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.