具有多个 url 的 Gatlin 测试

Gatlin test with multiple urls

我正在使用 Gatling 来衡量删除的性能 API。删除的 url 看起来像

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

所以我基本上想用不同的 ID 调用删除 API。我的场景看起来像这样:

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;

    })

getUrl() 方法 returns 端点每次调用时都具有唯一 ID。但是我看到该方法只被调用一次,第一次返回的 url 被用于所有后续调用。

解决我的用例的最佳方法是什么?

您需要传递函数而不是硬编码值,以便在每次调用时评估您的方法:

.post(session => getUrl())