Here is what I NEED to do:
.feed("users.csv") // includes username, password, groupid
// login...
.duration(x) {
feed( csv("${groupid}.csv").random )
// interact with the application using the data in the second .csv file
}
But of course, the csv() function takes a string, not an EL expression. I need to be able to compose that string at the appropriate moment in the scenario execution.
I am able to build the string, like so:
.exec( session => {
feed( csv( session.getAttribute("groupid") + ".csv" ).random )
session
})
But unfortunately, the following execs don't see the data. It looks like some kind of scoping issue to me. I'm guessing the feed() expression is doing exactly what it is supposed to be doing, but because it is not part of the outer chain, it's not being placed where it belongs. Am I supposed to be calling .feed on some object within the session object in order to attach it to the ongoing chain?
Any guidance on how to accomplish what I have set out to do? Thanks!
Feeders are instanciated at the same time as the Simulation. You can't defer it to the Simulation runtime, unless you hack with the underlying tools.
How many of those "groupid" files do you have? If you have just a few of them, you can use either doSwitch from Gatling 2 current snapshot, or embedded doIf blocks if you run with Gatling <= 2M3a.
.doSwitch("${groupid}") (
"foo" -> feed(csv("foo.csv").random),
"bar" -> feed(csv("bar.csv").random)
)
This can be generalized:
def groupIdFeed(groupId: String) = groupId -> feed(csv(groupId + ".csv").random)
.doSwitch("${groupid}") (
groupIdFeed("foo"),
groupIdFeed("bar")
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With