I have a JMeter script with multiple thread groups which are running concurrently. In one thread group PostProcessor
, I would like to check for a condition and stop ALL thread groups, and exit. Basically, I want to stop the entire test.
if (Integer.valueOf(prev.getResponseCode()) >= 400) {
// Stop the entire test in the next line.
}
How can I stop all thread groups at once, in a JMeter Script?
Please see:
JMeter automatically treats HTTP Request samplers with status codes above 400 as failed so you don't have to go for scripting, you can stop the test using If Controller using the following condition:
${__jexl3("${JMeterThread.last_sample_ok}"=="false",)}
and add Flow Control Action sampler as a child of the If Controller
If you want to do this in Groovy - go for one of the following approaches:
prev.setStopTest(true)
- to gracefully "ask" threads to stopprev.setStopTestNow(true)
- to forcefully "tell" threads to stop (you might get extra errors connected with abnormal threads interruption)