Jmeter Multiple CSV files - jmeter

I wanna use 2 CSV files. One CSV file with user id nd passwords.And second CSV file, containing data for adding different producers(agents) against each user.
I mean user id 1 should take 1st row of producer data, user id2 shall take 2nd row of producer data and so on. IS this possible in jmeter and how?

Put user 1, password 1 and other data in the same row which needs to be used. Make sure you CSV is having the headers and do not put any thing in the "Variable Names" of CSV Dataset config.
Now, when you run with multiple thread, 1st thread will pick 1st row and then move to the second row. Other threads will also do the same.
Hope it helps.
You can use multiple csv's but then you have to maintain login and other test data binding. So, it is better to put it in one.

Related

How to relate two variables in JSON POST request

I have a JMeter test scenario as follows: several hundred users have to login to a platform and send a POST request with several hundred of profiles to generate a report. For the data, I use two csv files.
One csv file contains the data of the users with which JMeter will login and send a POST request to generate a report. It contains the following fields:
userid, companyid, password
once logged in, each of these users has to choose profiles from another csv file, to generate reports about those profiles. The other csv file has these fields:
profileid, companyid
Each user can only generate profiles of the profiles that have the same companyid.
The profiles have to be placed inside an array, which in turn is inside an object, in a JSON request. IMPORTANT: all the profiles have to be placed inside the array in a single iteration. That means that if there are 1000 profiles, they have to be set on the array at the same time.
I haven't been able to:
Figure out how to ensure that for each user, the specific profiles available to that user get set in the array.
Figure out how to actually insert the values in the array, all in a single iteration .
Could someone offer advice on how to achieve this?
Disclaimer: I don't know Java and I have just begun using JMeter a few days ago.
It's hard to provide a comprehensive answer without seeing your CSV files structure so I can provide only a generic piece of advice:
If you're looking at CSV Data Set Config be aware that it reads the next line on each iteration, if you need to read multiple lines within the bounds of a single iteration you need to use __CSVRead() function or consider using JSR223 Test Elements for scripting
Solution 1
You can use a CSV Data Set Config element to read the data, userid, companyid, password from the first CSV file.
Add a CSV Data Set Config element to read the user credentials.
It will read one row for each thread and each iteration.
Now you have the companyid available for the entire iteration. You need to filter the data with the companyid from the second CSV file. This can be done with Groovy (you can use Java too).
Add a JSR223 Sampler to retrieve the profileid from the second CSV file. Following code demonstrates reading the CSV file into list of files and then filter the lines with companyid
log.info("Processing profile")
def lines = new File('company_profiles.csv').readLines()
def filteredLine=lines.find { it.contains(args[0])}
def lstRecord = filteredLines.get(currentRecord).split(",")
vars.put("profileid","${lstRecord[0]}")
SampleResult.setIgnore()
NOTE : companyid is passed to the script as an argument. Please see the highlighted areas in the following.
The profileid is set as a variable in the script vars.put("profileid","${lstRecord[0]}"). You can use the profileid within the iteration of the current thread with ${profileid}

Apache Nifi, can I collect an attribute from multiple flow files

I have a nifi flow that takes in .csv files and partitions each into multiple records with each csv column value added as an attribute.
At one point in the flow, I'd like to collect the value of one attribute from each record that passes though. There could be from 0 to n collected. Once I have the list, it'll be emailed out.
I'm trying to avoid me (or someone else) getting bombed with emails if there are 200+ bad records in a file. So if I could collect for a fixed period of time or until another attribute (filename) changes, that would be great.
I've tried merge content and record. I even tried replace text to replace the content w/ just the attribute value I want to save and merging those, and a slew of other things.
Is there a simple way to do this in nifi?
Have you tried UpdateAttribute with a new attribute of type array. When each flowfile passes the this processor you could continue to update the value of this attribute by appending a new value to the array, attribute.
However, as #daggett pointed out, it will be helpful if you can provide the input and expected output.

How can I read two values for the same request from CSV data set config in jmeter?

I need to read two values from two different rows in a csv and pass those values as a part of the body of a POST request.
Through CSV data set config I'm able to read only one value at a time. Is there any way I can read two values in the same request?
Example:
sourceSystemGuid,sourceSystemName
sourceSystem_733,sourceSystem733 sourceSystem_590,sourceSystem590
sourceSystem_959,sourceSystem959
I need to read two values for sourceSystemGuid in one request.
Without custom scripting it’s not possible.
But you can put 4 columns per line and that will do what you want.

Spring Batch, read whole csv file before reading line by line

I want to read a csv file, enrich each row with some data from some other external system and then write the new enriched csv to some directory
Now to get the data from external system i need to pass each row one by one and get the new columns from external system.
But to query the external system with each row i need to pass a value which i have got from external system by sending all the values of a perticular column.
e.g - my csv file is -
name, value, age
10,v1,12
11,v2,13
so to enrich that i first need to fetch a value as per total age - i.e 12 + 13 and get the value total from external system and then i need to send that total with each row to external system to get the enriched value.
I am doing it using spring batch but using fLatFileReader i can read only one line at a time. How would i refer to whole column before that.
Please help.
Thanks
There are two ways to do this.
OPTION 1
Go for this option if you are okey to store all the records in memory. Totally depends how many record you need to calculate the total age.
Reader(Custom Reader) :
Write the logic to read one line at a time.
You need to return null from read() only when you feel all the lines are read for calculating the total age.
NOTE:- A reader will loop the read() method until it returns null.
Processor : You will get the full list of records. calculate the total age.
Connect the external system and get the value. Form the records which need to be written and return from the process method.
NOTE:- You can return all the records modified by a particular field or merge a single record. This is totally your choice what you would like to do.
Writer : Write the records.
OPTION 2
Go for this if option1 is not feasible.
Step1: read all the lines and calculate the total age and pass the value to the next step.
Step2: read all the lines again and update the records with required update and write the same.

How to read values from a csv when the number of rows are exact for each parameter?

I have to run a load test on a server. The requests have to go to 2 servers in order to balance the number of requests. There are 100 household IDs also. So I have to use the first household and send the request to the first server. The second household to the second server. The third household to the first server again and 4th household to the second server. This should continue till 100 households send the requests and it will be exactly 50 requests for each server. I have created a CSV file with 2 columns. One column for Household with 100 rows and another column with 2 rows. The problem here is when the 3rd request is sent, JMeter will pick the 3rd Household but the server is blank. Is there any way to implement this using a single CSV file? I can make this work using 2 CSV files.
Please see the below Pics.
Looking at the last screen shot, the request is seen without an IP.
Jmeter scans complete row.It is not getting any value in 3rd iteration hence parameter is taking blank value .you have two option:
1.Drag drop 2 value to entire file .(not efficient though)
2.OR create separate csv file or use something like user defined variable

Resources