Hi friends,
I’am using Galting 3.2 and in the web socket stress test I use the subcribe method to test the correct read real -time notifications (stress test for In memory broker):
The part of code is:
val answerEventCheck = ws.checkTextMessage("<<RECEIVER Notification received")
.check(regex("^a.MESSAGE.testing."))
…
.exec(ws("<<RECEIVER - SUBSCRIBE")
.sendText("[“SUBSCRIBE\n”+“X-Authorization”+":"+"${X-Authorization}"+"\nid:sub-0\ndestination:/topic/messages\n\n\u0000"]")
.await(seconds seconds)(answerEventCheck)
…
This ‘subscribe execution’ exits (unless in a cycle) when the websocket checks the correct single message (regex pattern). How can I count or read exactly the N notifications arrived for the user that I had opened the socket (with the same regex)?
Before the version 3.2 there was a websocket listener but for this version it’s not present. It is possible to count the N notifications received.
Any suggest?
Regards.
hi Sebastiano,
I’m answering this question for the sake of future readers, although you might have already found a solution for your problem.
I did not use gatling 3.2, but with the current implementation (3.5.1) if you provide multiple checks, each one is going to be checked on one message, with the rest being applied to consecutive messages. so if you want to check n messages, provide n checks:
def await(timeout: FiniteDuration)(checks: WsTextFrameCheck*)
Hope this helps
Hi guys,
I’m also interested in such a solution, I want to get latency between messages. I’ve found such a solution put N check with the same Name, so then these checks will be on the same column in the report.
class Websocket extends Simulation {
val httpProtocol: HttpProtocolBuilder = http.baseUrl(“http://demos.kaazing.com”)
.wsBaseUrl(“wss://someWsUrl”)
val scene = scenario(“WS”)
.exec(ws(“OpenSocket”).connect("")
.onConnected(exec(ws(“Topic”)
.sendText(“data”)
.await(30)(ws.checkTextMessage(“result”))
.await(30)(ws.checkTextMessage(“result”))
.await(30)(ws.checkTextMessage(“result”))
.await(30)(ws.checkTextMessage(“result”))
.await(30)(ws.checkTextMessage(“result”))
.await(30)(ws.checkTextMessage(“result”))
)))
.pause(30)
.exec(ws(“closeConnection”).close)
setUp(scene.inject(atOnceUsers(1)).protocols(httpProtocol))
}
I want to create a function that allows adding N checks to sendText. I tried to put an object which returned from sendText to session and then calls function repeat where I retrieve that object from the session and add the check, but I got “type mismatch” error.
type mismatch;
found : Unit
required: io.gatling.commons.validation.Validation[io.gatling.core.session.Session]
exec(session=> println(session(“ws-send-awaiter”).as[String]))
val scene = scenario(“WS”)
.exec(ws(“OpenSocket”)
.connect("")
.onConnected(exec(session => session.set(“ws-send-awaiter”, ws(“Topic”)
.sendText(“data”)
))))
.repeat(10,“i”) {
exec(session=> session(“ws-send-awaiter”).as[io.gatling.http.action.ws.WsSendTextFrameBuilder].await(10)(ws.checkTextMessage(“result”)))
}
.pause(30)
.exec(ws(“closeConnection”).close)
среда, 17 марта 2021 г. в 11:12:37 UTC+2, abilyak@gmail.com: