0
votes

I am trying to send a http request and fail if the request returns not 200:

exec(http("Get some html")
      .get("${aggUrl}/somePath")
      .check(status.is(200))
      .check(regex("websocket=(.*?)&").saveAs("wsLink"))
)

The server sends the 401 response:

[HTTP/1.1 401 Unauthorized]{"errors":[{"code":"authentication.failure","message":"Failed to authenticate user details"}]}]

I expect in console something like "expecting code 200, but was 401"

But the actual error is:

[ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - 'hook-38' crashed with 'j.u.NoSuchElementException: No attribute named 'wsLink' is defined', forwarding to the next one
[ERROR] i.g.h.a.HttpRequestAction - 'httpRequest-37' failed to execute: No attribute named 'wsLink' is defined

So I assume that the ".check(status.is(200))" is just ignored?

How then should I fail the test?

Thanks in advance, Andrei Isakov

1
Which version of Gatling do you use? Have you upgraded to the latest version (3.4.0 as of now)?Stéphane LANDELLE
Hello Stephane! Yes, I use gatling 3.4.0: <gatling.version>3.4.0</gatling.version> <gatling.plugin.version>3.1.0</gatling.plugin.version> <scala-maven-plugin.version>4.4.0</scala-maven-plugin.version> The same behavior was in gatling 3.3.1.Andrei Isakov
Actually, the problem is that I see the output of regex check, but do not see the output of the status check. There is a field "displayActualValue" in this check, but I have no idea how to use it. The compiler always complain. Is there an example? Thanks!Andrei Isakov

1 Answers

0
votes

I think you're mistaken.

[ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - 'hook-38' crashed with 'j.u.NoSuchElementException: No attribute named 'wsLink' is defined', forwarding to the next one
[ERROR] i.g.h.a.HttpRequestAction - 'httpRequest-37' failed to execute: No attribute named 'wsLink' is defined

Those errors happens happen AFTER the request you provided the code for, in an exec block you didn't mentioned where you're trying to inspect the Session's content and fetch the wsLink attribute that doesn't exist because the request failed.

Check failures are not logged with ERROR level. You have to either lower the logging level (see logback.xml) or check the HTML reports.