Forum Discussion

M_McDonald's avatar
M_McDonald
Super Contributor
14 years ago

How to terminate a load test but let running threads finish

Hi -

I am attempting to create a Script load test that


  • 1. Will release all running threads at a particular test step at the same time (I have some code that does this.)

  • 2. Will increase the number of threads by 1 after each lock-step iteration of the test up to a preset limit.


I am ramping up the number of threads in the load test script, but when I reach the point that the test should stop I want all running threads to complete rather than stopping immediately. Here is the code I have currently:

int threadCount = loadTestRunner.loadTest.threadCount
int runCount = loadTestRunner.runCount
int maxThreads = context.maxThreads // preset in loadtest setup script
int threadSetSize = context.threadSetSize // controls threads to release simultaneously (starts at one in loadtest setup)

int runTarget = (threadCount * (threadCount + 1))/2 // sum of series 1,2,3...

if (runCount > runTarget) {
if (threadCount >= maxThreads) {
loadTestRunner.cancel("Max threads exceeded")
return threadCount
} else {
context.put("threadSetSize",threadSetSize + 1)
return threadCount + 1
}
} else {
return threadCount
}


Any ideas on how I can let the running threads complete?

Thanks.

- Mike
  • Hi Mike,

    hmm.. could you try using the fail(...) method instead of cancel(...) ? Does that make any difference?

    regards!

    /Ole
    SmartBear Software