Not able to generate html report in JMeter using Commandline - jmeter

I want to generate html report from the csv file that is created. I am using BlazeMeter to record the test which gives me .jmx file.
When I give:
sh jmeter -n -t /home/Annie/JMeter/vDC1.jmx -l /home/Annie/JMeter/a.csv
I am getting a csv file where there is no header.So when trying to generate a html report it shows:
File '/home/Annie/JMeter/a.csv' does not contain the field names header, ensure the jmeter.save.saveservice.* properties are the same as when the CSV file was created or the file may be read incorrectly.
I tried the solution found in:
Getting Header error in JMeter when trying to get HTML report
Its still showing the same error. However its showing the html report.
Is there anything else to be done?

Related

Azure Load test preview unable to read data from parameterized CSV file in JSR223 Sampler

I used JSR223 Preprocessor to create the request body for a POST JSON request. I used Groovy language for it The code has some parameterization so, I mentioned the path for CSV file in the script as below and attached the Order.csv file to the test plan in load test preview.
CSV file path in the script:
"List lines = new File("Order.csv").readLines()"
So whenever I run the test in Azure load test preview, the is the error message im encountering:
javax.script.ScriptException: java.io.FileNotFoundException: Order.csv (No such file or directory)
How can I fix this. Please Help.
I tried just mentioning the CSV file name in the code and attached the CSV file to the Load test preview along with .jmx file.
This is throwing error saying, File not found
How do you know where guys from Microsoft are placing the CSV file and why do you expect them to copy it to the same place where the .jmx script lives?
I would suggest amending your Groovy script to get the file location dynamically using FileServer class, i.e. change this line:
List lines = new File("Order.csv").readLines()
to something like:
List lines = new File(org.apache.jmeter.services.FileServer.getFileServer().getBaseDir() + File.separator + 'Order.csv').readLines()
More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?

Partial data is getting generated in html report

jtl file contains 2 testcase but when i generate html report using the same only the data of latest entry is populating in html report,
Command used for Report generation:
sh jmeter.sh -g /home/sadha/Documents/apache-jmeter-5.4.1/logs/log.jtl -f -o /home/sadha/Documents/apache-jmeter-5.4.1/bin/Output/
Getting below message in terminal after executing above command,
File '/home/sadha/Documents/apache-jmeter-5.4.1/logs/log.jtl' does not contain the field names header, ensure the jmeter.save.saveservice.* properties are the same as when the CSV file was created or the file may be read incorrectly when generating report
JTL data:
1619015828359,121,aws_sns,200,,Thread2 2-1,text,true,,422,592,1,1,http://10.77.2.208:8080/graphql,117,0,66
1619015831675,137,solutionsinfini,200,,Thread2 2-1,text,true,,422,600,1,1,http://10.77.2.208:8080/graphql,130,0,65
Below is the screenshot of html report
You need to have the same Results File Configuration for JMeter instance(s) which:
run the test
generate the reporting dashboard
any inconsistencies will result in failure or data loss
Particularly in your case the "problematic" property which doesn't match is jmeter.save.saveservice.print_field_names, try modifying your command to set this property to false via -J command-line argument as:
sh jmeter.sh -Jjmeter.save.saveservice.print_field_names=false -g /home/sadha/Documents/apache-jmeter-5.4.1/logs/log.jtl -f -o /home/sadha/Documents/apache-jmeter-5.4.1/bin/Output/
in order to make the change permanent put the following line to user.properties file of your JMeter installation:
jmeter.save.saveservice.print_field_names=false
More information:
Configuring JMeter
Overriding Properties Via The Command Line
Apache JMeter Properties Customization Guide

Jmeter: How to create HTML dashboard in jmeter using saved summary csv file

I am using following command to generate HTML dashboard:
jmeter -g C:/Users/E01659/Desktop/feb28/feb28_10_3600.csv -o C:/Users/E01659/Downloads/apache-jmeter-5.1/bin/sonali/
Following error is coming: File
'C:\Users\E01659\Desktop\feb28\feb28_10_3600.csv' does not contain the
field names header, ensure the jmeter.save.saveservice.* properties
are the same as when the CSV file was created or the file may be read
incorrectly when generating report An error occurred: Mismatch between
expected number of columns:17 and columns in CSV file:11, check your
jmeter.save.saveservice.* configuration or check line is complete
errorlevel=1
From the error message, it is clear that - CSV file created earlier don't have the header as the first line. When you want to create the APDEX Dashboard from CSV file, JMeter expects that files are created with correct Save Service Configuration. You can change Result file config which are present in jmeter.propertes file.
You may need to change the line as below, so that file created has the headers name as required
jmeter.save.saveservice.label = true
The command you're using is correct, the reason of failure is mismatch of the .jtl file contents and what JMeter expects it to be.
If you got this feb28_10_3600.csv file from execution on another JMeter installation - make sure that JMeter's result save configuration on the machine where you're trying to generate the report is identical to the JMeter installation where JMeter was running.
Inspect the associated JMeter properties and amend them to for 100% match, once done you should be able to normally generate the dashboard.
If you still experience the differences update your question with first 2-3 lines of your .jtl results file.
You are receiving this error (most likely) due to a corrupt line at the end of your file. Just execute a 'tail ' to see the last few lines. Most likely, your last line is missing columns due to an abrupt stop in the test. Once you delete the problematic line, you should be able to generate the HTML report.

How to save request body in Jmeter?

I am fetching data from the CSV file and giving as input to my Request.How can I save all the request in the same file when I run a test for an hour.
One more requirement is, if the result is success then I have to write that data I have used from the CSV into another file so that we can have only the data which is working in an separate file.
Please suggest
The best way would be using JMeter's built-in Sample Variables property.
Add the next line to user.properties file:
sample_variables=foo
Replace foo with the variable name you're getting from the CSV file
Next time you run your JMeter test in command-line non-GUI mode like:
jmeter -n -t test.jmx -l result.csv
your result.csv file will have an extra column called foo and having the foo variable value for each and every request. You will be also able to determine which data caused the failure by looking into "success" column

Saving a exact response in file in Jmeter

How to save exact response from Jmeter in a file?
e.g. - I have a response as email only so I want to save this email address only in a file with a success and failure but If I am saving a file as xml its giving a whole bunch of code otherwise if I save it as a csv file it's giving all sort of infomation other than a email address. Pls help me to solve it.
If you need to save the whole response - Save Responses to a file listener is what you're looking for.
If you need to store a part of the response - first of all get the necessary part with i.e. Regular Expression Extractor. Once you have JMeter Variable holding required value i.e. email you can add the next line to user.properties file (lives under /bin folder of your JMeter installation)
sample_variables=email
and ${email} variable value will be stored along with other results.
NB
you need to restart JMeter to pick the property up
you can also pass it via -J command line argument like:
jmeter -Jsample_variables=email -n -t /path/to/testplan.jmx -l /path/to/results.jtl
References:
Sample Variables
Apache JMeter Properties Customization Guide

Resources