WebSocket wsAwait: is it possible to define number of frames expected in a feeder?

Hi everyone,
I’ve got a json feeder with a number of different websocket requests (and other data related to these requests) that is picked up randomly.
The difficulty is that number of response frames expected depends on the request that was picked up.

I was trying to use something like this:

.check(wsAwait.within(30).until(framesCount).regex(SomeRegex).saveAs(“myVar”))

But it seems that framesCount is working properly only if it is hard coded in this check. I’ve found no way to use some value from the feeder.
Is it not possible at all? Or am I missing something?

Sorry, if it is a dumb question, I’m totally new to Gatling and Scala =)

Thanks.

Hi,

Sorry for the very late reply.

That’s not possible atm, the number of expected frames is static. Could you please explain how your test works and why it would make sense to make it dynamic (you’re the first one to ever ask)?

Regards,

Hi,
I’ve already found a workaround for my case)

Our application is using STOMP over websocket. Not very common, as far as I see.

The thing is, that rather similar requests to the same destination may result in different numbers of frames sent back in our case. The good thing is, that number of meaningful frames is known for each case in advance.
And further user workflow is more or less similar in all these cases too, the only significant difference being number of frames to wait. So it made sense to me to have this number of frames as a var, defined in a feeder together with other user workflow data.

Possible range of frames count is not that large is our case, so I’ve just made a switch like this:

doSwitch("${expectedFramesCount}")(
      "1" -> exec(myRequest(timeout, 1)),//performing request with 1 frame expected
      "2" -> exec(myRequest(timeout, 2))
        //etc.
 )

def myRequest(timeout: FiniteDuration, expectedFramesCount: Int): WsSendBuilder = ws("My Request")
    .sendText("${someText}")
    .check(wsAwait.within(timeout).until(expectedFramesCount).regex(MyRegex).saveAs("myResponses"))

Thanks for your feedback!

Glad you found a workaround.

Actually, we’re in the (long) process of revamping the WebSocket API for Gatling 3, so what you’ve done might be the proper solution, as you’d currently have to wait for each message.
See https://github.com/gatling/gatling/blob/master/gatling-http/src/test/scala/io/gatling/http/Ws2CompileTest.scala for a sample.

Cheers,