Restart JMeter thread after stopped by error - jmeter

I set JMeter Thread Group Action to be taken after a Sampler error to Stop thread to prevent forwarding of error rate to further steps.
When error occurred in an iteration, thread is stopped, but not restarted in new iteration.
So rest of test is executed with decreased number of threads in this case and I' unable to restart these stopped threads.
Is there a way to restart stopped threads?

You can choose Start Next Thread Loop it will restart thread with new iteration
Start Next Thread Loop - ignore the error, start next loop and continue with the test
In Loop Count define at least 2 iterations so it can restart flow.
If you want it to execute only once fully add Flow Control Action with Stop and Current Thread at the end, so it will execute fully only once
The "Stop" action stops the thread or test after completing any samples that are in progress.

Related

Jmeter Inter thread communicator waits for an item in the queue and never stops even after the test duration is reached. Causing heap space issue

I am using inter thread communicator plugin to share data between two thread groups.
TG-1: generates an ID -> stores it in the queue name Q1
TG-2: picks an ID from queue -> does the processing
After some time when run duration of TG-1 is completed, it stops processing or storing ID in to Q1.
TG-2 processed all the data in the queue and keep on waiting for new data in the Q1. However Q1 will not have any data.
My expectation was when the run duration of TG-2 also completed. TG-2 should finish its job and exit. Why does TG-2 keep on waiting for data in Q1. This is causing the exhaustion of the heap space and test never stops. This is causing a serious issue.
How can we prevent this and any suggestion to add timeouts so that we do not wait for data in queue infinitely.
Thanks
You can add kg.apc.jmeter.functions.FifoTimeout property to your user.properties file and set the value to some reasonable timeout in seconds.
You can add Flow Control Action sampler to the first Thread Group to be the last Sampler there and configure it to stop all threads, the test will end when any virtual user reaches the Flow Control Action Sampler

Jmeter: Ultimate Thread Group - Test finishes before it should

I am using 'Ultimate thread Group' scenarios for each of my 7 scripts/scenarios (each thread group having different number of users). For each of them, i have given the same 1800s as ramp-up and 3600s for steady-state and 90s for ramp-down.
I expect the test to run for about 1.5 hours whereas it finishes in 55min. Any suggestions please?
Thanks,
N
You can check jmeter.log file, it contains the reason for the ending each and every thread.
I can think of the following possible reasons for premature ending the test and none of them is specific to the Ultimate Thread Group:
You have chosen something other than "Continue" or "Start Next Thread Loop" under "Action to be taken after a Sampler error":
You have CSV Data Set Config which is set up to stop thread at the end of the CSV file and you don't have sufficient amount of test data
You're stopping the tread/test somewhere using Flow Control Action sampler
Your test terminates as the result of an OutOfMemory error

Difference between Start Next Thread Loop and Stop Thread in JMeter

There is a Test plan in with set of related requests. If first request fails then I need skip subsequent request as they will anyways fail. How can I achieve this in JMeter.
Test Plan
ThreadGroup(Number of threads:2)
Request1
Request2
Request3
Request4
For example: If Request1 fails due to some error then thread should not execute Request2, Request3, Request4. as Request2,3 & 4 use token from request1 and it will anyways fail if request fails. Can it be achieved using Start Next Thread Loop and Stop Thread. what is the different between these two options
Each JMeter thread (virtual user) you define in the Thread Group executes Samplers upside down.
When there are no more Samplers to execute or loops to iterate - the thread is being shut down. When there are no more running threads - the test will fail.
Start Next Thread Loop - ignore the error, start next loop and continue with the test, so if Request1 fails - JMeter will simply go to the next iteration of the Thread Group and will try to execute Request 1 one more time until it will be successful. The failure will be recorded in the .jtl results file
Stop Thread - current thread exits, it means that the current thread will be shut down and won't execute anything. The failure will be recorded in the .jtl results file
Another option is use If Controller with ${JMeterThread.last_sample_ok} pre-defined variable as the condition, if you design your test plan like this:
the Request2 will only be executed only if Request1 is successful

Jmeter: Stopping a Thread once all other Threads have completed

I have two threads in Jmeter. One the main scripts and the other is handling refreshing the Users Token
This Second one runs every 3 mins and loops forever
The First thread has multi users
this all works great but want to stop the second thread once the first thread has completed the script with all users
Thanks
You can use this element to do that by sending a notification from one thread to the other:
https://jmeter-plugins.org/wiki/InterThreadCommunication/
If you have a possibility to detect the "finish" event from the "main" thread group you can pass it to the "refresh" thread group via __setProperty() function or Inter-Thread Communication Plugin
If you don't have such a possibility you can consider adding an If Controller which will be checking the number of active threads and in case only 1 thread is left it will mean that the test has ended, example __groovy() function you can use as the condition:
${__groovy((org.apache.jmeter.threads.JMeterContextService.getThreadCounts().activeThreads = 1 && vars.getIteration() > 1),)}
Once the condition is met you can use Flow Control Action sampler to stop the current thread:

Finish/interrupt thread in JMeter (conditionally)

I know threads can be stopped by Test Action, but then I cannot see them in View Results Tree if that action was done.
I want to see results of steps before thread was interrupted/finished, Can threads be finished successfully conditionally at specific point?
P.S. workaround would be to put next steps in other if controller with negation to finish condition, however I suspect it would require significant test plan changes.
ADD: version 2.13, in 5.1 there is Break current loop and it works as I need, but I have not moved my test plan to it yet...
Test Action had name replaced to Flow Control Action
You can choose Stop to complete samplers in progress
The "Stop" action stops the thread or test after completing any samples that are in progress.
Also you have options to continue execution, but move to next iteration using
Go to next iteration of Current Loop
Or
Break Current Loop
Or
Start Next Thread Loop

Resources