【问题标题】:How to performance test workflow execution?如何性能测试工作流执行?
【发布时间】:2021-05-10 10:15:24
【问题描述】:

我有 2 个 API

  • 创建工作流(http POST 请求)
  • 检查工作流状态(http GET 请求)

我想对完成工作流需要多长时间进行性能测试。

尝试了两种方法:

选项 1 创建了一个 java 测试,触发工作流创建 API,然后轮询状态 API 以检查状态是否变为已创建。我检查了这个过程所花费的时间,这给了我性能结果。

选项 2 正在使用 Gatling 来做同样的事情

val createWorkflow = http("create").post("").body(ElFileBody("src/main/resources/weather.json")).asJson.check(status.is(200))
    .check(jsonPath("$.id").saveAs("id"))

  val statusWorkflow = http("status").get("/${id}")
    .check(jsonPath("$.status").saveAs("status")).asJson.check(status.is(200))


  val scn = scenario("CREATING")
    .exec(createWorkflow)
    .repeat(20){exec(statusWorkflow)}

加特林机并没有真正起作用(或者我以某种错误的方式做到了)。 Gatling 有没有办法合并多个请求并执行类似于选项 1 的操作

是否有其他工具可以帮助我对此类场景进行性能测试?

【问题讨论】:

标签: performance performance-testing gatling


【解决方案1】:

我认为使用 Gatling 的 tryMax 时应该可以使用下面的方法

.tryMax(100) {
  pause(1)
  .exec(http("status").get("/${id}")
    .check(jsonPath("$.status").saveAs("status")).asJson.check(status.is(200))
  )
}

注意:我没有在本地尝试过。关于 tryMax 的更多信息: https://medium.com/@vcomposieux/load-testing-gatling-tips-tricks-47e829e5d449(轮询:等待异步任务)

https://gatling.io/docs/current/advanced_tutorial/#step-05-check-and-failure-management

【讨论】:

  • 感谢这个。所以下面在某种程度上解决了val scn = scenario("CREATING") .exec(createWorkflow) .doIf("${id.exists()}") { tryMax(100) { exec(statusWorkflow1.check(jsonPath("$.status").is("CREATED"))) } } 但这并不能解决我想要的问题。这给出的结果类似于 Create OK 1 time of API 响应状态 OK 1 KO 16 time of API 响应我想要工作流从 CREATION 到 COMPLETED 所用的时间,而不是 API 响应时间。
猜你喜欢
  • 1970-01-01
  • 2022-01-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-25
  • 1970-01-01
相关资源
最近更新 更多