sqeeky
sqeeky

Reputation: 165

Jmeter - Stop All Threads After Specific Duration When Thread Has Loop Controller

My current environment: JMeter v2.11, remote Oracle 12, JDK 7

I have a recorded script for 200 users to login to a web application within 1 thread group but I need to keep this going for several hours so I need to keep the 200 user's sessions live for several hours and if there is no interaction, the http sessions will expire, so I decided to use a Loop Controller to simply resubmit the same http request every 14.5minutes, once the user's session has been established by logging in.

Because I need to stop the script running after a certain duration I specified the Duration on the Thread Group, but I noticed that if the http requests were before the Loop Controller in the script occurred when the Duration value was reached, the script stopped, however - if the http requests that were being exercised when the 'Duration' was reached were in the Loop Controller - the Loop Controller overrode those Duration settings and the script ran until the number of loops had completed.

I found the following posts https://sqa.stackexchange.com/questions/8378/how-to-run-jmeter-test-plan-for-specified-amount-of-time and https://sqa.stackexchange.com/questions/1660/how-to-stop-thread-in-jmeter and followed the instructions to create a second separate Thread Group placing a Test Action with a Constant Timer child which will stop ALL Threads.

Again (as when specifying the 'Duration' via the Thread Group property value) the Stop Test Action works when stopping the script in the other Thread Group if the http requests being executed are not in the Loop Controller - If they are, the Stop Test Action does not work - i.e. the Loop Controller overrides the Stop Test Action's Constant Timer Duration value and runs until the Loop Count has completed.

My Workings below:
Thread Group 1 : No. of Threads-->200, Ramp Up-->1, Loop Count-->Forever, Duration-->900 seconds -HTTP Request Defaults -Recording Controller --HTTP Request (GET) - Login Page Launched --HTTP Request (POST) - Login Details submitted --HTTP Request (POST) - Home Page displayed ---Loop Controller : Loop Count --> 2 ----HTTP Request (POST) - Relaunch Home page -----Constant Timer : Thread Delay --> 870000 ms ----HTTP Request (POST) - Select 'Yes' to View Home Page Again

Thread Group 2 : No. of Threads-->1, Ramp Up-->1, Loop Count-->Forever, Duration-->900 seconds -Test Action: Stop, All Threads --Constant Timer --> 900000 ms

note: I used 15minutes/900 seconds/900000 milliseconds to test my boundaries above.

Can anyone provide any insight into how I can stop the thread running after a certain duration despite the loop controller settings? That is - can anyone describe a way to override the loop controllers settings to stop the thread after a certain Duration, rather than it stopping once the Loop Count has been reached?

Many Thanks!

Upvotes: 0

Views: 4677

Answers (1)

sqeeky
sqeeky

Reputation: 165

I have identified what was causing my problem. The Loop Controller value - it needs to be set 'Forever' so that it doesn't override the 'Duration' settings in either the parent Thread Group or the separate Stop Test Action (with child Constant Timer) Thread Group.

Once the Loop Controller is set 'Forever' it appears JMeter then runs up to the 'Duration' settings.

Thanks

Upvotes: 2

Related Questions