Gatling test for async API

994 Views Asked by At

I've an API endpoint that accepts three APIs like the followings:

  • POST /runGraph => to start a job
  • GET /getProject => get status of a job
  • POST /runGraphResult => will give job result

this is what I'm currently doing with Gatling

scenario("runGraph Scenario")
    .exec(
      http("POST runGraph")
      .post("/runGraph")
      .body(RawFileBody("rungraph_req_body.json"))
      .check(
        status is 200,
        bodyString is "\"\""
      ))
    .tryMax(1000) {
      pause(5)
      exec(
        http("GET  getProject")
        .get("/getProject").queryParam("id", env.projectId)
        .check(
          status is 200,
          jsonPath("$..status") in ("running", "successfully-executed", "failed")
        ))
    }
    .exec(
      http("POST runGraphResult")
      .post("/runGraphResult")
      .body(StringBody(s"""{"projectId":"${env.projectId}"}"""))
      .check(
        status is 200,
        jsonPath("$..run." + env.nodeId + ".result.count").ofType[Int] is numberOfRows
      ))

The problem with this is that the final report is giving me stats on individual requests while it would interesting to get the actual time it took the project to change status into failed or successfully-executed

enter image description here

How could I measure in Gatling the time different between the first API call to POST /runGraph and the one when the GET /getProject returned a status failed or successfully-executed?

0

There are 0 best solutions below