For my scenario I want to combine few samples into one to show output as login ( instead of showing all 4,5 samples involved in login). My test plan has Onceonly controllers for login and logout users. Once the users are logged in, we want to loop through different data (iterations) Once all the iterations are done users should logout.
My overall testplan is like this.
Testplan
--ThreadGroup
OnlyOnceController
--LoginTransactionController
LoginSample1
LoginSample2
LoginSample3
Loop Controller
--Action1transactionController
Action1sample1
Action1sample2
Action1sample3
--Action2transactionController
Action2sample1
Action2sample2
--Action3trasactitonController
Action3sample1
Action3sample2
OnlyOnceController
--LogoutTransactionController
Logoutsample1
logoutsample2
I used transactioncontrollers inside loop controller.
When I trigger run with say 30 users (threadcount) and loop count =10, then in view result tree I am noticing that that all users finish one transaction controller and then move to other transaction controller together and then going to next loop.Is this because I used transaction controllers inside a loop controller?
But I want once the user login it should move on to next next samples without waiting for others. Is it right way to use transaction controller for my requirement?
Is there any other way to achieve this?
LoginTransactionController
LoginTransactionController
LoginTransactionController
.
.
Action1transactionController
Action1transactionController
Action1transactionController
.
.
.
30times
Action2transactionController
Action2transactionController
Action2transactionController
.
.
.
30times
Action3trasactitonController
Action3trasactitonController
Action3trasactitonController
.
.
.
30times
Then it is going to second iteration.
JMeter threads (virtual users) are absolutely independent, a virtual user will not "wait" for the others (unless you use Inter-Thread Communication Plugin)
JMeter virtual users execute Samplers upside down as fast as they can. Transaction Controller is nothing more than a "virtual sampler" which simply sums the response time of its children, it doesn't have any impact on the execution order
You can temporarily add a __threadNum() function and ${__jm__Loop Controller__idx} pre-defined variable, this way you will see which virtual user is doing at every moment of your test
Related
My requirement is as below:
I have 5 different URLs and I have to ramp up 5 users, with each new user added every second. However, when every new virtual user gets added, the previous user should also hit their URL again. Something like below:
Ramp-up 5s:
Loop 1: sec1.
VU1 URL1
Loop 2: sec2.
VU1 URL1
VU2 URL2.
Loop 3: sec3.
VU1 URL1.
VU2 URL2.
VU3 URL3 and so on.
How to achieve it in JMeter? Is there some other tool where we can achieve this?
The easiest way is to put the URLs into a text file, each on a new line and use __groovy() function to read the line from file equal to the number of the current thread (virtual user), something like:
${__groovy(new File('urls.txt').readLines().get(ctx.getThreadNum()),)}
Demo:
More information on JMeter Functions concept: Apache JMeter Functions - An Introduction
There are SaaS platforms online that do just that, eg https://rungutan.com
i want to control my sampler execution by using a random variable . I have a sequence of hits login,welcome,Bla,log out . i want the log out to be performed for 6/10 requests and let others do not login(so to speak 6 requests will perform the whole sequence including log out, 4 of them will perform will not perform log out ).How to achieve the same in JMETER
I have added a random variable rand and set it between 1-10 at the beginning of the thread group .Then just above Logout sampler i placed an IF controller were i check ${rand}>4 . How ever i always get all sequence executed . Please suggest what am i doing wrong
Your approach is a little bit weird, my expectation is that the problem is in the following areas:
Your IF Controller condition is wrong (check jmeter.log file for any suspicious entries)
Your random variable setting is wrong, i.e. it has the same value for all virtual users (threads) so they will either be executed all or none
So I would recommend using Throughput Controller or Switch Controller in order to set up this 60/40 distribution.
See Running JMeter Samplers with Defined Percentage Probability article for more details.
Random Variable in Jmeter is saved in long format be default so
${rand} > 4 won't work. You need to change
Condition to ${rand} > 4.0
or change Random Variable Output format to 00 (2 digits)
see Manual
This was accomplished by creating a combination of config element- random variable and an IF controller
1) a random variable was created with Minim and maxim value to meet above condition
2) and IF controller was able to check ${myrand}>4;
This had derived the desired result - thank you all
I got a thread group of 10 users. I want to to connect these 10 users to an URL path mysite.com/1.
Then I want to loop a second time on these thread group and connect them to mysite.com/2.
And I need to repeat this process 10 times (i.e until mysite.com/10)...
I there a simple way of achieving that? I've already tried to use counter but what it does is connecting user1 to /1, user2 to /2 and so on...
Add While Controller to your Thread Group and put the following expression to the "Condition" area:
${__javaScript(${counter} < 11,)}
Add Counter test element as a child of the While Controller and configure it as follows:
In your HTTP Request sampler refer the incrementing value as ${counter} where required.
See How to Use a Counter in a JMeter Test to learn how to properly generate incrementing values in JMeter tests.
I have a JMeter Test Plan with following structure
Test Plan
**ThreadGroup1**
--CSV Data Config-001
----SimpleController
--------------LoginRequest
--------------Action-abc-Request
**ThreadGroup2**
--CSV Data Config-002
----SimpleController
--------------LoginRequest
--------------Action-xyz-Request
I have two CSV files which contain list of users like this..
**CSV-001**
Username1
Username2
.. ..
Username50
**CSV-002**
Username51
Username52
.. ..
Username100
In my scenario, I need to run a load test with say 100 users. 50 users login from ThreadGroup1 and other 50 users login from ThreadGroup2. Users from both threadgroups login simultaneously.
Currently, I have to go through process of manually creating/editing these CSV files whenever I change the number of total users.
Please suggest if there are any alternative time-saving & performance-efficient approaches through I which can fulfill my scenario requirements (without using CSV files).
I will appreciate, if you can explain the alternative solution with some details as I am quite new to JMeter stuff. Thanks.
Another idea is to use
Username${__threadNum}
for the first thread group and
Username${__BeanShell(ctx.getThreadNum()+Z+1)}
for the second, where Z equals the total number of threads in thread group 1. You also need to add 1 since ctx.getThreadNum() returns a thread number using a 0 based index, whereas the __threadNum function is 1 based.
You can use a counter in each thread. The start value for the counter in the first thread would be 1, in the second 51. Be sure the 'Track counter independently for each user' check box is unchecked.
If you set the reference names to thread1Count and thread2Count respectively, you can use
Username${thread1Count}
for the first thread and
Username${thread2Count}
for the second.
I am trying to do the load testing of the pages which can be access after login only.
As I am using Once Only Controller for login request ,when I changed Number of thread- 5 or more,login executes 5 times.
as Once Only Controller works for loopcount so I used loopcount but it slowdown my process and it executes the whole testplan.
My test-plan is:
login thread A- one time execution - how to do it?
http request B- multiple times(by using Number of threads)
http request C- multiple times(by using Number of threads)
What should I use for one time login execution and other successor requests needs to be executed multiple times without using Once Only Controller?
Kindly follow these steps:-
In Thread Group put number of threads:5 , Ramp-up:0 , Loop count: 1
Put your Login part in Once only controller
Right click on Your thread group > add > logic controller > loop controller
Now put your http request part in loop controller and set loop count of loop controller how many times you want to run
Then run the test you will get whatever you want
The Loop count in "Thread Group" is your full script Loop count not for your Transactions, for your transactions you have to put separate loop count before transaction starts.
Please do below
Your thread group setting should be below:
A.Number of threads :1
B:Ramp up period : 0 or as per application response.
C:Loop Count :5
Put your login request under Only once controller.
Request B and Request C should be at thread group Level.ie one step above it.
Run the request.
please find Sample Jmxsample Jmx for your reference Plse try. Hope it resolves your issue.