0
votes

Is there a way for all Receive samplers to ignore specific responses in JMeter and wait for the one that we are interested?

To be more precise, we have created a jmx file that contains a large flow like a user would create on the browser. Each request sent is followed by a response, so we use a request handler followed by the corresponding receive handler for each call. And everything seems to work fine. But there are cases that another kind of response may arrive, which is not the one we expect in our flow, but it is triggered by another independent mechanism. You can think of it like notifications sent to the user that is doing the flow and are independent of the flow itself, but theu are received in the channel (for us inside the websocket connection).

So we are trying to find a way to ignore a specific set of responses that may come while we are running the tests.

We firstly tried to add a While Controller in each receive sampler that checks if the content is of the desired type and if not loops again. But this solution has 3 disadvantages :

  1. we have to add the sampler for the specific receive twice - one before the while element and one inside the element because we have to first extract the received data and while does not execute its contents before doing the while condition check
  2. we have so many pairs of send-receive in our jmeter test script , that we have to add so many while controllers inside the script
  3. since the received message may not be of the type we expect but another one that we want to ignore, then we cannot add a Response Assertion because it will fail if the notification arrives, so we have to verify the content indirect -> in the condition of the while loop

We use apache-jmeter-5.3.

So we are wondering if we could do another kind of configuration in order to avoid all these while loops.

It may be irrelevant to the solution, but we use websocket through "WebSocket Samplers by Peter Doornbosch".

Thanks

1

1 Answers

0
votes
  1. You don't have to, just amend your While Controller's condition to accept undefined variable as well

  2. Sounds like a potential use case for using Module Controller to avoid code duplication

  3. If you're getting the response you don't expect you can change the response body using JSR223 PostProcessor to the one you expect, example code

    if (!prev.getResponseDataAsString().contains('foo')) {
        prev.setResponseData('foo', 'UTF-8')
    }