Search code examples
testingautomationjmeterperformance-testingjmeter-5.0

JMeter , Execution order is not correct


I have 4 transaction controllers named

Trans_api1
__Http Request
Trans_api2
__Http Request
Trans_api3
__Http Request
Trans_api4
__Http Request

that contain Http Requests, However when I run my test plan, I want them to run in numerical order but then they run randomly. How do I fix the order to it runs from 1-4?


Solution

  • Each JMeter thread (virtual user) runs Samplers upside down so you don't need to do anything, your requests are executed from top to bottom already. If you run your test with 1 user - you will see that requests are being executed sequentially.

    If you're seeing some "mess" most probably it's caused by concurrency, like

    1. 1st user starts 1st request
    2. 2st user starts 2nd request
    3. 2nd user starts 1st request
    4. 1st user starts 3rd request
    5. etc.

    You can see this yourself if you add ${__threadNum} function as the prefix or postfix for your request (or transaction controller) label and eventually ${__groovy(vars.getIteration(),)} function to display the current loop number

    With 1 user:

    enter image description here

    With 2 users:

    enter image description here

    With 2 users and 2 iterations:

    enter image description here

    As it evidenced by the above images each users executes samplers sequentially on each iteration, these "inconsistencies" are misleadingly interpreted due to concurrency

    See Apache JMeter Functions - An Introduction article to get familiarized with JMeter Functions concept