No attribute named '<session-vairable>' is defined post facing 5xx,4xx errors

Hi,

I’m trying to run a soak test with the below simulation. The problem that I’m facing is that after some time, the system receives the following error :

status.is(200), but actually found 504
status.is(200), but actually found 500
status.is(200), but actually found 408

post the introduction of the above errors, my simulation started logging errors due to : no attribute named ‘csrfToken’ is defined

var scn: ScenarioBuilder = scenario(“Soak Test”)
.exec(Auth.auth)
.pause(1 second, 10 seconds)
.during (1 hour) (
exec(Stream.one)
.pause(1 second, 10 seconds)
.exec(Stream.two)
.pause(1 second, 10 seconds)
.exec(Stream.three("${status}"))
.pause(1 second, 10 seconds)
.exec(Stream.three(“Available”))
.pause(1 second, 10 seconds)
.exec(Stream.four)
.pause(5 seconds, 10 seconds)
)
.exec(Auth.logout)

the csrfToken is being extracted from the Auth :

val auth: ChainBuilder = feed(Config.csvFeeder)
.exec(http("/ui/auth")
.post(":443/ui/auth")
.header(“content-type”, “application/x-www-form-urlencoded”)
.header(“user-agent”, “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36”)
.formParamSeq(
Seq((“uid”,"${userName}"),
(“pass”,"${password}"))
)
.check(status.is(Config.success)))
.exec(
getCookieValue(CookieKey(“TOKEN”)
.withDomain(System.getProperty(“baseUrl”))
.withPath("/ui")
.withSecure(true)
.saveAs(“csrfToken”))
)

val one: ChainBuilder = exec(http("/endpoint")
.post("/endpoint")
.header(“x-csrf-token”, “${csrfToken}”)
.body(
ElFileBody(“bodies/streams/email/email-stream-req.json”)
).asJson
.check(status.is(Config.success))
.check(jsonPath("$…id").saveAs(“caseId”))
.check(jsonPath("$…caseNu").saveAs(“caseNu”)))

Wanted to understand why is the simulation unable to find the variable which was working fine previously before the introduction of these errors

Hi,

Bumping this thread as I’m still unable to figure out what is going wrong with the setup. Is it that the session variable is loosing the stored keys when the previous http request is failing?

Thanks in advance,
Ish

What does your injection profile look like?

I’d say that this no attribute named 'csrfToken' is defined happens for newly injected users who were never able to capture it as “/ui/auth” failed with 408/500/504 for them.

Hi Stéphane,

The injection profile is a simple one. Its rampUsers(1800) during (300 seconds).

This does looks like what you’ve mentioned happened when a newly injected user fails in the errors. Is there any way to mitigate those users?

Well, Gatling is only the messenger here. The core issue is that your
application can't withstand the load you're throwing at it and those users
don't fail. Investigate your performance issues and fix them, or decide
your performance target is too high.