Search code examples
jmeterperformance-testingload-testingbeanshellblazemeter

Jmeter: Is it possible to run a particular thread group after all the other thread group gets completed


In JMeter, I have a requirement where I want to run a particular thread group after all the other thread groups complete their run, I know the tearDown thread group has the similar behavior but unfortunately, the logic has to be part of my regular thread.

Let's say there are 4 thread groups A,B,C & D in my test plan and I want the thread group D only to be executed after A, B & C will complete their run.

Can we achieve this without using "setup, teardown & Run groups one at a time" ??

Problem ScreenShot:

enter image description here


Solution

  • I can suggest 2 options:

    1. Use Inter-Thread Communication Plugin. See example test plan for details.
    2. If for some reason you are not in position to use JMeter Plugins you can achieve the same using JMeter Properties like:

      • When Thread Group A finishes set a JMeter Property, i.e. ThreadGroupADone=true using __setProperty() function like

        ${__setProperty(ThreadGroupADone,true,)}
        
      • In Thread Group D:

        • Add While Controller at the beginning of the Thread Group and use the following condition:

          ${__javaScript("${__P(ThreadGroupADone,)}"=="false",)}
          
        • Add Test Action sampler as a child of the While Controller and configure it to pause for a reasonable amount of seconds, i.e. 5 so each 5 seconds While Controller will check ThreadGroupADone property value and if it is still false - sleep for another 5 seconds. When property value will become true - Thread Group D will proceed.