I don't clearly understand what is the meaning of a "Thread group" in JMeter. Does that means all the tests (Java requests etc) belong to a certain thread group run in a one thread or each test in that thread group runs in a separate thread? I couldn't get a clear understanding about this from JMeter documentations or googling.
For explanation see:
http://jmeter.apache.org/usermanual/test_plan.html
A thread group is a set of threads executing the same scenario. Set the number of iterations in the configuration.
Thread behaviour is defined according to ramp up and destroyed once the number of iterations per thread has elapsed.
Note that from version 2.8, you will be able to delay thread creation until the time the thread must start working, this will be adapted to tests that use very short lived threads and many threads.
Thread groups can be seen as a set of Virtual Users but not necessarily. It can be something else depending on how you develop your test.
As I understood (What I wanted to know), All the operations in a JMeter thread group run sequentially once per each thread and iteration. So it means each of operations in a thread group does not run in its own separate set of threads, but it shared each thread with the other operations in its thread group.
For example,
Thread Group 1
Operation 1
Operation 2
Operation 3
If we have scheduled this thread group Thread Group 1 to run in 3 threads, what happens is,
Operation 1, Operation 2, and Operation 3 will execute in thread 1.
Operation 1, Operation 2, and Operation 3 will execute in thread 2.
Operation 1, Operation 2, and Operation 3 will execute in thread 3. etc
Previously I was not sure whether each of these operations run on its own separate thread.
Thread = simulated user.
So thread group = users.
Check out jMeter Plugins thread group controllers with far more control than default thread group.
Just to further contribute following my own investigation (for clarity and completeness I hope):
A ThreadGroup has requests/ "operations" as described above (in Manjula Weerasinge's summary) but also has users and loops config.
A ThreadGroup creates a thread per user. This thread (representing a user) runs all operations in that ThreadGroup, in sequence in that loop.
These threads are re-used across all loops - that is: loop 2 will also execute the same set of operations as n different users but this will reuse the same threads as loop 1.
In summary, a ThreadGroup has a thread per user and and it's used to run all tests in that group, for all loops.
This was true across two loops with 10 users where my test contained the following:
System.out.println("MyTest#testSearchNodeByNodeNameExactMatch: MyTest="
+this + "(" +System.identityHashCode(this) +")"
+", thread=" +System.identityHashCode(Thread.currentThread()));
And the logs could be summarised using (assuming println output written to thread-output.2.txt):
grep MyTest#test thread-output.2.txt | awk -F ', ' '{print $2}' | sort | uniq
Related
No.Of Iterations in a thread Group is : 3
Thread Group Name from the below screenshot is : TCByEmployee
Thread Group performs various steps using If Controller
I want to Achieve "Loop Controller-TCbyEmployee-Login by Employees"
& "If Controller-TCbyEmployee-Login by DH" should start Next Iterations once it's completes "If Controller--TCbyEmployee-Login by PA" Iteration 1
Now the issue is : "Loop Controller-TCbyEmployee-Login by Employees"
& "If Controller-TCbyEmployee-Login by DH" continues the up to Iteration 3 before "If Controller--TCbyEmployee-Login by PA" begins
Please see the below screenshots
Your question in its current form doesn't make any sense, you need to either re-phrase it or provide minimal reproducible example
So far I can only inform you that:
Once started each JMeter thread (virtual user) starts executing Samplers upside down (or according to the Logic Controllers)
When thread executes last Sampler in the Thread Group it starts over from the beginning
If there are no more Samplers to execute or loops to iterate the Thread is being shut down.
If you're looking for a way to implement a GOTO statement - take a look at Test Fragments and Module Controller, this way you can change the flow from upside down to some custom
Also be aware that threads (virtual users) are absolutely independent and if you think that the execution order is broken might mean that another user executed another sampler at that moment
And last but not the least, don't run your test in GUI mode
I have 4 thread groups in my test. I have requirement as below:
I want first 3 thread groups to work sequentially. Hence, I have checked the chekcbox "Run Thread groups consecutively". But, i want my fourth thread group to start 30 mins after the third thread group while the third thread group is still not complete. Can this be achieved on Jmeter. Any help on this is highly appreciated.
If you tick Run Thread groups consecutively box you won't be able to have more than 1 thread group running at any moment of time.
So you need to untick that box on test plan level and start all Thread Groups in parallel.
The fact that the thread group has started doesn't necessarily mean that it will start executing Samplers, you can delay the execution until the previous Thread Group is done.
For example you can use Inter-Thread Communication Plugin for this purpose, in 1st thread group and put something into a FIFO queue and then try to read the value using jp#gc - Inter-Thread Communication PreProcessor in the 2nd Thread Group (add it to the first sampler). The 2nd Thread Group will start executing samplers only when the value will be available in the queue.
See SynchronizationExample.jmx test plan for example implementation
The same approach should be applied for thread groups 3 and 4, when 3rd thread group starts - put something to the FIFO queue so 4th thread group would be aware that the 3rd one has started, then you can "sleep" for 30 minutes using Flow Control Action sampler
I want to run a thread x times. The thread group contains three samplers and because I dont want them to be mixed up in the result windows I only want to start the next thread when another is finished. I don't want to use a Ramp-Up Period because a thread could take 1 to 20 seconds.
You could use 3 thread groups and module controller (to referencd in the 2 other thread groups the elements in the first one to avoid copy ) and check on test plan the option:
Run Thread Group sequentially
Your use case is not very clear, however if you need to limit JMeter to X concurrent threads only the most obvious choice would be going for the Concurrency Thread Group
As per Advanced Load Testing Scenarios with JMeter Part 4 - Stepping Thread Group and Concurrency Thread Group article:
The Concurrency Thread Group provides a better simulation of user behaviour because it lets you control the length of your test more easily, and it creates replacement threads in case a thread finishes in the middle of the process.
You can install Concurrency Thread Group as a part of Custom Threads Group bundle using JMeter Plugins Manager
Regarding your three listeners bit, I would recommend reconsidering this approach as per JMeter Best Practices you should not be using any listeners, instead of it you need to run JMeter in non-GUI mode and use -l command-line argument to specify the results file name. Once your test is finished you can open the .jtl results file with a listener of your choice or generate a reporting dashboard from it.
You can use "jp#gc - Ultimate Thread Group". The Ultimate Thread Group provides flexible thread scheduling to your test scenario. It allows us to create a scheduled thread with advanced configuration. Start Threads Count, Initial Delay, Startup Time and Hold Load Time can be defined separately for each record.
You can define tasks to run consecutively.
This platform support flexible thread scheduling. You can read detailed wiki docs about the ultimate thread group.
Link: Loadium.com/wiki/ultimate thread
I want to introduce some delay between two thread groups.
My test plan is-
Thread Group 1 -
a. Thread 1
b. Thread 2
c. Thread 3 (loop controller is added as a parent to thread 3. Loop controller is designed to run Forever)
Thread Group 2
My plan is to start thread group 1 and then start thread group 2 after some delay. Once both thread group have started they should keep on running. I need to introduce a delay between thread group 1 and 2.
I have tried 2 methods below, but they did not serve my purpose.
I selected Run Thread Groups consecutively from test plan, and introduced a test Action Sampler at the end of thread group 1 with
Target: All Threads
Action: Pause
Duration: 5000
and added Synchronizing Timer as a child of the Test Action sampler and set Number of Simultaneous Users to Group by to the number of threads (virtual users) in the Thread Group 1.
Simply added a Constant Timer before start of Thread Group 2.
What is a good solution for this?
Your solution 1 is very good however you need to add a Test Action sampler to the very beginning of the Thread Group 2 as your current setup assumes it running in the end of Thread Group 1 like:
Thread Group 1
Wait 5 seconds
Thread Group 2
Adding a Constant Timer between thread groups is absolutely not something you want to do as given you have the constant timer at the same level as Thread Groups it means the delay will be applied to each and every sampler. You need to move the timer to be a child of the first request of Thread Group 2. Timer will execute before the request which seems to be something you're looking for. See Advanced Load Testing Part 3 - Top 4 Timers article to learn more about timers use cases and best practices
And finally probably the fastest and the easiest solution would be setting a Startup delay for 2nd Thread Group. It can be done under "Scheduler" section:
as per the documentation:
If the scheduler checkbox is selected, one can choose a relative startup delay. JMeter will use this to calculate the Start Time, and ignore the Start Time value.
I have a Thread Group with the following property:
Number of Threads (users): 5
Now, when I run, all 5 threads launch concurrently.
Is there any setting or config element I can use to execute one thread at a time? In other words, I would like to execute Thread 2 only after Thread 1 has completed execution.
I believe the "Run Thread Groups consecutively..." option applies to "Thread Groups" and not to Threads.
1) you can use a Critical Section controller that will ensure only one thread runs at a time( put all your samples as its children)
2) you can play with rampup
3) you can set only one thread, and use loop iteration to 5