// Will create a string like “{id}{id}{id}” with a random number of {id}
def buildIdList = (0 to new Random().nextInt(10) + 1).map(n => “${id}”).toList.mkString(",")
I was hoping Gatling will replace each {id} in the built query string with a value from the feeder but id doesn’t.
Fist, you won’t be able to directly use the whole Feeder API, but you can re-use the Feeder utilities.
Then, I might be wrong, but it’s more likely that you actually need unique randomly picked ids.
If so, a simple approach would be to inject into a Set, but if your possible values list is not big enough, collisions would be high, so your distribution would change and you’d need a more complex approach.
With Gatling 2:
val data: Array[Map[String, String]] = csv(“ids.csv”).data // get the underlying array
val feedIds = (session: Session) => {
val random = ThreadLocalRandom.current
val ids = (0 to random.nextInt(10 + 1).map(n = data(n)(“id”).toSet.mkString(",")
session.set(“ids”, ids)
}
I’m still confused about when to use the methods imported by import bootstrap._ and when not to. That was the problem in this thread. If you can shed some light on that, that would be helpful.