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

89 views
Skip to first unread message

wolfgang

unread,
Jul 3, 2015, 12:42:44 AM7/3/15
to gat...@googlegroups.com
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

wolfgang

unread,
Jul 3, 2015, 2:58:08 AM7/3/15
to gat...@googlegroups.com
oops, I'm using Gatling 2.1.3


Stéphane LANDELLE

unread,
Jul 15, 2015, 4:23:34 PM7/15/15
to gat...@googlegroups.com
WebSocket support currently only support one single check.

Stéphane Landelle
Lead developer


On Fri, Jul 3, 2015 at 8:58 AM, wolfgang <wolfg...@gmail.com> wrote:
oops, I'm using Gatling 2.1.3


--
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.
For more options, visit https://groups.google.com/d/optout.

Esteban Sánchez

unread,
Jan 22, 2016, 6:05:00 AM1/22/16
to Gatling User Group
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

Esteban Sánchez

unread,
Jan 22, 2016, 6:54:47 AM1/22/16
to Gatling User Group
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"?
Reply all
Reply to author
Forward
0 new messages