How to validate and save values at the same time in websocket ?

Hi there,

How can I validate a value and also extract other values from a single response in websocket ??

Here is my request event to login.

exec(
ws(“login to our websocket service”)
.sendText("""{“event”:“login”,“username”:“foo”,“password”:“bar”}""")
.check(wsAwait.within(10 seconds).until(1).jsonPath("$.event").is(“authenticated”))
)

The following events would be returned as a response to the login event above.

{“event”:“authenticated”, “result”:“true”, “userId”:123}
or
{“event”:“authenticated”, “result”:“false”}

What I want to do is that if the event name is “authenticated” and the result attribute is “true” then,
I want to save a value of the userId attribute into a session.

I did like the following at the first but since there’re two wsAwait, the gatling expects two separate events…hm.

exec(
ws(“login to our websocket service”)
.sendText("""{“event”:“login”,“username”:“foo”,“password”:“bar”}""")
.check(wsAwait.within(10 seconds).until(1).jsonPath("$.event").is(“authenticated”))
.check(wsAwait.within(10 seconds).until(1).jsonPath("$.userId").saveAs(“userId”))
)

How can I validate and save values at the same time in a single response (websocket event) ??
Or is there a workaround ?

Thanks a lot.
Wolfgang

oops, I’m using Gatling 2.1.3

WebSocket support currently only support one single check.

Hi Stéphane,

any workaround if one really needs to use several checks? For me, not having the ability to do so is a show stopper

Thanks a lot

Let me explain myself a little bit better. I understand it is very difficult to have several conditions in a check when it comes to a WebSocket message but saving values should be a completely different story.

Why not several “saveAs”?