Run a scenario multiple time

Hi,

I’m building a load test and I have a question :

I would like to run a specific group of scenario multiple time (I don’t want to make a loop inside the scenario for each user)

Assuming my scenario is

val scn = scenario(“my scenario”)
.exec(…)
.exec(…)
.exec(…)

and assuming that I have a first scenario which made some initialization :

val scnClean = scenario(“clean process”).exec((s: Session) => { …do some process in DB… })

How to run the couple (scnClean followed by scn) multiple time in the setUp ?

Actually, my configuration is :

setUp(
scnClean.inject(atOnce(1)),
scn.inject(nothingFor(5 seconds), atOnce(10))
)

Thanks !

Won’t work. Users are users, not threads like in JMeter. You don’t have real users who empty their browser cache and cookies, and start all over again. This way of thinking is just a hack.

As I see it, you really want to launch multiple simulations. Then, you can for example launch Gatling from maven and set up multiple executions where you force different simulationClass.

Stéphane

I also need some initialization code to be run on start and this is the hack I’m using right now.
It would be nice to have a setUp/tearDown methods in Gatling… no need to be synchronous, but just a guarantee they’ll run before actual simulation.

So what do you propose? Were would you place such hooks? When would they be called?

Useful hooks in my lr scripts

  • vuser init/end
  • iteration start/end
  • transaction start/end
  • sub transaction start/end

And arguably you can make a case for scenario start/end as well.

Vuser init is used to set up things that never change: auto filters, generic global checks, picking up command line arguments, that sort of thing.
Sometimes people use that phase to log in, but that really isn’t proper practice.

Iteration start/end usually revolves around preparing information needed for the session. Pre calculation of expected values, setting up checks for usernames etc.

Transaction start/end has a lot of different uses. Custom checks of course, but also things like calculating the full transaction name, adding time measurements, postprocessing of captured values, adding extra transactions to allow measuring response times grouped by what the requirement is…

Hi Floris,

I get that, but I guess that what Jean-Philippe actually wants is hooks for setting/resetting his system under test’s state.

If that’s so, I’m a bit cautious/skeptical as there’s some many ways of doing (starting VM, launching script, calling REST API, etc) that I’m not sure that’s a stress tool concern. I also don’t want to “pollute” the JVM with things that might linger and hurt the actual stress test.

Does it really matter what he does inside each of the scenarios?

I understand that people doing things you did not anticipate makes you worry about memory pressure, but telling people to move code you don’t like to maven … won’t scale. At the very least it will stop being an option once you build a web based interface around this tool.

I’ve seen some terrible lr code before. Best you can do is make frameworks that enable people to do the right thing, and hope they will use them.

You’re might be right.
I’ve logged an issue: https://github.com/excilys/gatling/issues/1475

I won’t have to cycles to dig this any time soon, so if people come up with great ideas, feel free to discuss there.

My company use shared environment to test their systems and those environments cannot be recreated automatically yet.
This is not cool because you never know in which state the environment will be.
Even if you could recreate the environments each time, I don’t think one would want to do it between each test execution.

In my case, I must make sure JMS queues are empty, flush some database tables, remove some files, etc. I know I can do this in some other scripting tool, but you know Scala would be better at this. I have currently plugged in a synchronous http client in my simulation to do these cleanup tasks just before calling setUp() with my scenarios.

Maybe I’m doing it wrong, but that seems to work well for me, I just feel many people would need to do this.

OK, so having overridable setUp and tearDown methods defined on Simulation would meet your needs?

Yes, but with the ability to reuse protocols (http, sql, jms) inside of them.
If someone could sketch the general design I could jump in!

Give them a hand, they take an arm… :slight_smile:

This is actually complex: have to disable logging, properly clean up connections and the likes, etc.
Will give it a thought.

simple workaround for me is using this trait I made: https://gist.github.com/jplmelanson/7327385#file-testablesimulation-scala
which allow to write simulation in this pattern: https://gist.github.com/jplmelanson/7327453#file-exampletestablesimulation-scala

Thanks for the pointers, that’s neat!