Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

doIf not working with session

Tags:

scala

gatling

I´m trying to use Gatling, where I just want to execute some steps in the first scenario iteration, here my code

def create(): ScenarioBuilder = {
    scenario(name)
      .exec(session => session.set("DEBUG", debug_set))
      .exec(session => session.set("client_id", session.userId))
      .doIf(session => session("initialized").asOption[String].isEmpty) {
        exec(Identity.getIdentityToken)
        exec(session => session.set("initialized", "true"))
      }
      .exitHereIfFailed
      .during(Duration(15, MINUTES)) {
        exec(X.setupVars)
          .exec(X.create)
          .pause(Duration(1, SECONDS))
          .exec(X.get)
      }
  }
}

Somehow first iteration where initialized it´s not defined it´s not getting there, since I dont see the logs the execution of the one of the steps.

Any idea what I´m doing wrong?

like image 969
paul Avatar asked Dec 11 '22 13:12

paul


1 Answers

One dot is missing for the second exec in your doIf:

.doIf(session => session("initialized").asOption[String].isEmpty) {
    exec(Identity.getIdentityToken)
    .exec(session => session.set("initialized", "true"))
}

Cheers,
Paul as well :)
Gatling Team

like image 105
Paul-Henri PILLET Avatar answered Dec 27 '22 07:12

Paul-Henri PILLET