Gatling : session.isFailed returning true even the previously executed request has succeeded

Hi Everyone,

I was tasked with running some performance tests in order to benchmark our systems. I designed the scenario as below :

var scn: ScenarioBuilder = scenario(“Sample Scenario”)
.exec(
forever(
exec()
.pause(2, 5)
.doIf(session => !session.isFailed) {
randomSwitch(
70d → exec(),
15d → exec(<third request),
15d → exec()
)
}
)
)

The issue I’m facing cropped up when we were performing fail-over tests in our system. I noticed that during the simulation all of requests stopped executing after the “first request” once a failure was introduced in the system.

I checked the logs and the “first request” was successful and as per my understanding !session.isFailed condition should be true allowing for further execution of the scenario.

Can anyone please share why the condition is being marked as false instead of true?

Hi,

The session keeps its status even after several requests.

As you mentioned, “a failure was introduced in the system”

One of the primary goals is to have points in your scenario where the virtual user may leave (because of the failure) with exitHereIfFailed

If you want to recover, you should mark your session as succeeded

var scn: ScenarioBuilder = scenario("Sample Scenario")
    .exec(
      forever(
        exec(session => session.markAsSucceeded) // <---- reset the status
          .exec(<first request>)
          .pause(2, 5)
          .doIf(session => !session.isFailed) {
            randomSwitch(
              70d -> exec(<second request>),
              15d -> exec(<third request),
              15d -> exec(<fourth request>)
            )
          }
      )
    )

Hi Sébastien,

Thank you for sharing the info. This helped me resolve the issue. :slight_smile: