Suraj Menon
Suraj Menon

Reputation: 1604

Gatlin test with multiple urls

I am using Gatling to measure the performance of a delete API. The url for the delete looks like

https://endpoint.com/rest/<id>/delete

So I basically want to invoke the delete API with different ID's. My scenario looks something like this:

val scenario =
  exec(
    http("${scenario}")
      .post(getUrl())
      .headers(getHeaders())
      .body(StringBody(body))
      .check(status.is(200))
  )
    .exec(session => {
      val response = session("responsePayload").as[String]
      logger.info(response)
      session;

    })

the getUrl() methods returns the endpoint with a unique id each time it's called. However I see that the method gets called only once & the url returned for the first time is being used in all subsequent calls.

What would be the best way to solve my use-case ?

Upvotes: 0

Views: 467

Answers (1)

St&#233;phane LANDELLE
St&#233;phane LANDELLE

Reputation: 6623

You need to pass a function instead of a hardcoded value so your method is evaluated on each invocation:

.post(session => getUrl())

Upvotes: 2

Related Questions