JMeter simplistic nested loop - jmeter

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.

Related

JMeter - Setting the value of a Counter config element programatically in a setup thread

Im using Jmeter 5.5. Im trying to find a way to set the starting value of a counter programmatically. Essentially what i need to do is
Start test
Read an int value from a file <-- setUpThreadGroup
Set the start value of the Counter element to this value.<-- setUpThreadGroup
Iterate through the test/threads, incrementing this as a shared variable. <--Threadgroup
Write the new value to the file. <-- Teardown
I've tried using props.put(),(__P,__setProperty), vars.put, System.setProperty, all with no success.
Is it possible to set the starting value of a counter via code? It always seems to start with 0.
If this isnt possible, is it possible to create a shared variable that can be used across threads that increments safely to ensure no duplicate variable values will ever be used?
I don't think you even need set up and teardown thread groups, you can do something like:
Read the counter from the file via __FileToString() function like:
${__FileToString(counter.txt,,)}
Once all iterations are complete you can write the new value into the file using __StringToFile() function
${__StringToFile(counter.txt,${counter},false,)}
Demo:
More information: How to Use a Counter in a JMeter Test

Incremental variable in each iteration/loop in Jmeter Tests

I have below setup for my test plan:
In POST http request, I am sending a variable myCount set to value 0.
As per above configuration,
this test will run 100 times but everytime the value of myCount is sending 0.
I want it in incremental
for example: for loop 1 value set to 1, for loop 2 value should set 2.
Please let me know how can I achieve this.
Also, I would like to know in Taurus as well.
Thread Group has a pre-defined variable which returns the current iteration number, it's ${__jm__Thread Group__idx}
if you want the counting to start from 1 - go for __intSum() function
There is __counter() function which generates an incremented number each time it's being called
There is Counter configuration element which does the same but you have additional possibility to control the number format, i.e. if you need 0001 instead of just 1 or you plan to re-use the generated variable value later on within the bounds of same request or iteration. More information: How to Use a Counter in a JMeter Test
With regards to Taurus - in case of JMeter executor it supports all the approaches mentioned above

JMETER - How can I pass 2 condition in a while loop on Jmeter

How can I pass 2 condition in a while loop on Jmeter. The conditions are
The request should run in loop till "Pass" response comes.
While loop should run only for 1 minute.
Condition 1 is working fine. However condition 2 is unable to implement.
I have tried running the While Loop inside a Runtime Controller. But the issue is, if the response "Pass" comes before 1 min, the rest of the test stops.
Tried other way round (Runtime inside While Loop) leading to numerous execution of the request, even after receiving "Pass" response.
Will appreciate any leads on this. Thanks
Add a JSR223 Sampler just before the While Controller and store the current time into a JMeter Variable using the following code:
SampleResult.setIgnore()
vars.putObject('whileLoopStart', System.currentTimeMillis())
Use the following __groovy() function as the While Controller's condition:
${__groovy(!vars.get('your_variable').equals('Pass') && ((System.currentTimeMillis() - vars.getObject('whileLoopStart')) < 60000),)}
This way the While Controller will run until:
either your_variable is not equal to Pass
or 60 seconds pass
whatever comes the first
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
This could be another solution.
You can achieve the desired outcome with the following components.
Runtime Controller
If Controller
Flow Control Action
Set the Runtime (duration) in the Runtime Controller
Set the first condition you already have in While Controller in the If Controller
Click the Break Current Loop to exist from the Run Time controller

Loop threw Thread Group with 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.

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