Search code examples
jmeterperformance-testingload-testingbeanshell

Jmeter: How to control a http sampler request in a thread group to run only once among 100 threads


I've a thread group to run for 100+ users with-in that there is a need to execute a particular http request only once for all the threads. I know the "Once only Controller" but it execute the child samplers once per thread that is why it doesn't meet the requirement here:

As shown in the image: The "once only controller" run the request E & F only once for every thread where as I my requirement to run the sampler request E & F once only for all the threads A, B, C & D. having said that if i run the 100+ thread request E & F should run only 1 time.

Is there any way to achieve this in jmeter??

Problem ScreenShot:

enter image description here


Solution

  • Put your requests E and F under the If Controller and use the following condition:

    ${__BeanShell(ctx.getThreadNum() == 0 && vars.getIteration() == 1)}
    

    If Controller Example

    Where: