Using a session variable as pause time


I have some code that looks like this:


.exec(http(“Go to Sign Up”)

String session variables can be used with the “${var}” syntax, but I would like to use a numeric session variable (from a feeder) as the amount of seconds to pause. Is that possible?



Only in Gatling 2:
pause("${var}", java.util.concurrent.TimeUnit) if var is an Int
pause("${var}") if var is a Duration

Thanks. I’ve tried with your first suggestion, but it fails with the following error:

11:55:49.645 [ERROR] i.g.a.ZincCompiler$ - /home/ale/Downloads/mercury_lms/gatling_oficina/user-files/simulations/LawVaultSimulationv2
.scala:65: object java.util.concurrent.TimeUnit is not a value
11:55:49.645 [ERROR] i.g.a.ZincCompiler$ - .pause("${delay_one}", java.util.concurrent.TimeUnit)
11:55:49.645 [ERROR] i.g.a.ZincCompiler$ - ^

I’m using 2.0.0-M3.

By the way, I had no success using gatling from Eclipse. Is there an updated guide?

java.util.concurrent.TimeUnit is a java enum =>

Ah. It outputs the following with SECONDS.

12:10:32.775 [ERROR] i.g.a.ZincCompiler$ - /home/ale/Downloads/mercury_lms/gatling_oficina/user-files/simulations/LawVaultSimulationv2
.scala:66: overloaded method value pause with alternatives:
(minDuration: scala.concurrent.duration.Duration,maxDuration: Option[scala.concurrent.duration.Duration])io.gatling.core.structure.C
(minDuration: scala.concurrent.duration.Duration,maxDuration: scala.concurrent.duration.Duration)io.gatling.core.structure.ChainBuil
(minDurationExp: io.gatling.core.session.Session => io.gatling.core.validation.Validation[scala.concurrent.duration.Duration],maxDur
ationExp: io.gatling.core.session.Session => io.gatling.core.validation.Validation[scala.concurrent.duration.Duration])io.gatling.core
cannot be applied to (String, java.util.concurrent.TimeUnit)
12:10:32.775 [ERROR] i.g.a.ZincCompiler$ - .pause("${delay_one}", SECONDS)
12:10:32.775 [ERROR] i.g.a.ZincCompiler$ - ^

Sad news, this methods only exists in master (next version).
If you don’t want to walk on the wild wild side and upgrade to master, you’ll have to first build a duration:

.exec{ session =>
for {
delayOne ← session(“delay_one”).validate[Int])
} yield session.set(“delay_one_duration”, delayOne seconds)


OK. Thank you for your answers.