I have my jmeter test plan like this,
Test Plan
Thread Group1
Thread Group2
Thread Group3
Thread Group4
and my Test Plan Configuration is set to run all thread groups in parallel
Here I want to execute Thread Group1 and then Thread Group2
sequentially and same Thread Group3 and then Thread Group4
But Thread Group1 and Thread Group3 parallel
So is there any way to group together Thread Group1 with Thread Group2 and Thread Group3 with Thread Group4 to run sequentially?
I know this very weird requirement but I have to suffer through it, appreciated your help in advance, thanks.
I see 3 options here:
Use schedule which would allow you to schedule 4 groups in a way that Group 1 and 3 run at the same time, and Groups 2 and 4 are scheduled to run after 1 and 3 complete.
Run them using 2 JMeters: in one JMeter you will have Thread Group1 and Thread Group2, in the other - Thread Group3 and Thread Group4. Each JMeter will be configured to run thread groups sequentially, but both will run in parallel, thus Thread Group1 and Thread Group3 will run in parallel
Change test setup, so that there are 2 thread groups:
Thread group A combines Thread Group1 and Thread Group2
Thread group B combines Thread Group3 and Thread Group4
inside Thread group A and Thread group B you can use Loop controller to achieve specific number of iterations instead of Loop on Thread Group level. I.e.:
Thread Group A
Loop Controller [Count = same count as was used for Thread Group1]
all samplers of Thread Group1
Loop Controller [Count = same count as was used for Thread Group2]
all samplers of Thread Group2
Thread Group B
Loop Controller [Count = same count as was used for Thread Group3]
all samplers of Thread Group3
Loop Controller [Count = same count as was used for Thread Group4]
all samplers of Thread Group4
Related
I'm trying to write a script with two users, 5 second constant time sampler between each request and 3 iterations.
For Users, Thread Group - No of users 2
For iterations, Thread Group - Loop Count 3
For Timer, Thread Group - Constant Timer 5000ms
My Hierarchy is as follows: Test plan
Thread Group
Constant Timer
Logic Controller
Action 1
Action 2
Listener View Result table
Is this approach correct, I'm unable to validate if the sampler request time is 5 seconds from the output.
You can add some extra information to your Sampler label, for example:
${__threadNum} function which returns the number of current virtual user
${__jm__Thread Group__idx} pre-defined variable which returns current Thread Group iteration
So if you modify your samplers labels to look like:
User: ${__threadNum}, Iteration: ${__jm__Thread Group__idx}, Sampler 1
User: ${__threadNum}, Iteration: ${__jm__Thread Group__idx}, Sampler 2
You will be able to see the 5 second intervals between Sampler 1 and Sampler 2 and between iterations.
Here I have 4 Thread Groups present in my Test Plan and I have a requirement, need to run test plan in the time interval of 30 minutes between each of my Thread Group (2nd thread group should start only after 30 minutes, after the completion of 1st thread group and so on).
But cannot estimate the actual duration for all my thread groups. And my Ramp-up period should be 0 for all my thread groups, is there any solution to full fill my requirement ?
Thanks in advance
Add Test Action Sampler to the end of each Thread Group
Configure it as follows:
Target: Current Thread
Action: Pause
Duration: 1800000
Add a Synchronizing Timer as a child of the Test Action sampler and set Number of Simultaneous Users to Group by to be equal to number of threads in the current Thread Group
This way Test Action sampler will act as a "rendezvous point" so all threads in the current Thread Group will sleep for 1800000 milliseconds (1800 seconds == 30 minutes), this way you will get a 30 minutes delay between Thread Groups.
Adding to #Dmitri T answer, Make sure in Test Plan the uncheck Run Thread Groups Consecutively so it won't try to execute in parallel
You can add Critical Section Controller in each Thread Group as the parent of all other components with same name (default is global_lock)
That way no Thread Group will start until previous thread ends.
EDIT
For getting result between threads:
Add to each thread group Generate Summary Results to get the result of each thread
Generates a summary of the test run so far to the log file and/or standard output.
I use like this :
Add "Flow Control Action" steps in Sampler List to the end of the Thread Groups
In JMeter, I have a requirement where I want to run a particular thread group after all the other thread groups complete their run, I know the tearDown thread group has the similar behavior but unfortunately, the logic has to be part of my regular thread.
Let's say there are 4 thread groups A,B,C & D in my test plan and I want the thread group D only to be executed after A, B & C will complete their run.
Can we achieve this without using "setup, teardown & Run groups one at a time" ??
Problem ScreenShot:
I can suggest 2 options:
Use Inter-Thread Communication Plugin. See example test plan for details.
If for some reason you are not in position to use JMeter Plugins you can achieve the same using JMeter Properties like:
When Thread Group A finishes set a JMeter Property, i.e. ThreadGroupADone=true using __setProperty() function like
${__setProperty(ThreadGroupADone,true,)}
In Thread Group D:
Add While Controller at the beginning of the Thread Group and use the following condition:
${__javaScript("${__P(ThreadGroupADone,)}"=="false",)}
Add Test Action sampler as a child of the While Controller and configure it to pause for a reasonable amount of seconds, i.e. 5 so each 5 seconds While Controller will check ThreadGroupADone property value and if it is still false - sleep for another 5 seconds. When property value will become true - Thread Group D will proceed.
This may sound like a duplicate question but its nit, I've searched a lot before putting this here.
I have a single thread group with 10 users and 28 HTTP requests, what I want is something like:
Thread 1 --->rqst 1
Thread 1 --->rqst 2
Thread 1 --->rqst 3
.
.
Thread 2 --->rqst 1
Thread 2 --->rqst 2
Thread 2 --->rqst 3
.
.
Thread n --->rqst n
delay one minute
Start over again.
I tried using constant timer in the thread group but what i got was execution of a single request by all threads every time.
Can anyone please explain how this can be achieved.
There are at least 2 options:
Add Test Action Sampler after all requests and configure it like:
Target: All Threads
Action: Pause
Duration: 60000
Add Constant Timer as a child of rqst 1. Timers are executed before sampler so only one request will be impacted. See A Comprehensive Guide to Using JMeter Timers for more details on timers scope and detailed explanation of each and every Timer.
In both cases delay won't be included into test results
Add a beanshell timer after the last request with something like this
if (${__threadNum} == 10){
Integer WaitTime = Integer.parseInt(vars.get("WaitTime"));
return WaitTime;
}
If the last thread has started add a sleep with milliseconds from the var WaitTime.
Or take a loop at the jp#gc - Stepping Thread Group plugin.
I have 3 Thread Groups: Setup Thread Group, Thread Group 2(which has the http request which does the download of the file), Thread Group 3 under a single Test Plan. The thread count=3 for each. The checkbox 'Run consecutively' is deselected in the Test plan.
The Setup thread group has all the pre-requisite requests which are needed to be executed prior to Thread Group 2 and 3. The Setup Thread Group(having multiple https requests) writes some authentication tokens to 2 different csv files which will then be utilized by the other 2 thread groups respectively when they get executed in parallel at later point of time. So, csv file1 will be used by Thread Group 2 and csv file2 will be used by Thread Group 3.
First, the Setup Thread Group gets executed.Then the Thread Group 2 and Thread Group 3 get executed in parallel. Everything seems fine when all of the threads of Setup Thread Group get the successful response:200.
But when there is any erroneous response like 500 in one of the Setup Thread Group thread Response, the csv files get less number of entries(which is fine); and the Thread Group 2 and Thread Group 3 do not run in parallel. The Thread group 3 runs first. Then after some time gap, the Thread group 2 runs. What's the cause and resolution for this problem?
1) Set Up Thread: Extract the response code or any response message of the Last sampler of the Set Up Thread.
2) Before proceeding Thread group 2 or 3 add some constant time and a BSF pre-processor. validate the condition of the extracted value(either response code/response message).
If the anticipated value is found, proceed with Thread group 2 and 3.
If not Add some constant time within the BSF(define a condition).
3) do the simlar approach, to wait for Thread Group-3 to ensure Thread Group-2 has ran succesfully.