Running into issues trying to write recursive scenarios. I’m performance testing a piece of software that has some unpredictable behavior around logout. I cannot modify the base software at this time but i still need to make sure that a user is fully logged out when the scenario ends.
Below is an NDA-friendly version of the scenario i’m trying. It attempts to log the user out, but sometimes users are sent to an authentication screen instead of directly to the logout, and that screen requires a different request to flow through. And sometimes the logged-out screen also flows through to authenticate. I want it to repeat until neither of these screens is hit anymore.
Here i’m hitting a null pointer because when it’s building the handleAuthenticate ScenarioBuilder the current value of handleAuthenticate is null so it tries to execute null when hitting that step. What should I do? If I do this without recursion the code is much more complicated.
val logout = scenario(“Logout”)
.pause(1)
.exec(http(“Logout - OK to logout”)
.post(“logoutURI”)
.headers(logoutHeaders)
.body(StringBody("""
{
bodyJson
}""")).asJson
.check(jsonPath("$.redirectScreenJSONPath").saveAs(“redirectScreen”)))
.exec(handleAuthenticate)
.exitHereIfFailed
private val handleAuthenticate : ScenarioBuilder = scenario(“Handle Authenticate”)
.doIfEquals("${redirectScreen}", “LOGGED_OUT_SCREEN”) {
pause(1)
.exec(http(“Logout - User is logged off”)
.post(“promptURI”)
.headers(logoutHeaders)
.body(StringBody("""
{
bodyJson
}""")).asJson
.check(jsonPath("$.redirectScreenJSONPath").saveAs(“redirectScreen”)))
.exec(handleAuthenticate)
.exitHereIfFailed
}
.doIfEquals("${redirectScreen}", “AUTHENTICATE_SCREEN”) {
pause(1)
.exec(http(“Logout - Authenticate”)
.post(“authenticateURI”)
.headers(logoutHeaders)
.body(StringBody("""
{
bodyJson
}""")).asJson
.check(jsonPath("$.redirectScreenJSONPath").saveAs(“redirectScreen”)))
.exec(handleAuthenticate)
.exitHereIfFailed
}
// If the redirect screen is anything other than these two, we’re done.