I have an application with n users connected by websocket, and each time one user send a transaction request, I want to check that I receive n messages : 1 OK as response for the transaction, and n-1 messages as notifications from the other users. I have the following code :
class MySimulation extends Simulation {
val numberOfUsers = 70
val httpConf = http
.baseURL("http://localhost:8080")
.wsBaseURL("ws://localhost:8080")
val scn = scenario("WebSocket")
.during(30 seconds) {
exec(ws("Connect WS").open("/websocket"))
.pause(3 seconds)
.repeat(480) {
exec(ws("Transaction Request").sendText(session => """{my transaction request}""")
.check(wsAwait.within(500 milliseconds).until(numberOfUsers)))
}
.pause(3 seconds)
.exec(ws("Close WS").close)
}
setUp(scn.inject(atOnceUsers(numberOfUsers)).protocols(httpConf))
}
This is working well.
Now I would like to have a scenario with a dynamic number of users : for example I start with 1 user (so I should receive 1 message), then 5 seconds later I have 5 users (then I should receive 5 messages for each user), and so on until 150 users. For each ws check, I need to have the right number of users at instant t.
How can I manage this scenario ?