gatlingscala-gatlinggatling-plugin

Gatling 3.3.1/Scala: answer validation block doesnt grab answer that i need to recieve


try to test a program based on socket.io technology, i try to make sequence of "exec" blocks, which contains "sendText" function and answer validation.

.exec(
ws("write first number")
.sendText("""424["/answer/Session", {"message":"message text"}]""")
  .await(30 seconds)( ws.checkTextMessage("server answer")
     .check(
     regex("""server answer text""")))
)

But gatling doesn't grab the answer according to my parameters. It also ignore code-numbers of outgoing and incoming messages to choose answer. It choose some incoming message which it seems to be matching, then makes a validation according to my parameters and gives an error.

For single thread the problem can be solved with several validations for each incoming message, which seemed to be matching for gatling. like

.exec(
ws("write first number")
.sendText("""424["/answer/Session", {"message":"message text"}]""")
  .await(30 seconds)( ws.checkTextMessage("server question was answered")
    .check(
      regex("""answered""")))
  .await(30 seconds)( ws.checkTextMessage("answer was displayed")
    .check(
      regex(""""data":"message text"""")))
  .await(30 seconds)( ws.checkTextMessage("receive success status")
    .check(
      regex(""""success":true""")))
  .await(30 seconds)( ws.checkTextMessage("server answer")
     .check(
     regex("""server answer text""")))

till i get necessary server answer.

But when i try to increase number of threads at least to 50, multiple checks become a problem. Is there any way to specify more precisely the message for validation?


Solution

  • You have to define a matching criteria to apply the checks on the proper message.