Is it possible to set a specific concurrency number for Gatling tests?

For example, given there are 5 different scenarios, when the concurrent number is 2, then what I expect is to run 2 scenarios everytime.

I knew how I can run all the scenarios concurrenctly, like

setUp(
  scenario1.inject(injectionProfile1),
  scenario2.inject(injectionProfile2)
)

And I just wonder how can I implement such a test scenario:

I can set the concurrency number, e.g, 2, in the code or in some other config file, then the test could run by this concurrency number.

Hi @BayonetS,

Sorry, I’m not sure to understand the question.
Can you provide what you tried, what you see and what you expected to see?

What I understood is that you want to have scenario run 2 by 2.
Here what might work in that case:

  setUp(
    scn1.inject(profile1)
      .andThen(
        scn2.inject(profile2),
        scn3.inject(profile3),
      ).andThen(
        scn4.inject(profile4),
        scn5.inject(profile5)
      )
  )

Does that help?

Cheers!

@sbrevet Yes, that does help, thanks for your answer, that’s perfect!

And it’s gonna be better if gatling could provide the ability to read the concurrent number and set up the test scenarios by the framework.

You know, for example, there are 5 different test scenarios, scn1,…scn5, and I just read the user-defined concurrent number from environment variable, properties ,yaml file or something like that.

And I don’t have to build the setUp by myself, I just list all the test scenarios and then they just run by the concurrenty number as expected.

Hi @BayonetS,

Sorry, but again, I am unsure about what to understand here.
Having a fixed amount of concurrent scenarios is a bit unusual.
It’s the first time I, personally, see such a request.

For your use case, you can pass parameters for your amount of concurrent scenarios.

And build your injection profile with:

  
  val scn1: Scenario = ???
  val scn2: Scenario = ???
  val scn3: Scenario = ???
  val scn4: Scenario = ???
  val scn5: Scenario = ???

  val allPopulation = List(
    scn1,
    scn2,
    scn3,
    scn4,
    scn5
  ).map(_.inject(injectionProfile))

  val concurrentAmount = Integer.getInteger("concurrentScenarios", 2)

  setUp(
    allPopulation.tail.grouped(concurrentAmount).foldLeft(allPopulation.head) {
      case (acc, current) => acc.andThen(current)
    }
  )

WDYT?

Cheers!

Yeah, thanks @sbrevet . Literally what you understand is all right.
Hope it could help others with the same request.