I need to iterate a request multiple times in JMeter for different users. The iteration number differs for each users. For example: I need to iterate a request 5 times for first user, 3 times for second user and only 1 time for 3rd user and so on. How can we do this and how the input can be fed to the same. Is it possible to say read first 5 line for first user and next 3 lines for second user in csv data set config.
You can define the desired loops count for each user in the CSV file or via JMeter Properties
You can read the desired line from the CSV file using __groovy() function like:
${__groovy(new File('test.csv').readLines().get(0),)} - read 1st line
${__groovy(new File('test.csv').readLines().get(1),)} - read 2nd line
etc.
Here is a solution for your problem. There could be many other solutions available in JMeter.
You can define the loop count associated with the users (threads) in a (User Parameters)enter link description here Pre-processor.
This panel allows you to specify a series of values for any User Variable. For each thread, the variable will be assigned one of the values from the series in sequence. If there are more threads than values, the values get re-used.
Then the requests can be placed within a Loop Controller
The User Parameters component shall be placed within a JSR223 Sampler to ensure the values are initiated before the loop controller is reached. Also the JSR223 Sampler shall be placed within a Once Only Controller to ensure the Sampler is executed only once.
Add SampleResult.setIgnore() in the JSR223 Sampler to avoid the sampler getting recorded into the test results.
Test plan structure
CSV Data Set Config more suitable for large numbers of parameters
Related
I am currently using JMeter 5.5 and I have the below data set stored in a .csv file
BatchId
DocID_Start
DocID_End
1
1
93
2
94
1266
...
...
...
7
25313
45700
Each BatchID has 'n' number of Document ID ranging between DocID_Start and DocID_End.
I am trying to create a sampler that sends a POST Drop loop Call to the API ${url}/drop?documentIds=${DocID}
where DocID is any number between the DocID_Start and DocID_End.
I Created a the following testplan
GET Batch is working as expected and it is looping through each of the BatchID within the CSV file one by one but I could not get POST Drop Loop to go through the CSV and grab a different DocID_Start value. It will just keep reusing the first line for every user.
I've tried using Loop Counter and ticked off different checkboxes but i couldn't get it to work
With the default Sharing Mode of All threads CSV Data Set Config reads the next line from the CSV file on each iteration of each virtual user.
If you want to get a random number between DocID_Start and DocID_End - go for __Random() function:
${__Random(${DocID_Start},${DocID_End},)}
you can call this function as many times as you want under the Loop Controller.
If I misunderstood your question and you want to proceed to the next "Batch" under the Loop Controller - you need to move your CSV Data Set Config inside the Loop Controller as currently it proceeds to the next line on the new iteration of the Thread Group. JMeter Scoping Rules documentation chapter can shed some light on this.
I would like to be able to extract the first 5 characters from the element in the array in Logic App. I am able to generate the list (below image) but I need only first 5 characters not the whole name
and here is the result
Thank you :)
Using substring function you can extract first five characters of the file name. I have reproduced issue from my side and below are steps I followed,
Created logic app as shown below,
Taken http trigger and then initialized a variable of type array.
Next listing Azure blobs in storage account.
In foreach loop, iterating over list of blobs and then appending display name of blob to array variable. Here using substring function to take first 5 characters of file name with expression,
substring(items('For_each')?['DisplayName'],0,5)
Creating blob with using content as array variable output.
File names in storage account displayed as shown below,
Logic app ran successfully and blob created in storage account as shown below,
I have a scenario where a Logic App will be scheduled to run at 11 am everyday and will move file from one SFTP to another SFTP, which I have done.
I want to add a condition if the first time the file is not present on SFTP then it should check again after 5 min for 3 retry attempts.
Thanks in advance.
I want to add a condition if the first time the file is not present on SFTP then it should check again
In order to check if the file is present or not, you can use List files in folder action.
Then you can check for file's existance by looping through files inside that folder using DisplayName Variable.
I want to add a condition if the first time the file is not present on SFTP then it should check again after 5 min for 3 retry attempts.
Whereas For the above requirement, when you want to retry you can use until Action of Control Connector.
Then set its count to 3 from Change Limits. Below is the flow in my Logic app
In the next step you can use Delay action and set its limits to 5 minutes.
So that for every 5 minutes the flow is going to check whether the file is present or not in sftp for 3 times.
Below is the whole flow that satisfies your requirement.
my JMeter plan is
-- Loop controller (set to 3)
-- while controller(set to "${Dataitems}" != "<EOF>")
-- using CSV for reading the data items
-- HTTP requests
now issue is that after completing the while loop , thread is getting stopped . I know this is controlled in CSV config "Stop thread on EOF" =true will make thread to stop. But my requirement is that after iterating through my csv , I want control to passed to outer loop which will run based on the variable i provide in my case 3 so all request will run for all the data items i provide in csv for three times.
To achieve i tried to set
"Stop thread on EOF" = false , then its started running lopp for intinte times
"Stop thread on EOF" = ${Var1} , where var1 was declared in test plan , but still loop was running infinite times
Can some provide an insight on how to handover control from while loop to outer loop?
Your help much appreciated.
As you know, While controller will keep running until the condition fails.
Unfortunately, in your case, you need to set below condition to reiterate the CSV file values.
'Recycle on EOF?' to TRUE
So, While controller will never exit as you can not use any condition there (to fulfill your requirement).
The only way I can think to make your requirement work is - to use 2 Loop Controllers.
(Outer) Loop Controller (set to 3 as you had said)
(Inner) Loop Controller (set to no of rows in CSV)
I get the output like this. My CSV file has 3 rows with the values A,B,C. They are called 3 times by the outer loop controller.
If you do not want to hard code the number in the loop controller, use a variable & find the no of rows using beanshell and set the value to the variable.
I want to read Database result into variables so I can use it for later requests.
How can i do it?
What if i want to return from database multiple
columns, or even rows? can loop the returned table same way i can
with "CSV Data Set Config"?
--edit--
Ok, i found this solution that uses regular expression to parse the response, but this solution and other like it doesn't work for me, because they require me to change SQL queries so Jmeter could parse them more "easily". I'm using Jmeter to do testing (load testing), and the last thing I want is to maintain 2 different codes, one for "testing" and other for "runtime".
Is there a "specific" JDBC Request solution that enable me to read result into variables using the concept of result-sets and columns?
Using The Regular Expression shouldn't affect what your SQL statement looks like. If you need to modify which part of the response you store in variable, use a Beanshell sampler with java code to parse out the response and store into a variable.
You can loop through the returned table, by using a FOREACH controller, referencing the variable name in the reg ex. Make sure in your reg ex, you set the match value to -1 to capture every possible match.