How to execute requests sequentially running multiple JMeter Threads - jmeter

I have a single thread group which has 3 requests and have set the Number of Threads(users) = 2.
I would like all the requests to be executed in sequential order for each user before it repeats these steps for the next user and so on.
Output expected:
HTTP Request 1_Thread 1
HTTP Request 2_Thread 1
HTTP Request 3_Thread 1
HTTP Request 1_Thread 2
HTTP Request 2_Thread 2
HTTP Request 3_Thread 2
However, the output results vary differently for each run and are not in the order I expect. How can this be corrected?
I have tried following but with no luck in achieving my output
1. Enable/disable "Run Thread Groups consecutively
2. Running the test in non-GUI mode
I have attached a screenshot as an image as I am not able to embed into this message yet.
Appreciate if anyone can help me with this query
Thanks
Output Screenshot

For execution of Sampler Request by only Single Thread at a time use Critical Section Controller.
For more info about Critical Section Controller Critical Section Controller
The Critical Section Controller ensures that its children elements (samplers/controllers, etc.) will be executed by only one thread as a named lock will be taken before executing children of controller.
Critical Section Controller takes locks only within one JVM, so if using Distributed testing ensure your use case does not rely on all threads of all JVMs blocking.
Practical Example:
Place all your request under Critical Section Controller
Run the test for any number of Threads you want
Observe the Result in View Results Tree
Note : If you want to run it sequentially from 1 thread to N, make sure you provide Ramp Up Period properly.

Related

java.lang.RuntimeException: Attempting to reset the thread name -> Jmeter Error while execution

When I execute my jmeter script with below mentioned scenario then I get java.lang.RuntimeException in the logs and 2nd iteration/loop count APIs are not executed.
As you can see only for 1 thread APIs are visible in view result tree.
In this you can see that no APIs are executed for 2nd thread.
Runtime exception is coming.
Thread Properties
Number of threads : 1
Ramp-up period : 1
Loop Count : 2
Thread Group Used : Normal Thread Group
Controller Used : Parallel
Data is parameterized using 1 csv file only.
I also used "Transaction Controller" to verify but in that I didn't faced any issues and the threads were executing for the mentioned loop count. Is it normal in case of parallel controllers?
As per "Limitations" chapter of the Parallel Controller documentation
Parallel Controller does not support work with Transaction Controller so if used you can get an unexpected results. If you decide to use these controllers together familiarize yourself with already known problems that described in roadmap
So my expectation is that you need to remove either Transaction or Parallel controller from your test plan.
Parallel Controller is for "exotic" scenarios like handling AJAX requests when a single JMeter's thread (virtual user) kicks off one or more sub-threads
If in the reality your "Scan_API" requests are sequential - you need to remove the Transaction Controller and implement concurrency on Thread Group level
If in the reality all the "Scan_API" requests are executed at the same moment, i.e. when one user "scans" something 13 concurrent requests are fired - then you need to remove the Transaction Controller because you don't really need it, the total execution time of the "scan" would be the time of the longest request so Parallel Controller in "parent sampler" mode will return you the slowest request execution time and that would be the value you're looking for.
More information: How to Use the Parallel Controller in JMeter

How to chain HTTP request requests in Jmeter Simple Controller?

I have multiple Simple Controllers under Thread group. All controllers have 1 HTTP request. Only one controller have 3 requests. How can I chain 3 requests in one simple controller to run sequentially.
Test Plan
The screenshot above is my test plan. In v4/bootstrap call I have 3 HTTP requests. Result of these 3 requests is token which I extract from get_v4/restart and then this token used for all other requests. For correct token generation 3 requests from v4/bootstrap call should run sequently. On summary report shown that amount of run 3 requests is different.
Each JMeter thread (virtual user) executes Samplers upside down. The same applies to Simple Controllers.
So you don't need to do literally anything, each thread will execute samplers sequentially as they appear in the Test Plan.
If you have more than 1 virtual user in the Thread Group you might be confused by the "wrong" order of sample results:
However each user is still executing samplers upside down, you can check it by adding __threadNum() function to show the current virtual user's number and __groovy() function calling vars.getIteration() method
You will see that each user executes samplers sequentially and starts over when the last sampler ends and there are iterations still:

How to execute multiple parallel controllers simultaneously?

I am having 2 parallel controllers in my thread group, in both parallel controllers I have added 1 simple controller in which there are 10 API requests. When I execute the script with 2 threads and 2 sec ramp up time to check the start time of the thread groups then I observe that script completes 1 thread's parallel controller first then 2nd thread's parallel controller.
Scenario - To scan the barcodes from csv file.
Expected Result: Expected_Result_table_ss
and in the meanwhile when Parallel 2 is processing the barcode, the first controller should also pick the next barcode to scan. For ex when the 2nd parallel controller is scanning 110121 at 12:00:01:190 at the same second or after some milliseconds parallel controller 1 should pick next barcode 110123 to scan.
Actual Result: ActualResult_TABLE_ss
Jmeter Script Flow : Jmeter_Script_Flow_ss
I may be wrong but I think this execution will be more precise if I am able to execute these parallel controllers simultaneously. Please let me know if any other logic can be applied for the same to scan the barcodes simultaneously using script
Parallel Controller executes its direct children in parallel, your "Jmeter Script Flow" means sequential execution of all "API requests" by each thread (virtual user)
I don't think you understand the concept and use case for the Parallel Controller, it was implemented as a JMeter Plugin to overcome JMeter limitation of not being possible to kick off extra threads within the bounds of one virtual user making simulating AJAX calls quite hard. If scanning the barcode really produces 10 requests at exactly the same moment then your setup is good and you just need to move the "API requests" out of the "Simple Controller" so they would be direct children of the
JMeter threads are absolutely independent and know nothing about each other unless you use Inter-Thread Communication Plugin so each virtual user will be executing Samplers upside down as fast as it can
If you want to execute both scenarios at the same time with 2 users - take a look at Synchronizing Timer

Performing many tests in 1 test plan

I need to perform tests on hundreds of HTTP links one after the other.
That means i want to, for instance, perform a 3 minute test with 5 users on 1 link and after that's done, do the same for the next link.
1 way to do this is to create a ThreadGroups for each link, each having a HTTPsampler and just have all of the run consecutively. But i read that that would create memory problems for the testing machine.
So what is the correct way of doing this? I really don't feel like creating and manualy running a separate TestPlan for every link.
You can use only one HTTP Request sampler, the suggested Test Plan structure:
Thread Group with the number of threads (virtual users) you want to simulate
CSV Data Set Config containing the list of URLs
Runtime Controller configured to last 180 seconds
HTTP Request sampler configured to hit the URL:
This way you will hit 1st URL for 180 seconds then 2nd URL for 180 seconds, etc.
For the problem you have mentioned you can create single test plan instead of multiple test plans and add multiple thread groups inside it and make sure that run thread consecutively is checked.
In each thread group mention the thread count and test duration as mentioned in the example below.

How to enforce run Once Only Controller in Jmeter

I'm a newcomer to Jmeter and want to be able to run some setup requests once only, in which some variables are setup, before I then run a set of further requests for as many users as I set in the Number of Users Thread Group. These users are passed the variables created in the Once Only Controller.
I've inherited a script as follows, using a Once Only Controller:
If I set the Number of Threads as 10 to ramp up to 10 in one second and run for one minute, I expect the number of Samples (requests) made in the Once Only Controller to show as 1. I only want these requests to run once then subsequent requests to use the setup data.
Why then, when I run, do I see the samples as 10 in the requests that are set in the Once Only Controller:
Bear in mind there may be some fundamental misunderstandings given my I'm a newcomer to Jmeter.
I found the setUp Thread Group Controller which seems to be what I need. However, this does not seem to pass variables extracted using the JSON extractor into the next Thread Group 'Load Test'
Thanks
Use Once Only Controller for running specific samplers for every thread
The Once Only Logic Controller tells JMeter to process the controller(s) inside it only once per Thread
You can add samplers to setUp Thread Group so it'll be executed once before test
execute before the test proceeds to the executing of regular Thread Groups.
Note keep its default (especially Number of Threads = 1)
As per Once Only Controller documentation:
The Once Only Logic Controller tells JMeter to process the controller(s) inside it only once per Thread, and pass over any requests under it during further iterations through the test plan.
So each your Thread will execute Once Only Controller's children only once, no matter how many loops your thread group will have.
As you have 10 threads each of 10 threads will execute the requests once.
If you want to execute the request by only one thread, no matter how many requests are in the Thread Group - I would recommend going for If Controller instead
Substitute Once Only Controller with an If Controller
Use the following condition:
${__groovy(ctx.getThreadNum() == 0 && vars.getIteration() == 1,)}

Resources