[Gatling2] How to synchronize scenarios

Hi,

I am new with gatling and scala…

I have 2 scenario and I would like to synchronize them.

I have fount a way to synchronize users in the same scenario using rendezVous, but not sure if it is possible to apply it to multiple scenarios.

What I would like to do:

  1. scenario 1: admin create game A

  2. scenario 2: all users connect to game A and play round 1

  3. scenario 1: admin check round 1 results

What would be the best way to implement that behavior (I currently use pause() that is really not trustable)?

Maybe could I check data in the database, e.g. in scenario2 I wait until game A is present? How to do that?

Maybe is it possible to use a global variable as discussed here: https://groups.google.com/forum/#!searchin/gatling/global$20variable/gatling/2le9xjI0DNc/DJOUKFyYlWcJ

Something like:

`
var isGameCreated = new AtomicReference(false)

`

then in the first scenario:

`
.exec { session =>
isGameCreated.set(true)
session
}

`

This one compiles, but isn’t a more elegant way to do that?

and finally in the second scenario:

`
.asLongAs(! isGameCreated.get()) {
.pause(1)
}

`

This last one does not compile.

Ok, I have been able to make it work with global variables, not sure if it is the best way to do.

Here is the code:

`
var gameCreated = new AtomicReference(false)

val superAdmin = scenario(“SuperAdmin”)
[…]

.exec { session =>
// here we update the global variable
gameCreated.set(true)

val player = scenario(“Player”).feed(feeder)
.exec { session =>
session
.set(“gameCreated”, gameCreated)
}
// wait until game is created
.asLongAs(session => !(session(“gameCreated”)).as[AtomicReference[Boolean]].get()) {
pause(1)
}
.exec { session =>
println(“Connect user.”)
session
}
[…]

`

Any comment?

LGTM

It doesn’t work for me without the additional pause after asLongAs block. Am I missing something?

// wait until game is created
.asLongAs(session => !(session(“gameCreated”)).as[AtomicReference[Boolean]].get()) {
pause(1)
}.pause(1)