Using a session variable as pause time

Hello,

I have some code that looks like this:

[…]

.exec(http(“Go to Sign Up”)
.get("""/users/sign_up""")
.headers(headers_1))
.pause(28)

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?

Thanks,
Alejandro

Hi,

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 => http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/TimeUnit.html
SECONDS, MILLISECONDS…

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
hainBuilder
(minDuration: scala.concurrent.duration.Duration,maxDuration: scala.concurrent.duration.Duration)io.gatling.core.structure.ChainBuil
der
(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
.structure.ChainBuilder
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)
}

.pause("${delay_one_duration}")

OK. Thank you for your answers.