You want to execute a JMeter performance test but you don’t want to exceed a specific number of requests , is it possible?
Yes it is 🙂
What if we can get the value of the current iteration and make a condition to stop the test when reaching a specific values. This can be done as the following
Create a basic JMeter test plan with the essential samplers and listeners
Test plan will have the following :
- Thread Group
- Http Sampler
- If controller
- Test Action Sampler
- Summary Report Listener

Thread Group run settings will be as the following :

We will put If controller and a test action as a child for it in the beginning of the test just under the Thread Group.

Everytime you call ${__counter(,)} you got the current iteration number.
in the above example we need to set a maximum of 300 requests (iterations).
“${__counter(,)}” >= 301
So why i put the condition operator to be >=301 because in case of concurrency it will be easier to check for number of iteration after you already finished your 300 iterations , give it a try if you put 300 the test will be stopped at the iteration number 299.

When the condition is true the Test Action will stop the test.
Then you have to add http request , in the example we used “https://en.wikipedia.org/wiki/Main_Page”

At the end add summary report to check the number of request and run the test

Summary
With IF Controller and Test Action you can limit your test execution maximum number of requests While you executing a duration based test with multiple threads.
Leave a Reply