How to run an JMeter test plan that it should be completed in specified time or it should be terminated within that stipulated time? Please throw me light on this question.
It isn't possible at Test Plan level, but there are following options available:
Duration (seconds)to the desired value for each Thread Group
- Use Test Action timer to stop all the threads (for example create a separate thread group, add Constant Timer which will sleep desired number of seconds, when the timer all threads will be requested to stop
Use Beanshell Sampler anywhere in your script. Relevant Beanshell code to stop the test looks as follows:
SampleResult.setStopTest(true); // to ASK threads to stop SampleResult.setStopTestNow(true); // to TELL threads to stop
Stop doesn't mean that your test plan will end at that moment as threads need some time to gracefully shut down.
In case of forceful termination threads may produce extra errors which will be reflected in test results.
Hope this helps.
You can do this by using JMeter Scheduler: In Thread Group tick the Scheduler and set the value as below:
Start Time and End Time: No need to input. keep them as they are, because they have no significant after entering Duration and Startup delay value. Delay overrides Start Time, and Duration overrides End Time.
For example, if you want to run the test for 2 min. Input the value as below:
Duration (seconds): 120
Startup delay (seconds): 0
Now it's the time to run the test: Run -> Start
At my current project we had configuration build with ant and possibility to set properties for Jmeter. With some of them, we used for controlling duration of script execution:
And here is thread group parameters:
config.test.timeout.min - duration of run in minutes
throughput.freight.offer.permin - load number of users per minute.
Just one more way of configuring the time for Jmeter script.