how can I use different CSVs for my JMeter script on different instance - jmeter

We have 20 worker on AWS and I want to parameterized CSV file name for each instance Please help
I have divided my CSV in to number of Load generator hosts
$ wc -l "youroriginalcsv.csv" /* this will return number of total rows in csv*/
$ split -l "count of above query"/"number of hosts" "youroriginalcsv.csv" /* this will split CSV with file name as xaa, xab ... */
Transfer each unique CSV to all available hosts
$ scp xaa host1_user#host1_ip:/csvpath/csvfile.csv
$ scp xab host2_user#host2_ip:/csvpath/csvfile.csv
$ scp xaz hostN_user#hostN_ip:/csvpath/csvfile.csv
Now I want to use specific file name for specific host

What do you mean by "specific file name for specific host"? Your CSV files are all named csvfile.csv so it's sufficient to specify /csvpath/csvfile.csv in the CSV Data Set Config and each JMeter slave will pick up its own file containing partial data from the "big" CSV file.
If you want to use different names for CSV files depending on the machine IP address or DNS hostname - go for combination of If Controller with __machineName() or __machineIP() function
Also if you don't want the same data to be re-used by different JMeter slaves you can consider using Redis Data Set Config or HTTP Simple Table Server, this way you won't have to "split" and "copy" CSV files and will be able to centrally manage your test data from a single location

Related

How to to get multiple output files with non-gui JMeter?

I need to have 2 output files, one with successes only and another one with failed status. First file must be in CSV format and another in XML (it must contain response data with response body). The solution must be in the non gui mode.
My current solution with one file:
jmeter.bat -Jjmeter.save.saveservice.output_format=xml -Jjmeter.save.saveservice.response_data=true -n -t JMeterFile.jmx -l OutputFile.jtl
I don't know how to make two output files with different content.
For the default .jtl file in CSV (for example suitable for generating HTML Reporting Dashboard) format run JMeter in command-line non-GUI mode like:
jmeter.bat -n -t JMeterFile.jmx -l OutputFile.jtl
For getting another file with detailed information on errors add a Listener, i.e. Simple Data Writer would be a good choice and configure it like:
This way you will get 2 files:
OutputFile.jtl - in CSV format with all metrics for all Samplers
Errors.xml - in XML format for failed samplers only having response data (you can tick other boxes as well if you want more details)
More information: How to Save Response Data in JMeter

Jmeter - Run .jmx file through command line and get the summary report in a html, csv as well as XML output - All three

Currently, I am giving below on the command line. When I add CSV, it doesn't give output in csv format. Can you please provide complete command for all three outputs.
Sample 1:
!JMeter -Jjmeter.save.saveservice.samplerData=true -Jjmeter.save.saveservice.response_data=true -Jjmeter.save.saveservice.output_format=xml -Jjmeter.save.saveservice.responseHeaders=true -Jjmeter.save.saveservice.requestHeaders=true -n -t ProgramServices.jmx -l JmeterReports\TestReport.xml -j JmeterReports\jmeter.log
Sample 2:
JMeter -n -t Creation_SLW.jmx -l JmeterReports/TestReport.csv -e -o JmeterReports/htmlReport/ -j JmeterReports/jmeter.log
As per Generating Report Dashboard documentation
The dashboard generator is a modular extension of JMeter. Its default behavior is to read and process samples from CSV files to generate HTML files containing graph views. It can generate the report at end of a load test or on demand.
So as of latest JMeter 5.4.1 you can only generate the HTML dashboard from .jtl file which is in CSV format and the contents of the file has to be inline with the Result File Configuration
I would recommend reverting your changes and going for CSV + HTML Reporting Dashboard with the default configuration (or with your necessary amendments)
If you need XML with the full data as well - you can add i.e. Simple Data Writer to your test plan and specify the desired file name and the metrics which you want to store:
More information: How to Save Response Data in JMeter

How do I make jmeter use the different hostname/port for different threads of same test plan

In my test scenario I have to test 2 urls with different host and port under same test plan. Is it possible to do so
You can make variable as property and send to jmeter script
Add to Test Plan In User define variables 2 rows:
baseUrl with Value ${__P(baseUrl,localhost)}
port with Value ${__P(port,8080)}
localhost and 8080 are default values you can change it
and when you execute add the values you want e.g.:
jmeterw.cmd ... -JbaseUrl=192.168.0.33 -Jport=80
Define your host and port combinations in a CSV endpoints.csv file like:
somehost,someport
someotherhost, someotherport
and put the CSV file to the "bin" folder of your JMeter installation
Add CSV Data Set Config to your test plan and configure it like:
Set HTTP Request sampler to use ${host} and ${port} variables defined via the CSV Data Set Config
That's it, on each iteration (or virtual user hit) the next line will be picked up from the endpoints.csv file.
See Using CSV DATA SET CONFIG article for more information on parameterising JMeter tests using CSV files.

Details about which user from csv failed response assertion in Jmeter

I am using JMeter to webUI performance testing. I have a list of users in csv with passwords. I am using response assertion to check failed password scenario.
How to record which user from csv is failed?
I would recommend going for Sample Variables property. For example, if you defined a ${username} which holds the user name from the CSV you can get it added to JMeter .jtl results file by adding the next line to user.properties file:
sample_variables=username
If you need to store more variables - provide them separated by commas:
sample_variables=username,password
Remember that:
JMeter restart is required to pick the property up
You can pass it via -J command line argument as well like:
jmeter -Jsample_variables=username,password -n -t test.jmx -l results.jtl
See Apache JMeter Properties Customization Guide for more information on different JMeter properties types and ways of working with them

Use multiple column variables in bash script to pull output from routers

I have a script that logs on to routers and pulls output that is named routerauto. I would like to use data from a text file to automatically populate required commands to pull required info from a large number of routers.
Ultimately I would like the script to move through each line of the text file, filling in the gaps with the output from the columns as below. The text file uses tab as separator.
routerauto VARIABLE1 "sh service id VARIABLE2 sap VARIABLE4 detail"
Example data:
hostnamei serv-id cct sap
london-officei 123456 No987654321 8/1/4:100
Example output:
routerauto london-office "sh service id 123456 sap 8/1/4:100 detail"
Here is a bash only solution:
#!/bin/bash
while read hostnamei servid cct sap; do
echo routerauto $hostnamei \"sh service id $servid sap $sap detail\"
done < <(tail -n +2 sample.data)
Producing given your sample file:
routerauto london-officei "sh service id 123456 sap 8/1/4:100 detail"
Please note this assume no space are allowed in your various data fields.

Resources