I have a workflow that involves saving some data, and then updating it a few seconds later. I've created a CSV file with parameters like so:
ID,Success
1,true
2,false
3,true
4,false
5,true
And so on and so forth. The first HTTP request is to save a new ID:
POST http://server/save
{ id: 1 }
And the second HTTP request updates the ID with the status:
POST http://server/update/
{ id: 1, success: true }
I've created a JMeter test to benchmark this workflow. I created a Thread Group with the following steps:
1. Do save request
2. Wait a random period between 5 and 30 seconds
3. Do update request
I've set my Thread Group to use 2 threads at once as an initial test. However, I've noticed that what happens is actually this:
Thread 1
----------------------------------------------------
| 1. Do save request |
| 2. Wait a random period between 5 and 30 seconds |
| 3. Do an update request |
|--------------------------------------------------|
Thread 2
----------------------------------------------------
| 1. Do save request |
| 2. Wait a random period between 5 and 30 seconds |
| 3. Do an update request |
|--------------------------------------------------|
Problem is, what I'd actually like to do is ensure that there's always 2 simultaneous HTTP requests to the server. In this case, it spawns 2 threads and runs through the ENTIRE workflow as one thread, meaning that I can't guarantee a certain load on the server. What I'd like for it to do instead is this:
Thread 1
-------------------------------------------------------
| |
| HTTP request |
| ********************************************** |
| * 1. Do save request * |
| ********************************************** |
| |
| 2. Wait a random period between 5 and 30 seconds |
| |
| HTTP request |
| ********************************************** |
| * 3. Do update request * |
| ********************************************** |
| |
|-----------------------------------------------------|
Is there a way that I can write my JMeter test such that it will ensure that there are always 2 simultaneous HTTP requests on the server? Also, the update request must happen after the save request, otherwise the ID will not exist.
Here's an image of my JMeter test:
The while controller simply processes every line in the CSV file.