Repeat blocks and ChainBuilder

I was using something similar to the following with 2.0.0-M3a, but it is no longer working with 2.0.0-RC1.

My question is what do I pass in to addXmlPostLoop() for chain? I had been passing in bootstrap, but that has been removed in RC1.

def addXmlPost(chain: ChainBuilder, i: Int) =

def addXmlPostLoop(chain: ChainBuilder): ChainBuilder =
    (0 until numberOfLoops).foldLeft(chain)(addXmlPost)

Hi Larry,

Using Gatling’s repeat, you can obtain a similar behaviour and rely only on Gatling’s DSL :

repeat(numberOfLoops, “i”) {
.body(StringBody(session => createXml(session(“i").as[Int])))

Some explanations :

  • repeat works lilke your everyday for loop : starts at 0, repeat a specified number of times
  • the second parameter of repeat is the counter name, which is set to i here and stored in the user’s session
  • Then, you execute your request, and set the body (I used StringBody here, but it works the same for any type of body, they all allow to get data from the user’s session)
  • Then call createXml, using the counter stored in the session with session(“i").as[Int]

Here are the related Gatling 2.0.0-RC1 documentation for each “component":

Hope this helps !



Thank you Pierre. I think that will work for me, and appears to be a bit cleaner by relying only on the Gatling DSL.