JMETER nested while loop is stopping at first line of the CSV data file - jmeter

I have to make a GET call on IDs stored in a CSV while and I have to retry on GET call till it returns 200 response code.
This is what my current structure looks like ..
GET thread group
Once only controller to grab authentication for each thread
While Controller with condition "${__javaScript("${index}"!="<"EOF">")}" to check for end of the CSV
file
CSV data config file (Each file is unique for each thread) , variable name is "index", Recycle on
EOF - False, Stop thread on EOF - True,
sharing mode - current thread
While Controller with condition "${__javaScript(parseInt(vars.get("Response_code"))!=201)}"
User defined variables - Response_code
Http GET request
JSR233 post processor - "vars.put("Response_code",prev.getResponseCode());"
JSR223 post-processor - To write ID returned in successful call to another CSV file
Now I am not getting error or anything .. but I was expecting first while controller to loop through CSV file for each id, then make a GET request for each id and then second while loop would wait for success code but for some reason, GET call is only executing for the first entry in the csv and then exit out of it. What am I missing here?

CSV data config file (Each file is unique for each thread)
this is not how it works, the CSV Data Set Config is being initialized once with the filename resolved at the time of its execution, it doesn't load the new CSV file for each virtual user.
If you're looking for an option of supplying the CSV file name(s) dynamically in the runtime - consider switching to __CSVRead() function. See How to Pick Different CSV Files at JMeter Runtime article for more details.

Related

Value cannot be null: Parameter: Source error received from JMeter

I have been receiving this error message on particular request - "Value cannot be null. Parameter name: source".
My Scenario is that 1 user will be transacting 5 transaction (Search and Remit). I'm targeting to run 650 Users to 3250 Transaction. The problem is that one particular request which is getting details from the DB, some data is passed but mostly are the mentioned error message above.
I Have 2 CSV Config, 1 from Users, the 2nd is for the Data where the second csv is inside the Loop Controller.
Your application tells you that the request is not correct, it expects a value and you're failing to provide the value. Use Debug Sampler and View Results Tree listener combination to validate the values of the JMeter Variables which are being sent for successful and not successful requests, it might be a test data issue, for example an extra comma in the CSV file will make CSV Data Set config "think" that this is the delimiter for the next column.

Failed thread should not pick same data from CSV file, already read by thread in queue

Precondition:
Threads: 5, Loop Count:5
CSV config file contains: IP address and Mac address
Scenario:
When Thread execution starts, 5 threads reads values of IP address and Mac address from CSV file.
T3 fails in execution and looping of threads starts, it picks Ist ip and ist mac address from CSV and that is already picked by ist threads and is in queue(Completing end to end flow).
How to handle like all the threads in queue should have picked unique row from CSV file?
As of JMeter 5.1 none of the test elements and JMeter Functions suitable for parameterization provides the behavior you're looking for.
You can use __groovy() function to script the CSV file reading in the way you want, for example you cat configure 1st virtual user to read 1st row, 2nd user - 2nd row, etc.
The relevant Groovy code would be something like:
${__groovy(new File('test.csv').readLines().get(ctx.getThreadNum()).split('\,')[0],)} - gets the value from 1st column
${__groovy(new File('test.csv').readLines().get(ctx.getThreadNum()).split('\,')[1],)} - gets the value from 2nd column
Demo:

How can run JMeter with limited CSV login details for multiple threads ?

Im just trying to run my JMeter script for 20 threads. I'm use CSV data set config for read login data. I set there are only 5 login details in CSV file. When i run the script only first 5 request got pass and rest of the thread request got fail. Anyone can suggest a solution. Thanks.
Apply the following configuration to your CSV Data Set Config:
Recycle on EOF - True
Stop thread on EOF - False
When JMeter reaches the end of the CSV file it will start over so 6th thread will get <EOF> as the value, 7th thread will pick 1st line, 8th thread will pick 2nd line, etc.
You can put your login request under the IF Controller and use the following condition:
"${line}" != "<EOF>"
to avoid the login failure due to this <EOF> variable value.

jmeter loop through multiple files

I have a Jmeter test with multiple while controler, each looping through data in separate files
I want each while loop to loop through the end of that file.
Structure:
While controller 1
- CSV Data Config 1
- Http sampler 1
While Controller 2
- CSV Data Config 2
- http sampler 2
When I set as an end condition: ${__javaScript(${myVar}!="<EOF>")} with stop thread on end of file to true, it stops the whole test completly.
If I set stop on end of file to false it loops on the also, meaning it loops one time too many
Is there another way to do this?
Thanks
A possible solution would be use beanshell processor and find the number of records in each file. Use the number of lines as the condition to break out of the loop. Please note that you will have to use parseint in the while condition as discussed in this thread.
Another option could be changing your While Controller to do the infinite loop and control thread stopping via CSV Data Set Config.
As per Using CSV DATA SET CONFIG guide:
It is worth mentioning that every CSV Data Set Config is visible to all Thread Groups by default. If you need to use separate CSV Data Set Config for every Thread, you create a number of data files that you need and in every CSV Data Set Config set “Sharing mode” to “Current Thread”
So the following combination:
Recycle on EOF = false
Stop Thread on EOF = true
Sharing mode = Current Thread
Should do the trick for you.

how to use separate csv file for each thread

My scenario is like,
1. Login by multiple users (100 users)
2. Select 50 items by id's specific to user
I have placed id's for each user in separate csv file say user1.csv, user2.csv, user3.csv and so on.
My result should be like Thread 1 should take user1.csv and process all 50 id's in loop controller.
Thread 2 should take user2.csv and so on.
I tried with below example, but still couldn't find the solution.
Eg. I used file path as C:\abc\user${_threadNum}.csv
Or
C:\abc\user${_threadNum}.csv
Variable name in csv file is user_id
Requeat will look like /home/abc/${user_id}
I want thread 1 to use the user1.csv file and substitiue the value of user_id in the request and thread 2 should use user2.csv and so on.
If I execute my above plan, I am getting error as /home/abc/EOF
How is this possible in JMeter? Or any other approach?
Please provide solution with an example, since I am new to JMeter.
Create your files like comman_name_1,comman_name_2,comman_name_3
etc. & select current thread option from dropdown list present in csv data config set.This will allow threads to use different files per thread or put values in a single file and select current thread option.
It's easy, just add CSV Data Set Config to each thread (user1.csv for thread1 and so forth). Configure CSV Data Set config, and select one of this values in Sharing mode field:
Current thread group - each file is opened once for each thread group
in which the element appears
Current thread - each file is opened separately for each thread
UPD: I have done it right now, it works
Script looks like this:
I selected 'Current thread' in each CSV Data Set Config
I was making the mistake of using single underscore in fetching the count of thread.
We need to use double - underscore like this : ${__threadNum}
Note :

Resources