Exiting user session when any HTTP status is 401.

I have a simulation built which normally runs successfully. It’s a modification of what was generated by the recorder and I have a scenario that does what I expect.

Under some conditions (heavy load, primarily), user sessions are invalidated and subsequent requests result in a simple HTTP 401 response from the server.

I’d like for this condition to end the user’s session and for no further HTTP requests be made by that user. Here’s the basic outline of what I have:

import scala.concurrent.duration._

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

class MyUser extends Simulation {
val baseUri = “https://localhost.localdomain/
val httpProtocol = http
.baseURL(baseUri)
.inferHtmlResources()

val headers_0 = Map(
“Accept” → “text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8”,
“Upgrade-Insecure-Requests” → “1”)

object MySession {
val login = exec(
http(“load_login_form”).get(“/login”).headers(headers_0).resources(
http(“login.css”).get(baseUri + “login.css”).headers(headers_0),
http(“login_logo.png”).get(baseUri + “login_logo.png”).headers(headers_0)
)
)
.pause(3)
.exec(
http(“loginExecute”).post(“/login/enter”).headers(headers_0)
.formParam(“username”, “test”)
.formParam(“password”, “secret”)
.resources(
http(“application.css”).get(baseUri + “application.css”).headers(headers_0)
)
)

val search = exec(
http(“search”).get(“/search”).headers(headers_0).resources(
http(“application.css”).get(baseUri + “application.css”).headers(headers_0),
http(“results”).get(baseUri + “results”).headers(headers_0)
)
)

val logout = exec(
http(“logout”).get(“/logout”).headers(headers_0).resources(
http(“login.css”).get(baseUri + “/login.css”).headers(headers_0),
http(“login_logo.png”).get(baseUri + “login_logo.png”).headers(headers_0)
)
)
}
}

I’m looking to retain all KOs registered by default (including 401) as KOs, but if any of the http responses have a status of 401 (including those called from resources), the user session should stop and the rest of the simulation should continue normally.

I’m trying to work with exitBlockOnFail and check and doIf and doIfOrElse but am encountering syntax errors in most of those cases.

If anybody can point me in a good direction, it would be very much appreciated. I’m on my 3rd iteration reading the documentation on the APIs that I mentioned and I’ve seen a few similar posts but I don’t see solutions that quite seem to do what I’m looking for.

Thanks in advance.
Paul.

No, that’s not possible atm, we don’t have a way to exit only on some particular condition/kind of failure.