500 Response code not counted as KO in simulation log

88 views
Skip to first unread message

Sergio Momos

unread,
May 11, 2021, 3:23:27 PM5/11/21
to Gatling User Group
I am facing a weird issue where in 500 responses are not counted as KO, when I save the status code of the response in a session attribute.
If I remove the check(status.saveAs("STATUS_CODE")) from the request, the 500 responses are counted as KO in the report.
I am wondering if this is the intended behaviour?
My Gatling version is 3.5.1 and scala version is 2.13.5

Stéphane LANDELLE

unread,
May 11, 2021, 3:25:43 PM5/11/21
to gat...@googlegroups.com
As soon as you add your own check on the status, it replaces the default one.
Your check doesn't perform any validation on the status.
You should do something like:

check(status.is(200).saveAs("STATUS_CODE"))

Logo Stéphane Landelle
Chief Technical Officer
twitter: @slandelle
site:
gatling.io




--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gatling/55d1f7f5-4919-4db2-b252-c66e7fa2e489n%40googlegroups.com.

Sergio Momos

unread,
May 11, 2021, 3:38:55 PM5/11/21
to Gatling User Group
Thanks Stephane! After implementing your suggestion, I noticed that the check is happening, but the status code is not getting saved in the session attribute. I am getting this error in the log file:
00:58:58.179 [ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - 'hook-3' crashed with 'j.u.NoSuchElementException: No attribute named 'STATUS_CODE' is defined', forwarding to the next one

Is this happening because Gatling moves to the next request as soon as the check fails? Here is my check expression : check(responseTimeInMillis.saveAs("PREV_REQ_RESP_TIME"), status.is(200).saveAs("STATUS_CODE"))

Stéphane LANDELLE

unread,
May 11, 2021, 3:42:09 PM5/11/21
to gat...@googlegroups.com
Are you trying to both fail the request when the status is not 200 AND always save the status whatever its value? 

check(
  status.is(200),
  status.saveAs("STATUS_CODE")
)

Logo Stéphane Landelle
Chief Technical Officer
twitter: @slandelle
site:
gatling.io


Sergio Momos

unread,
May 11, 2021, 3:47:06 PM5/11/21
to Gatling User Group
Yes that's correct. Works perfectly now. Thanks!
Learned something new today. I am a longtime jmeter user trying out Gatling for the first time today. So far loving it!

Stéphane LANDELLE

unread,
May 12, 2021, 4:53:05 AM5/12/21
to gat...@googlegroups.com
Thanks for your kind words :)


Logo Stéphane Landelle
Chief Technical Officer
twitter: @slandelle
site:
gatling.io



Reply all
Reply to author
Forward
0 new messages