Jmeter: Parallelly running Thread Group execution gets delayed - jmeter

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.

Related

Jmeter concurrency issue for a Thread of 7 Users

I have 1 thread Group, Within that I have 5 HTTP Request calls. 1st HTTP Request returns a value & that value is used in rest 4 HTTP Requests. The Thread Group Set Up with Number of Thread (Users) : 7 & Ramp-Up period : 5 & Loop Count : infinite. When I run the thread group it breaks due to concurrency.
Example:
When User Thread 1 executes -> Request 1,
Thread 2 executes -> Request 2 (It expects a value from Request 1, Which has not happened for thread 2, Hence it breaks).
Please find the Jmeter SetUp Images below,
Thread
HttpCookieManager
I am new to Jmeter please help me in this.
Each JMeter thread (virtual user) executes Samplers upside down (or according to the Logic Controllers
JMeter Variables are local for the thread (virtual user)
So there is no option that Thread 1 executes Sampler 1 and Thread 2 executes Sampler 2, all users will be executing all Samplers sequentially, it can be checked using __threadNum() function:
So my expectation is that either your extractor fails or Sampler 1 execution by Thread 2 fails somewhere somehow, check the requests and responses using View Results Tree listener, the JMeter Variables using Debug Sampler and jmeter.log file for any suspicious entries.

In jmeter, how can we restrict each thread to read on csv line only?

Objective:
I have csv files with unique data e.g say 200 lines. I want to run endurance test, which executed for duration e.g 10min and avail a unique data from csv.
Setup:
Conisdering this, i did stepping thread setup as below with "shared mode: All threads". And i was expecting each min/60sec, 20 new threads will add and so on till 10min (expecting 200 threads at the end). With Stop thread EOF- True ( want to process data once no dup) and Recycle of EOF= False.
However,API executed in one min only and csv data read by few threads < 20 and done (EOF encounter), though jmeter honoring next 9min without executing my API's.
Expectation : 200 threads will read 200 lines i.e each thread 1 line and occurance of thread will be 20 threads in 60sec. Same like diagram, without doing Stop thread EOF=false. In nutshell, each thread execute once and then stop like kind of stuff.
Any sugeestion, how could i acheive this? Thanks!!
Given your setup each thread will read next line from the CSV file on each iteration
For example:
Thread 1 starts
Thread 1 reads line 1 from CSV
Thread 1 executes 1st sampler, response time is 1 second
Thread 1 executes 2nd sampler, response time is 2 seconds
Thread 1 starts 2nd iteration
Thread 1 reads line 2 from CSV
etc.
So you either need to switch to the Thread Group implementation which has Threads iterations limit setting like Concurrency Thread Group or Arrivals Thread Group or Free-Form Arrivals Thread Group
If you want to continue with your Stepping Thread Group - you need to slow down your threads using Timers

4 thread groups in 1 test plan login time for 100 threads in all thread groups

I have included 4 Thread groups in one test plan and recorded script for all thread groups . As all ALL thread groups contain login script , so can i record time for first request of login from all the thread groups ? and then another 4 users entering system and login again and time is recorded -> this i have to do for 100 threads :::: first 4 users come then other 4 come and perform login .please tell if anyone could solve my issue .
If I got your scenario right you need to go for the following configuration:
Thread Group (Number of Threads: 4, Loop Count: 25)
HTTP Request sampler which performs login
Synchronizing Timer (Number of Simulated Users to Group By: 4)
This way you will have 100 requests in total, there will be 25 "login" loops when 4 virtual users will perform login at exactly the same moment.

How to delay my each thread group in JMeter (without using startup delay)

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

Jmeter: Is it possible to run a particular thread group after all the other thread group gets completed

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.

Resources