If condition is skipped on multiple threads? (JMeter)

Viewed 51

After a long period of time of reading, It's my first post here. :)

My question is the following: Using JMeter, I have to execute 10000 requests, but between every 1000 of them, I should have sleep time (from 0 to 1000 => sleep time => from 1000 to 2000 => sleep time => ...).

I was able to do that using if clause and '__counter(FALSE,)' with pause between every 1000 requests, but it's working only on one thread. If I set >1 threads, it skipping if clause and sleep time is not activated. Far as I know, first parameter of the "counter" function makes it "global" if it is FALSE, but I am confused why the if clause is skipped, if more than 1 thread is used.

I'm checking the counter with groovy func: ${__groovy("${__counter(FALSE,)}" == "1000")}

1 Answers
  1. How do you know that the "sleep time is not activated"?

  2. Your "sleep time" will be "activated" only once when the counter reaches 1000, on 2000 and so on the condition will not be met

  3. Inlining JMeter functions or variables into Groovy scripts is not very recommended, consider switching to __jexl3() function and changing your expression to something like:

    ${__jexl3(${__counter(FALSE,)} % 1000 == 0,)}
    

Demo:

enter image description here

More information: 6 Tips for JMeter If Controller Usage

Related