Running thread groups sequentially in Jmeter - jmeter

I am trying to run a script with two thread groups each for multiple users. script looks like
Test Plan
Thread group 1 (10 users, ramp up period 5 sec and loop count 1)
Samplers
Thread group 2 (10 users, ramp up period 5 sec and loop count 1, thread startup delay 3 sec)
samplers.
both thread groups share some parameters. So I am using Inter thread communication plugin. My requirement is that for first user I want to run thread group1 and then run thread group2 . then start threadgroup1 for second user. Is this possible?

You cannot, an "user" belongs to Thread Group, they don't share any context.
User 1 of Thread Group 1 and user 2 of Thread Group 2 are different beasts.
Normally you should not be passing anything between thread groups, if you need - most probably the test is badly designed and you need to move Samplers under a single Thread Group.
If thread groups "share" some parameters - take a look at User Defined Variables
If thread groups "share" some test steps - take a look at Test Fragments and Module Controller

Related

Need to run threads groups in Jmeter when previous threads group's all threads is started

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

JMeter - Is it possible to run thread groups randomly but only one running at a time

I want to run load tests for 5 different req types with different number of users for each. At a time only one type of request should be hit with its defined no of users. The test should run for 24-48 hrs.
Is this possible to do this in jmeter? I am unable to randomize the thread groups for each request type with only one running at a time.
Thread group 1 runs 10 thread per sec forever
Request 1
Thread group 2 runs 5 thread per sec forever
Request 2
Thread group 3 runs 4 thread per sec forever
Request 3
Thread group 4 runs 2 thread per sec forever
Request 4
Thread group 5 runs 1 thread per sec forever
Request 5
Thread group should run randomly and only one thread group should run at a time.
Please suggest if there is any other way to do this in jmeter.
You can not apply the logical behavior at the "Thread Group" level. That is just not possible. Also, what you need does not seem to fit in the real world scenario unless you extend my knowledge with a valid use case.
Apart from randomizing the thread group you can do everything else mentioned and when you trigger the test all the thread groups will execute.

Introducing a delay between two thread groups in jmeter

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.

how to make jmeter Thread group sleep till all the threads in other thread group are active

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.

RAMP UP in Thread Group of Jmeter

I have issue with setting ramp-up in jmeter.
My test scenario described below.
There are 3 thread groups:
Thread Group1 - 2 Users - Ramp up 10
Thread Group2 - 3 users - Ramp up 15
Thread Group3 - 5 users - Ramp up 25
Problem i'm facing with above scenario is the following.
First user of all the thread groups is kicked off at a same time.
But i don't want like that, i want the following:
In first 10 seconds, 2 users of first thread group should kick off.
After 10 seconds to the test, thread group 2 should kick off their users.
After 25 seconds to the test, third group should kick off their users.
I have seen one option in Jmeter that "Run thread groups consecutively" but if i set that thread group 2 will never start until thread group1 users should complete their requests execution.
jMeter Plugins' Ultimate thread group and Stepping thread group give you far more control over threads.
Add a startup delay to second and third thread group:
http://jmeter.apache.org/usermanual/component_reference.html#Thread_Group
This should do the job.
You can put anything in Start Time and End Time as these will be overriden by startup delay and duration.
Also note:
Start Time If the scheduler checkbox is selected, one can choose an absolute
start time. When you start your test, JMeter will wait until the specified start time
to begin testing. Note : The Startup Delay field over-rides this - see below.
Note particularly:
Note: the Startup Delay field over-rides this - see below.

Resources