The “userFeeder” has two values: “user”, which is the username, and “pause”, which is how long I want to pause for each URL. However, I can’t seem to access the value that’s in “pause” when I try to execute the pause. In this case, and in a simpler one with the normal “pause” method, I get a parse exception.
How can I do this? Is this even possible? The documentation seems to indicate that something like I did should be possible, but it’s not working. I’d also love to be able to do something similar for how often I repeat an action as well.
EL expressions can’t be parsed implicitly inside a function.
And pauseCustom, as stated by its signature, can’t access the session, so cannot retrieve user data.
You can convert your data from String to Long directly in your feeder:
val feeder = csv(fname).map { record =>
record.map {
case (“pause”, value) => “pause” → value.toLong
case entry => entry
}
}.random
This is easier with Gatling 2 as feeders have a transform method for this purpose.
class TestSim extends Simulation
{
val numUsers = Integer.getInteger(“users”, 10);
val rampUp = java.lang.Long.getLong(“ramp”, 0L);
val fname = System.getProperty(“ccodes”);
// The next two lines copy data from a file and put it into an array.
/val cCodes = new collection.mutable.ArrayBuffer[String]/
/Source.fromFile(fname).getLines.foreach(code => cCodes += code)/
val httpConf = httpConfig.baseURL(“http://localhost:8080”)
.acceptHeader(“application/json”)
/val userFeeder = Array(Map(“user” → “foo”, “pause” → 1),/
/* Map(“user” → “bar”, “pause” → 2),/
/ Map(“user” → “baz”, “pause” → 3)).random*/
val userFeeder = csv(“user.dat”).map { record =>
record.map {
case (“delay”, value) => “delay” → value.toLong
case entry => entry
}
}.random
[error] /home/dev/rmt/volt-getaor/src/main/scala/VoltGetAor.scala:31: value random is not a member of Iterator[scala.collection.immutable.Map[java.lang.String,Any]]
[error] possible cause: maybe a semicolon is missing before `value random’?
[error] }.random
[error] ^
[error] /home/dev/rmt/volt-getaor/src/main/scala/VoltGetAor.scala:40: not found: value delay
[error] .pause(delay)
[error] ^
I’ll apologize now if it’s my own stupidity, but this was thrust upon me late last week and I never programmed in Scala before.
Hopefully last question: how do I access the value then in the “.pause()” call? It looks like I can simply access the userFeeder array and access a value, but then I wouldn’t know if that value is the one being referenced somewhere else in the session. The examples that come with Gatling assume that all values coming out of a feeder are accessed in strings, which is not the case here.
Ha, I’m very sorry: I realize that Gatling 1 doesn’t support dynamic pauses, only Gatling 2 does.
If that’s a feature you really need, you’ll have to migrate.