0

In my Gatling simulation, I have a list of WebSocket requests that are currently called one after another:

.exec(ws("1").sendText("1").check("..."))
.exec(ws("2").sendText("2").check("..."))
.exec(ws("3").sendText("3").check("..."))

The problem with that is that the checks arrive at different times and they cause test failures. Using a blocking check via wsAwait is not possible because of the requirements.

What I would like to have instead is a single check that collects all the responses. Ideally, it would look something like this:

.exec(
  ws("1").sendText("1"),
  ws("2").sendText("2"),
  ws("3").sendText("3")
  ).check(...)

This is, however, not possible currently. Is there a way I can achieve this?

xeroqu
  • 425
  • 5
  • 14

1 Answers1

0

I would suggest you take a look at Assertions. This will allow you to make an assertion at the end of your simulation; so each scenario will run fully and then you can fail it based on whatever criteria you would like.

Alternatively you could define the exec calls as resources and have the check come after them.

.exec(ws("1").sendText("1").resources(
      ws("2").sendText("2"),
      ws("3").sendText("3")
    ).check(...))
Questioning
  • 1,903
  • 1
  • 29
  • 50
  • I don't want to use assertions as I don't want to create dozens of small simulations. These WS requestd should all be sent and read within a single WS connection. Also, unlike `http`, you cannot use `resources` like that with `ws`. Your answer won't compile. – xeroqu Dec 06 '16 at 12:25
  • You mention that you have used `wsAwait`, a blocking check, but you cannot use non-blocking checks (`wsListen`). Can you go in to more detail? `The expect` function also comes to mind but I have no experience with that one. – Questioning Dec 06 '16 at 12:49
  • I made a mistake in the question: `wsAwait` is a blocking operation, which would not allow next `exec()` to be executed until the `check` returns. In our scenario, we don't have this. Users send requests and in an async fashion they get their replies back from the server. One workaround to my question is using `wsListen` and set `within` to a very long time - just to make sure that `check` returns. I'm looking for a more elegant solution though. – xeroqu Dec 06 '16 at 12:58
  • I've exhausted my knowledge of websockets with gatling here so I can't really suggest anything further. You may have more luck at their [user group](https://groups.google.com/forum/#!forum/gatling) - the big contributors seem active there. – Questioning Dec 06 '16 at 13:41