Loop threw Thread Group with Jmeter - jmeter

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.

Related

JMeter - In Test Plan that executes consequtive Thread Groups - How to execute particular Thread Group only once

I have a Test Plan, that executes multiple Thread Groups consequtevly - But for one of these Thread Groups I want to be executed once and on next Test Plan exection it should be ommited. Is this possible?
You can implement it as follows:
Put all the requests in your Thread Group under the If Controller and use the following expression as the "Condition"
${__groovy(!new File('somefile').exists(),)}
Add a JSR223 Sampler at the end of your Thread Group and put the following code into "Script" area:
new File('somefile').createNewFile()
If Controller checks for somefile file presence in JMeter's "bin" folder (or whatever is your current working directory) and if there is no file in it - its children will be executed.
JSR223 Sampler creates this somefile when it's being executed so next time you will run your test the condition will not be met and Thread Group will skip all its samplers. If you will need to re-enable the Thread Group - just delete this somefile
Not sure if I fully understood your requirement. If you would like to ignore a specific thread group dynamically , then you could pass the 'number of threads/users' for the thread group to 0 using properties.
more information is here - http://www.testautomationguru.com/jmeter-manage-test-plan/

JMeter simplistic nested loop

I am tryig to implement a simple nested loop in JMeter 3.2.
This solution did not work for me.
You can find my test plan here, I've hosted it on my Dropbox. I tried to keep things really simple. If you don't want to download the test plan, here's what I do :
Thread Group
View result tree
Loop controller (forever)
Counter (Start:0, Increment:1, Maximum:10,Reference Name:loopX, track counter independently for each user: checked)
Loop controller (forever)
Counter (Start:0, Increment:1, Maximum:5,Reference Name:loopY, track counter independently for each user: checked)
Debug Sampler
Now when I take a look at the loops in the Response data tab from the Debug Sampler, I only see loopY varying, from 0 to 5. Obviously I am expecting loopX to vary too, from 0 to 10.
I'd appreciate any help, thanks.
Your first loop controller won't ever "loop" as you have nested Loop Controller in "forever" mode. loopX counter will start incrementing only when second loop controller will exit the loop and with your current configuration it is not achievable.
If you need to increment 2 counters separately you can take a look into __counter() function or add loopX counter to the second loop controller. See How to Use a Counter in a JMeter Test for more information.

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.

Jmeter Inter Thread group communication MxN invocations

I Have a setUp Thread group in which i am creating A resource with unique Id,path it will give me a url to test
In main Test group I have to Test each url created in setupthread group needs to be rigorsly tested.
testplan
In tearDown thread group i need to clear the setupgroup creation .
The problem i am facing is , the property value is getting overridden
Suppose say in SetUpthread group i have created 10 resources then its the last resouce always the mainTest thread group is getting executed
I am looking for a way foreach setupThread group resource the mainTest theadgroup must execute the no of times i specified in the TheadCount and LoopCount
eg: setUpThread group ThreadCount is 10 and Loop count is 10 then i will get 100 different unquie resources would be created then its the mainTest ThreadGroup
100 TC , 100 LC i.e., for each resource its 10000 times gets invoked .
please help me in acheiving this attached pic
You can take a look at http://jmeter-plugins.org/wiki/InterThreadCommunication/ plugin.
This will help in your case. Let me know if this works.
It is hard to suggest anything without having your test plan itself so here is just an approach, I don't guarantee that it'll work, however the idea should be fine.
You need to set up as many properties as many URLs you would like to be hit in the main thread group.
For instance, if you write some URL down in JSR223 Sampler using __counter() function output as postfix like:
This will generate the following properties:
URL_1=http://some.url
URL_2=http://some.other.url
etc.
After that in 2nd Thread Group you can add another JSR223 Sampler to convert JMeter Properties to JMeter Variables like:
Enumeration e = props.propertyNames();
while (e.hasMoreElements()) {
String propertyName = e.nextElement().toString();
if (propertyName.startsWith("URL_")) {
vars.put(propertyName, props.getProperty(propertyName));
}
}
Then you should be able to use ForEach Controller to iterate the variables.
Also make sure you use Groovy as JSR223 PostProcessor and Sampler language

without using only once controller,i want the login request to be executed once

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.

Resources