0

In a JMeter test plan, I have 4 thread groups which will be executed consecutively, however there is a dependency of certain variables from one thread group to another and hence, in case of any sampler failure in previous thread group, the execution of subsequent thread groups should stop.

Test Plan:

Each thread group is a simple thread group [not setUp or tearDown thread group]

How to control or decide the thread groups execution flow/order in JMeter?

James Z
  • 12,209
  • 10
  • 24
  • 44

2 Answers2

1
  1. The fastest and the easiest way is to stop the test when an error occurs on Thread Group level

    enter image description here

  2. If you want more flexibility you can check whether this HTTP Request B2 was successful or not by using ${JMeterThread.last_sample_ok} pre-defined variable in the If Controller, then you can add Flow Control Action as a child of this If Controller and decide what do you want to do there.

  3. This is pretty much similar to point 2, if your Thread Groups C and D rely on a variable from the Thread Group B you can put all the Samplers under the If Controller

  4. You can set number of threads in Thread Groups C and D using __P() function like ${__P(threads,)} and in case of value you can use __setProperty() function to set this threads property to 0 - thread groups with 0 threads are not being "started"

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
0

You need to pass the status (flag) from the previous thread group(s) to the subsequent thread groups. Status should be evaluated before executing the requests in the subsequent thread groups.

You can pass the values between the thread groups with JMeter properties.

  1. Use props.put('canContinue',true) from the JSR223 element with the status or
  2. Set the property through JMeter function ${__P(canContinue,true)}

In the subsequent thread groups you can check the status with a If controller

${__groovy(!props.get("canContinue"),)}

Add a Flow Control Action sampler to the If Controller and set what you want to do.

enter image description here

Janesh Kodikara
  • 1,670
  • 1
  • 12
  • 23