[2.0.0-M3a] Passing the concatenated string

Hi all.

I need to stress test a service that have a strong caching mechanism.
Because of that I need to add some random num to the parameter value I get from CSV via feeder.
How can I do it in gatling?

I tried the following:

def getRand(i: Int) : String = ThreadLocalRandom.current.nextInt(i).toString

val httpProtocol = http.baseURL(“http://media.mtvnservices-d.mtvi.com/pmt/e1/director/dte_devices_test.php”)
.proxy(“localhost”, 8888)

val scn = scenario(“Devices.esi test”)
.feed(csv(“useragents.csv”).circular)
.exec(http(“test”).get("/")
.header(“User-Agent”, “${UserAgent}”.concat(_ => getRand(1000000)))
.check(status.is(200))

)
.pause(1, 2)

Thanks in advance!

You can’t use Gatling EL and code together.

  • either first write an exec function where you store in the Session the getRand result so you can use Gatling EL for both
  • or use a function for the UserAgent value where you manually get the UserAgent Session attribute