Firstly I was using the JMeter WebSocket Samplers. here is the order of operations that I needed to accomplish:
So based on the flow, I'm gonna need 2 connections to different endpoints (one is for presenter and the other is for participant).
I needed to make sure the first 4 steps are completed and both presenter and participant connect to the web socket successfully before I start the latency test.
I created 2 thread groups and connected to the endpoints for presenter and participant accordingly. My question is how do I manage to have the requests in the 2 thread groups executed in a specific order? Follow the order, I'd like to execute
I tested it by putting the send request in a 3rd thread group, and then check run thread groups consecutively option in test plan. But the WebSocket single write sampler in the send request was not be able to use the existing connection anymore. (And there were 2 connections out there for presenter and participant)
And I am a little confused about the order of execution with my current setting. Looks like there were being executed randomly. The first 4 requests within participant thread group looks like being executed before any requests in the presenter thread group in the snapshot below, which messed up the data because the highlighted subscribe request in participant thread group was dependent on the session id that will be passed from request (WS-Subscribe-Presenter-/v1/create/session)in the presenter thread group. Due to the wrong order of execution, the session id that was passed to here was actually not the same session id that was created from the presenter request in this round of test run. It was actually still using the session Id that was created in the previous round of test run.
Note: I passed the session ID as a property such that the value can be passed between thread groups.
import groovy.json.JsonSlurper;
def response = prev.getResponseDataAsString();
String[] res = response.split();
def json = new JsonSlurper().parseText(res[res.size() -1]);
vars.put("sessionUUID", json.data.sessionUUID);
props.put("sessionId", vars.get("sessionUUID"));
Add a JSR223 PostProcessor as a child of the last WebSocket Sampler in 1st Thread Group
Put the following code into "Script" area
def connection = sampler.threadLocalCachedConnection
props.put('connection', connection.get())
Add a JSR223 PreProcessor as a child of the first WebSocket Sampler in 2nd Thread Group
Put the following code into "Script" area:
def connection = props.get('connection')
sampler.threadLocalCachedConnection.set(connection)
More information on what do these sampler
and props
mean: Top 8 JMeter Java Classes You Should Be Using with Groovy