Feeder that create scenarios

Hi,

my question comes based on what I think I understood from the documentation and testing Gatling out. I hope the following is correct:

  1. Multiple exec’s in the same scenario are executed after each other and not in parallel.
  2. Feeders can only be used inside a scenario.
  3. To have 2 http request run in parallel i’d have to create 2 scenarios where each scenario has 1 exec with the http request.

I am testing a web service post api that takes different json data as input. I wanted to store each test, which would be a different json blog, in a different file in the same directory. Also I want to execute each request (each json file) in parallel and not sequential, which would mean for each request (each json file) a new scenario.

So what would be nice is if I could write a Feeder that reads in all files from my directory and create’s an array of scenarios from it that I can launch using “setUp(arrayScenarios.inject(atOnce(10 users)))”. The feeder itself would create the scenario with the appropriate “.check(…)” in place.

Is that doable or just a dumb idea :slight_smile:

Thx
—Joerg—

Hi,

my question comes based on what I think I understood from the
documentation and testing Gatling out. I hope the following is correct:

1. Multiple exec's in the same scenario are executed after each other and
not in parallel.

true

2. Feeders can only be used inside a scenario.

or a chain
but it has to be passed to feed()

I don't see your point here.

3. To have 2 http request run in parallel i'd have to create 2 scenarios
where each scenario has 1 exec with the http request.

It depends on if you want those to be executed by the same virtual user or
not.

If no:
you can also have several users run the same scenario

if yes:
In Gatling 2 master/snapshot/upcoming 2M4, you can attach resources to a
HTTP request and those will be fetched in parallel (simulates page
resources fetching or ajax calls).
But at the moment it has to be attached to a root request, not top level
like what you want.

I am testing a web service post api that takes different json data as
input. I wanted to store each test, which would be a different json blog,
in a different file in the same directory. Also I want to execute each
request (each json file) in parallel and not sequential, which would mean
for each request (each json file) a new scenario.

So what would be nice is if I could write a Feeder that reads in all files
from my directory and create's an array of scenarios from it that I can
launch using "setUp(arrayScenarios.inject(atOnce(10 users)))". The feeder
itself would create the scenario with the appropriate ".check(..)" in
place.

Is that doable or just a dumb idea :slight_smile:

First, I advise you stick to Gatling defaults and place your body templates
into expected folder:

However, you can change it with -bf:

Then, Feeder is not suited for your needs (at least, as long as we don't
have top level parallel requests, as mentioned above, but I'd like to be
convinced by your use case).

Create a method that takes a body template location and returns a scenario.
Then list all the files in your template, and for each, call setup with the
above method result.

Get it?

Cheers,

Stéphane

Hi,

my question comes based on what I think I understood from the documentation and testing Gatling out. I hope the following is correct:

  1. Multiple exec’s in the same scenario are executed after each other and not in parallel.

true

  1. Feeders can only be used inside a scenario.

or a chain
but it has to be passed to feed()

I don’t see your point here.

No point. Just stating what I thought I understood :slight_smile:

  1. To have 2 http request run in parallel i’d have to create 2 scenarios where each scenario has 1 exec with the http request.

It depends on if you want those to be executed by the same virtual user or not.

If no:
you can also have several users run the same scenario

if yes:
In Gatling 2 master/snapshot/upcoming 2M4, you can attach resources to a HTTP request and those will be fetched in parallel (simulates page resources fetching or ajax calls).
But at the moment it has to be attached to a root request, not top level like what you want.

Got it.

I am testing a web service post api that takes different json data as input. I wanted to store each test, which would be a different json blog, in a different file in the same directory. Also I want to execute each request (each json file) in parallel and not sequential, which would mean for each request (each json file) a new scenario.

So what would be nice is if I could write a Feeder that reads in all files from my directory and create’s an array of scenarios from it that I can launch using “setUp(arrayScenarios.inject(atOnce(10 users)))”. The feeder itself would create the scenario with the appropriate “.check(…)” in place.

Is that doable or just a dumb idea :slight_smile:

First, I advise you stick to Gatling defaults and place your body templates into expected folder: https://github.com/excilys/gatling/wiki/HTTP#wiki-request-body
However, you can change it with -bf: https://github.com/excilys/gatling/wiki/Configuration#wiki-cli-options

Then, Feeder is not suited for your needs (at least, as long as we don’t have top level parallel requests, as mentioned above, but I’d like to be convinced by your use case).

The use case would be to simply create new test runs by having anybody on a team create a bunch of files in a specific directory and run a test pointing to that directory. This is not a UI test cases. This is basically for plain web service test cases. I don’t want to create/change a script every time I add a new file, delete a file. But from what you describe below that is possible without using a feeder. So “no use case” anymore :slight_smile:

Create a method that takes a body template location and returns a scenario.
Then list all the files in your template, and for each, call setup with the above method result.

Get it?

Kind off until you said “…for each, call setup…”. Wouldn’t that imply they are executed serial and not in parallel?

Thx
—Joerg—

In the end, a Simulation is just a plain old Scala class.
What I suggest is to scan your directory and have a many scenarios as you have files when the class is instanciated (not when it’s executed).

I have to go, but I can help later if you’re stuck.

The only thing I am stuck with is the setUp call.
If I have a List or Seq of scenarios, how to I pass them into the setUp call, which I think takes a Seq of PopulatedScenarioBuilder?

Thx
—Joerg—

Arghhhh

If you’re using 2M3a, Simulation.setUp signature was stupid back then:
https://github.com/excilys/gatling/blob/2.0.0-M3X/gatling-core/src/main/scala/io/gatling/core/scenario/Simulation.scala#L36-L39

The idea was to enforce users to pass at least one scenario, but that just made things horrible for users trying to do exactly like you.

If you’re using snapshot, the signature is more convenient.
https://github.com/excilys/gatling/blob/master/gatling-core/src/main/scala/io/gatling/core/scenario/Simulation.scala#L57

So, assuming you have a List[ScenarioBuilder]:

with 2M3a:

val scns: List[ScenarioBuilder] = ???
val profiledScenarios = scns.map(_.inject(atOnce(1)))
setUp(profiledScenarios.head, profiledScenarios.tail: _*)

with snapshot:

val scns: List[ScenarioBuilder] = ???
val profiledScenarios = scns.map(_.inject(atOnceUsers(1)))
setUp(profiledScenarios: _*)

casting to _* is how you deal with passing a sequence to a vararg/array in Scala

I’ll also change snapshot so that you can pile up setUps, so you can write:

val scns: List[ScenarioBuilder] = ???
val profiledScenarios = scns.map(_.inject(atOnceUsers(1)))
profiledScenarios.forEach(setUp)

Cheers,

Stéphane

Very nice. Thank you!

You’re welcome!