NHN
NHN

Reputation: 5

cannot stop Thread Groups and start next Thread when I reached the EOF in jMeter

I have Test Plan that contains Thread Group that is used CSV file. The point is that all data fron CSV file can be done much earlier than the duration for Thread Group would be over, so I try to use a condition to forcerly stop me Thread Group with this CSV file and starting next Thread Group under condition "if I reach EOF". But, for unknown for me reason I couldn't do it, the THread Group is not stopped.

What I've tried:

def file = new File("somedoc.csv")

def numLines = file.readLines()

if (numLines == '' || numLines == null) {
    log.info("Reached end of CSV file. Stopping thread.")
    SampleResult.setStopThread(true)
}

Nothing from this worked and after jMeter reached the EOF -> thread is not stopped, it just print in jmeter.log file something like INFO o.a.j.t.JMeterThread: Stop Thread seen for thread <thread_name>, reason: org.apache.jorphan.util.JMeterStopThreadException: End of file:somedoc.csv detected for CSV DataSet:CSV Data Set Config configured with stopThread:true, recycle:false and continue to activate threads without any requests within this Thread Group.

I'll appreciate any help, thx in advance!

Upvotes: 0

Views: 554

Answers (1)

Dmitri T
Dmitri T

Reputation: 168162

You're stopping the thread (single virtual user) and it sounds like you need to stop the test.

So the JMeter API call you're looking for is most probably:

SampleResult.setStopTest(true)

this way JMeter will "ask" all the threads to stop. If you want to forcesfully terminate the test - use the following command:

SampleResult.setStopTestNow(true)

Put the line of your choice into "Script" area of the JSR223 Sampler and put the JSR223 Sampler under the If Controller.

More information:

Upvotes: 0

Related Questions