Gatling 2 dynamic requestParam on each request

I am trying to run a load test using Gatling 2. I need to generate one of the request parameters dynamically for each request.

My scenario is defined like this:

val scn = scenario("Load Test Scenario")
        .exec(
            http("Test API")
            .post(url)
              .body(StringBody("Some XML"))
              .queryParam("x", DigestUtils.md5Hex(generateX().getBytes("UTF-8")))
          )

def generateX() : String = {
    // generate random string and return
}

      

It only calls generateX once and uses the result in every request. Anyway, is there a generateX call for every request?

Any help was appreciated.

+3


source to share


1 answer


You need to pass a function, not a value. See the Gatling documentation about expression .

Here you can just drop the session input parameter as you are not using it, so you can simply write:



.queryParam("x", _ => DigestUtils.md5Hex(generateX().getBytes("UTF-8")))

      

+6


source







All Articles