简体   繁体   中英

How to run dependent samplers with load distribution in Jmeter

I am looking to run a service mix of 3 APIs with different loads sequentially. Q1 - 20%, Q2 -10%, Q3 - 70% However, Q1 in independent and Q2 is dependent on variable generated in Q3.

I have following setup. I cannot have multiple thread groups and need transaction controllers as I need to upload this to Storm Runner.

ThreadGroup - Threads 10,  Loop 1
 --- Q1ThroughPutController -20%
    ---Q1TransactionController
 --- Q2ThroughPutController - 10%
    ---Q2TransactionController 
 --- Q3ThroughPutController - 70%
    ---Q3TransactionController

Current run looks like this:

Q3 - Fail
Q3 - Fail
Q3 - Fail
Q3 - Fail
Q1 - Fail
Q3 - Fail
Q1 - Pass
Q3 - Pass
Q2 - Pass
Q3 - Pass

According to JMeter Documentation :

Properties are not the same as variables. Variables are local to a thread ; properties are common to all threads, and need to be referenced using the __P or __property function.

Your setup assumes that:

  • 20% of users are executing Q1
  • 10% of users are executing Q2
  • 70% of users are executing Q3

so there is no way for user who ran Q3 to switch to Q1

You need to amend your correlation logic to use properties instead of variables, properties are global so they will be accessible to all threads, you will have to do some custom Groovy scripting using suitableJSR223 Test Elements

Alternative solution would be using Inter-Thread Communication Plugin to pass your variables between different threads and also implement some blocking logic so the virtual user will "wait" for the variable value before proceeding

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM