Jmeter run threads sequentially for different loop counts

514 Views Asked by At

I have scenario where I have threads like below

1thread ---2 loops
 --request1(post)
   --json extractor(id)
2thread ---4loops
 --request2
 --request3
3thread ---2loops
 --request4(deleting that created in 1st thread using id extracted)

I have to implement requests as below

request1
request2
request3
request2
request3
request2
request3
request2
request3
request4
request1
request2
request3
request2
request3
request2
request3
request2
request3
request4
2

There are 2 best solutions below

1
On

Your design is overcomplicated, my expectation is that you don't need different Thread Groups as you will have to pass the id between thread groups which is possible, but unnecessary in your case)

Instead of this I would recommend using Loop Controller where you need to make > 1 iteration

Example test plan:

  • Thread Group (with 1 thread and 1 loop)
    • Loop Controller (with 2 loops)
      • Request 1
        • JSON Extractor
      • Loop Controller (with 4 loops)
        • Request 2
        • Request 3
      • Request 4

Demo:

enter image description here

0
On

One thing you can do is to pass the loop count value at the run time to the script by specifying -- ${__P(LoopCount1,2)} in the loop count field.

Use variable ${__P(LoopCount1,2)} for first loop, ${__P(LoopCount2,2)} for second and ${__P(LoopCount3,2)} for third one and try running the script using non gui mode with the help of command like -

jmeter -n -t (location of script) -l location for result file -j location for logfile -JThreadGroup=%ThreadGroup% -JRampUpTime=%RampUpTime% -JLoopCount=%LoopCount1% -JLoopCount=%LoopCount2% -JLoopCount=%LoopCount3%