Gatling: requests inside foreach loop not having the same number of executions
Asked Answered
M

0

10

I have this script:

.foreach("${list}", "item") {
  exec(http("Req 1")
    .post("/path/to/service/one")
    .formParam("param1", "${item}")
    .formParam("param2", "somestring")
    .formParam("param3", "${param3}")
    .check(xpath("/xmlroot/id").saveAs("id"))
    .check(xpath("/xmlroot/version").saveAs("version")))
  .exec(http("Req 2")
    .post("/path/to/service/two")
    .formParam("param1", "${param1}")
    .formParam("param2", "${param2}")
    .formParam("version", "${version}")
    .formParam("id", "${id}")
    .check(status.is(200)))
  .exec(http("Req 3")
    .post("/path/to/service/three")
    .formParam("id", "${id}")
    .formParam("param1", "somestring")
    .formParam("param2", "${item}")
    .check(xpath("/xmlroot/@id").exists))
}

It executes successfully, but it reports that there are only 2 Req 2 requests executed while there are 8 of Req 1 and Req 3. I expect there to be an equal number of requests.

Any idea what could be causing this?

Edit: It seems to be completing different number of requests each run, where it only tries to run as many Req 2 requests as it can fit in the amount of time Req 1 and Req 3 runs. Are they fired simultaneously? I assumed these are fired one after the other.

Edit2: screenshot of results Here is a screenshot of one of the reports generated. It shows that Req 2 executed 75% less times, and that the requests are also around 3 times slower than Req 1 and Req 3.

Edit3: Setup and scenario:

  val scenario = scenario("Scenario")
    .exitBlockOnFail {
      exec(loginAction,
        actionThatEndsWithTheLoop)
    }

  setUp(scenario.inject(atOnceUsers(1)))
    .assertions(global.successfulRequests.percent.is(100))
    .protocols(httpProtocol)

I only run 1 user so all of the 8 iterations are expected for each of the requests.

Malherbe answered 4/10, 2017 at 11:36 Comment(5)
Are you sure it's not just showing that only 2 of them were successful? exec calls as you listed above execute in sequence, so I don't see how it would be possible to have fewer Req2 than Req3. Can you show the report?Shortsighted
Yes, I'm sure that only 2 were sent and both were successful, no failed requests. I can show the report when I get back to the office next week.Malherbe
Attached screenshot of the report.Malherbe
Can we see the actual code of (a) the setup call, and (b) any scenarios run by setup?Shortsighted
Is it possible that you have other request with identical names? How is populated your list? Req2 is not bound to item.Domella

© 2022 - 2024 — McMap. All rights reserved.