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
Related
I have two thread group Thread group 1 and Thread group 2 in my test plan. Thread Group 1 has 15 users and Thread Group 2 has 20 users. Now I want to run my thread group 2 after threads ( 15 users) of Thread Group has been started.
Is there anyway to run like this.
To achieve this: use following steps:
Add multiple Thread Group in your Test Plan.
In this example, Thread Group - One has 10 Threads and Thread Group - Two has 1 Thread
To start Thread of Thread Group 2 after all the Threads of Thread Group 1, make sure you keep following settings in Thread Group 2
Check Scheduler check box
Start Up Delay should be greater than Ramp up period of previous Thread Group
Make sure to enter duration as well, otherwise you will get the error.
Add If Controller to first Thread Group and use the following __groovy() function as the condition
${__groovy(ctx.getThreadGroup().numberOfActiveThreads() == ctx.getThreadGroup().numberOfThreads,)}
Now you have a "trigger" which fires when all the threads defined in Thread Group are started. Now you can use i.e. Inter-Thread Communication Plugin in order to "tell" the 2nd Thread Group that it's good to go. Check out SynchronizationPluginsExample.jmx for reference implementation.
Add Startup Delay to group 2 which is greater than Ramp-Up Period of group 1
Make sure Test Plan Run Test Group consecutively check-box is un checked
I have 2 thread groups in one test plan in Jmeter. I know how to replay both the thread groups one after the other during a load test i.e., by selecting 'Run the thread group consecutively' option in the test plan.
But I want to do the same in GUI mode for one iteration. I am fixing the second thread group and want to replay that after the first thread group completes. I checked the option but it didn't worked. Is there any other way?
Here is my Test Plan-
enter image description here
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 2 thread groups in jmeter project and when I run it, thread group2 starts paralelly along with threadgroup1. Is there a way I can make threadgroup2 to wait till all the threads in tg1 become active/running state?
Basically in threadgroup1 I am inducing the load and in threadgroup2 I have a thread which is integrated with selenium to capture the actual response time when the load is applied. Currently well before all the threads in tg1 are fired tg2 starts.
I think the easiest option would be to use the Startup delay in the Thread Group 2. delay period would be the rampup period (+ few seconds) of Thread group 1. By this time, JMeter would have started all the threads in the Thread Group 1.
Another approach would be to use to beanshell in the Thread Group 2 to calculate the total active threads of Thread Group 1. (assuming you only have 2 thread groups)
org.apache.jmeter.threads.JMeterContextService.getNumberOfThreads() gives total active threads of the Jmeter test.
ctx.getThreadGroup().numberOfActiveThreads() - gives the active threads in the current thread group.
so,
int grp1_thread_count = org.apache.jmeter.threads.JMeterContextService.getNumberOfThreads() - ctx.getThreadGroup().numberOfActiveThreads();
In the Thread group 2, use an If controller to check for the no of active threads of Thread Group 1 by using the value of grp1_thread_count to send the requests.