Chain block after doWhileDuring was not executed

Hi there,
I was blocked when I use doWhileDuring. I’m using Gatling 3.7.4 and here was my scenario.
exec(
http …
)
.doWhileDuring(condition, duration){
exec(
http …
)
}
.exec(

)
And my problem was the 2nd exec block chained after doWhileDuring was not executed if doWhileDuring block finished because it reached the duration. If doWhileDuring block finished because it didn’t match the condition, 2nd exec block was running good.

Anything wrong I did.

Oops, I mean the 3rd exec, after doWhileDuring

Hello,

Let me rephrase this with my own word.

You have a doWhileDuring containing a chain of 2 execs.
You expected that the 2 execs will always be executed together or not at all.

From your experience, the doWhileDuring, in another hand, stops at any step if the duration expires but check the condition only when fully execute the chain.

I will check if this is the current AND wanted behavior but in the meantime, you can work around that by checking if you need to exec the second one after the loop.

Please, try with explicitly set the exitASAP to false

Could you tell me in which language is your scenario ? (scala, java, kotlin)
Perhaps it’s just the default values that were wrongly reported.

Please check this pinned post: How to Ask a Question - #2

We ask that you provide a reproducer for very good reasons:

  • it saves time for the people willing to help you
  • the issue might be something completely different from your guess

We also ask that you test with the latest Gatling version:

  • your issue might have been already fixed

I’ve done a reproducer of the setup you’ve described and it works just fine:

import io.gatling.core.Predef._
import io.gatling.http.Predef._

import scala.concurrent.duration._

class DoWhileDuringSim extends Simulation {

  val httpProtocol = http
    .baseUrl("https://github.com") // Here is the root for all relative URLs
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers
    .acceptLanguageHeader("en-US,en;q=0.5")
    .acceptEncodingHeader("gzip, deflate")
    .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")

  val scn = scenario("Scenario")
    .doWhileDuring(_ => true, 3.seconds) {
      exec(http("InLoop").get("/gatling/gatling"))
        .pause(1)
    }.exec(http("AfterLoop").get("/gatling/gatling"))

  setUp(scn.inject(atOnceUsers(1)).protocols(httpProtocol))
}
================================================================================
2022-03-20 08:27:03                                           3s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=4      KO=0     )
> InLoop                                                   (OK=3      KO=0     )
> AfterLoop                                                (OK=1      KO=0     )

---- Scenario ------------------------------------------------------------------
[##########################################################################]100%
          waiting: 0      / active: 0      / done: 1
================================================================================