I met a problem when using Stepping Thread Group in jmeter that a request is sent many times.
For example:
I have 1 csv that contains 100 users and passwords for login system.
I want to test with 10 concurrent users using Stepping Thread Group in jmeter.
I setup the params as piture.
Stepping Thread Group setup
And observe result that login request sent many times and the number of loged-in users is more than 10.
Please help me to fix this.
Thanks
Updated question:
Besides, I want to execute scenario like this.
1. login
2. do stuff 01
3. do stuff 02
4. logout
Constrain 01 - During a user execute step 3, all others must wait and donot execute step 2 until user finishes step 3.
Constrain 02 - When step 3 finished, only 1 user execute step 2, others wait again.
is there any controller help this scenario?
I can setup a while controller for solving Constrain 01. But for contrain 02, I donot found any solution yet.
If you want to execute request(s) only 10 times - just put them under Throughput Controller and configure it like:
Also be aware that as of now Stepping Thread Group is deprecated and users are encouraged to go for Concurrency Thread Group instead. See Advanced Load Testing Scenarios with JMeter Part 4 - Stepping Thread Group and Concurrency Thread Group to learn more about things in common and what is different.
Related
I am running one scenario for 2 hours in which I am using service which generates the cookie.. and that cookie is getting expired after 30 minutes.
So I want to create a thread group which will run after 30 minutes so that new cookie will get replace with old cookies.
You can setup another thread group with a 30min startup delay.
Add a constant timer with 30min to ensure the delay after the first execution.
Best approach could be to check the expiry with a If Controller and add the requests within the if controller.
To make this simple
Create a thread group with number of threads as 1 with ramp up as 1 second.
Create a loop controller and add loop count as 4.
Create your request under this loop controller and also add constant timer as child of your request as shown below :
Execution flow will be:
First request will get executed . Once this first request gets a response from the server, it will wait for 30 mins. Then this loops again 4 times. You can control the number of execution in the loop count.
The options are in:
Just specify "Startup delay" for the Thread Group:
Add Flow Control Action sampler as the first sampler in the Thread Group and configure it to pause for the half and hour:
Use custom thread group like Ultimate Thread Group (can be installed as a part of Custom Thread Groups bundle using JMeter Plugins Manager) where you can precisely define when and how to start threads:
The stress test plan contains 5 threads, see below.
Lets consider a food booking app :
Thread 0 contains the prerequisites such as extracting the token which will be used by the remaining threads (1,2,3,4).
Thread 1 relates to the food menu.
Thread 2 relates to adding items to the menu and calculating the order price.
Thread 3 creates the order.
Thread 4 confirms the order.
Each thread requires the previous thread to be executed as it uses the response from the previous thread and I have been asked to run Thread 1,2,3,4 concurrently, but the fact is they cannot be run concurrently as
Thread 3 cannot be executed without actually executing Thread 2 and so on.
7.
Let me add a real-world use case:
A user is viewing the menu items
Concurrently, another user is confirming the order
Another user is adding items to the cart
Actually, all the operations are taking place concurrently, but no operation can be performed by skipping the previous threads.
How do I make changes to my script to accommodate such type of parallel stress testing?
Had to re-read your question a few times... I think what you are asking is can you run multiple "Thread Groups" ... the answer is yes, in your test plan you right-click and add multiple Thread Groups, each thread Group has its own user journey scripted.
As for dependencies between Thread Groups there are options for sharing variables. but you would likely need to work out your logic and write a little bit of groovy to ensure that the data flows correctly.
You could also look at "How to Use the Inter-Thread Communication Plugin in JMeter" on the BlazeMeter website: https://www.blazemeter.com/blog/how-to-use-the-inter-thread-communication-plugin-in-jmeter
Update: After Christian's formatting of the question, it appears that "threads 0-4" are describing a user journey. for example; user logs in, clicks menu, adds item x, goes to checkout etc.
This would be recorded in one Thread Group. Each call made would provide a server response that could then be parameterised and correlated, ensuring data is passed appropriately. The "concurrency" would come from ramping up multiple users "Threads".
For example; here in this screenshot, I have added a Thread Group that has 4 HTTP Samplers (the user journey). The Thread Group is then set to run 10 users, ramping up in 5 minutes (300 seconds), and runs for a duration of 3600 seconds (aka 1 hour).
I have a thread group that is running non-stop in a VM to simulate user behavior. However I need to stop it after 6 days, since the user token expires (after 6 days) and make the user login again. My thread sequence is as follows-
1. Login (extracts session token and use it in subsequent calls)
2. HTTP req 1
3. Loop controller
a. http req 2
b. http req 3...
Is there a way or script that I can use to auto-stop the thread group after 6 days and auto-restart it again?
The Scheduler on thread group just stops it after a certain time, but I need to auto-restart the thread group again.
If you just need to run JMeter test for 6 days, then restart it you can configure your Thread Group to run for 6 days
and schedule the test execution using your operating system task scheduling mechanisms like crontab for Unix and derivatives or Windows Task Scheduler. One more option is putting your JMeter test under orchestration of a Continuous Integration server like Jenkins
If for some reason the above options are not suitable, i.e. you don't have permissions to install 3rd-party software or add a scheduled tasks on OS level what's the problem in putting the Login (extracts session token and use it in subsequent calls) into a separate Thread Group and use Constant Timer or Flow Control Action Sampler in order to make this Login to fire once per 6 days? The token and stuff can be passed to the "main" Thread Group via __setProperty() function or Inter-Thread Communication Plugin
You could modify your original Test Plan structure in one of the following ways:
1. Login
2. HTTP req 1
3. While Controller
a. http req 2
b. http req 3...
The While Controller could run for 6 days after which the outer Thread Group would loop around for another login.
The While condition would have to compare the time difference between the current time and TESTSTART.MS (see https://jmeter.apache.org/usermanual/functions.html#predefinedprops) and take into account the number of previous logins i.e. number of Thread Group iterations (e.g. __jm__Thread Group__idx).
1. If Controller
a. Login
b. HTTP req 1
2. http req 2
3. http req 3...
Alternatively, an If Controller could run only once every 6 days with a condition similar to the above.
I have scenario where I want to run load test for 250 users.
Ramp up time is 10 mins for 250 users and run test for 50 min duration.
Question 1 : Is it recommended to do login and login out as part of set and tear down .. as the dev team does not measure login and log out .?
Question 2 : How do i keep the the other thread group in loops during the 50 min duration . ?
I wouldn't go for it as normally different thread groups should represent the different groups of virtual users, setUp thread group is for accomplishing the pre-conditions for the test and tearDown thread group is for cleaning everything up. If you perform the login in the setup thread group - there will be negative consequences like having to pass login context (tokens, headers, cache, etc.) to other thread groups. So I would rather move login to be the integral part of the main thread group and if needed remove login/logout via Filter Results Tool (not part of vanilla JMeter, can be installed using JMeter Plugins Manager)
It can be done on either on Thread Group level like this:
or you can "loop" the arbitrary part of the test by putting it under the Runtime Controller:
I have a requirement in JMeter, while executing several recorded HTTP Request (placed inside Transaction Controller) in Thread Group, They should start its execution from one by one ie) Controller 1, Controller 2, ... & Final Controller.
But when I gave 100 threads it start execute, Controller 1 for 100 times then Controller 2 for 100 times and it continues the same till last controller.
From the above shown image you can verify my results. And I need to know, how can I prioritize my controllers when I gave multiple thread counts. My exact output for 100 threads should be like as mentioned below,
1. Controller 1, 2, and till final controller should run as 1st thread count
2. Controller 1, 2, and till final controller should run as 2nd thread count
3. Same like it should continue till the 100th thread count
Please let me know how this requirement is possible in JMeter 4.0
Thanks in advance
This is default JMeter behaviour, JMeter threads (virtual users) are absolutely independent so:
When you start your test with 1 user it starts executing Samplers upside down, one by one
When you start your test with 100 users - all 100 users start executing samplers upside down. And given you have 100 concurrent users it might be the case that first sampler is being executed by multiple users at once.
Normally this is what the majority of people require. If you got the requirement to run all requests by 1st user followed by all request by 2nd user and having 100 users in parallel - suggest the person, who gave you this requirement to quit IT and become a lawnmower as the requirement doesn't make sense and is contradictory.
You can still achieve it using Concurrency Thread Group configured like:
Which will give you what you're looking for:
You can install Concurrency Thread Group using JMeter Plugins Manager.