JMeter Multiple Log Files from Command Line - performance

I'm running JMeter through jenkins for performance testing using the command line options. I already write to one jtl file when I do the command, such as:
java -jar path to Jmeter -n -t jmx file -l log file
I would like to also put the results into another log file stored in another location, but I can't get it to work by putting another path after the -l command or putting in a second -l. Is there anyway to do this simply?
Thanks

Check these options. you should use the option '-j'. It works fine for me.
-n This specifies JMeter is to run in non-gui mode
-t [name of JMX file that contains the Test Plan].
-l [name of JTL file to log sample results to].
-j [name of JMeter run log file].
-r Run the test in the servers specified by the JMeter property "remote_hosts"
-R [list of remote servers] Run the test in the specified remote servers

Related

How can I create a new unique name jmeter.log file each time a CLI command is run?

Whenever I run a new jmeter command from the CLI a new jmeter.log file is generated and I lose the contents written by the previous test run.
Example:
First I run the test script with :
jmeter -n -p .\config.properties -t .\path\to\jmeterScripFile.jmx -l .\path\to\jmeterScriptOutputFile.jtl
This generates a fresh jmeter.log file.
Then I run this command to generate a HTML Dashboard report:
jmeter -g .\path\to\jmeterScriptOutputFile.jtl -o .\path\to\TestResults\ReportHTML
This 2nd command overrides the previous jmeter.log file contents.
I would like each jmeter CLI command to generate a unique .log file.
Something like jmeter-yyyymmdd-hhMMss
How could I achieve this?
You can override the default jmeter.log file name using -j command-line argument like
jmeter -j your-custom-log-name-here.log -n -t .....
the timestamp can be added by means of your operating system
If you want to make the change permanent and don't want to provide the new log file name via -j command-line argument you can amend the log file prefix via log4j2.xml file like
change this line:
<File name="jmeter-log" fileName="${sys:jmeter.logfile:-jmeter.log}" append="false">
to something like:
<File name="jmeter-log" fileName="jmeter-${date:yyyyMMdd-hh-mm-ss}.log" append="false">
More information: How to Configure JMeter Logging
JMeter command line option -j will allow you to specify the jmeter log file. Name of the file can be set dynamically. If you are on Mac $(date +%Y%m%d-%H%M%S) can be used for getting the timestamp.
-j
[name of JMeter run log file].
List of command line options
You can use following command with current time stamps suffix to the jmeter log file. The log file will be create in your JMETER_HOME/bin folder.
./jmeter -n -t TestPlan-Basic-Test.jmx -j jmeter-$(date +%Y%m%d-%H%M%S).log -l test-result.csv
Similar could be used on widows. link
You can follow this simple example the date here generates date now:
jmeter -g ./path/to/"`date`".jtl -o ./path/to/TestResults/ReportHTML
Extra:
In case you want dates separated by underscores you can use this
DN="`date`"
DATE_NOW=${DN// /_}
jmeter -g ./path/to/$DATE_NOW.jtl -o ./path/to/TestResults/ReportHTML
PS: Don't forget to do the same thing for the other command.
Date Example would look something like this Sun_Dec__5_00:55:38_WCAST_2021

How to generate composite html report for distributed load testing in jmeter?

Context: I am running JMeter load test on a distributed load system with 1:2 master slave ratio, with the following command:
jmeter -n -t "home/jmeterscripts/EventGridScript.jmx" -R slave1:1099,slave2:1099 -l "home/jmeterscripts/Result.csv" -e -o "home/jmeterscripts/HTMLReports"
Will the result report to the same report.html because I am getting error of Result.csv presence from slave2 while reporting? how to handle it this, didn't find similar post.
You're getting this message because home/jmeterscripts/Result.csv is present already, if you don't need the results file from the previous run add -f command-line argument to your command line:
jmeter -n -t -"home/jmeterscripts/EventGridScript.jmx" -R slave1:1099,slave2:1099 -f -l "home/jmeterscripts/Result.csv" -e -o "home/jmeterscripts/HTMLReports"
-f, --forceDeleteResultFile
force delete existing results files and web report folder if present before starting the test
The results are not being stored on slaves, the slaves send test metrics to the master so the master collects the statistics from all the slaves so no matter how many slaves you have you always get a single .jtl results file and a single HTML Reporting Dashboard.
More information: How to Perform Distributed Testing in JMeter

Passing Parameter with -J var=value works not with Jmeter remote tests executions

I would like to pass jtl file name over command line arguments. commanline lookslike this:
jmeter -J JTL=%JTLFILE% -t Metasuche.jmx
In Script I am using ${__P(JTL)}. If i am starting jmeter like this:
jmeter -J JTL=%JTLFILE% -t Metasuche.jmx
and
jmeter -J JTL=%JTLFILE% -t Metasuche.jmx -n
It works as expected and jtl file is created in a file as passed in arguments. But if I am starts Jmeter with:
jmeter -J JTL=%JTLFILE% -t Metasuche.jmx and -n -r
then my JTL values are landing in a new File ${__P(JTL)} in current directory.
How should I tell jmeter to use command line arguments in local and remote executions?
If you want to pass the properties to the remove machines via command-line argument you should be using -G instead of -J
As per Overriding Properties Via The Command Line
-G[prop_name]=[value]
defines a JMeter property to be sent to all remote servers.
-G[propertyfile]
defines a file containing JMeter properties to be sent to all remote servers.
More information:
Full list of command-line options
How to Perform Distributed Testing in JMeter

JMeter Distributed Runner not able to Generate the Consolidated Reports

When I am running a simple standalone JMeter script using command line as below
jmeter -n -t your_script.jmx
This generates a CSV file which contains all the data related to the execution.
However, when the same JMeter file executed for a distributed load testing with multiple JMeter Server IP addresses which will simulate the given number of users and runs on the target server, I am not able to get the jmeter.csvfile Generated(But the command runs successfully).
The command I have used for distributed execution is
jmeter -n -t script.jmx -R IP_address1, IP_address2,...
Now, I should get a consolidated jmeter.csv file from this execution. But, I am not getting one.
Same is the case with JMeter API DistributedRunner Class- We are not getting the consolidated jmeter.csv file and reports.
This command:
jmeter -n -t your_script.jmx
does not generate any CSV file, you need to add -l command-line argument and provide desired results file location like:
jmeter -n -t your_script.jmx -l jmeter.csv
The same applies for distributed testing:
jmeter -n -t script.jmx -R IP_address1, IP_address2 -l jmeter.csv
If you provide -l command-line argument but still not getting any results most probably your script execution fails on remote slaves somewhere somehow. Follow the below checklist in order to get to the bottom of the script failure:
Inspect jmeter.log file on master machine and jmeter-server.log on the remote slaves, if something goes wrong - most probably you will find the cause in log files
Make sure that JRE version is the same on master and the slaves
Make sure that JMeter version is the same on master and the slaves, it's recommended to use the latest JMeter version where possible
If the test relies on any of the JMeter Plugins - make to install them all onto all slave machines. The plugins can be installed using JMeter Plugins Manager
If your test is using CSV Data Set Config - you will need to copy the CSV file to all slaves manually
If your test needs any additional JMeter Properties you will need to supply the properties via -J or -D command-line arguments on all the machines or via -G command-line arugment on the master

How do I clear the jmeter results from dashboard on multiple runs?

I'm currently running jmeter in NON-gui mode and I want to generate a report after each run.
The problem I have is that the results are being added in the jmeter dashboard after each run and are not cleared. How can I generate the report only with the last run?
If you have the jtl file saved for the last test run then it's quite easy to generate dashboard result specifically for that test from the jtl file.
Execute the below command
./jmeter -g <jtl file> -o <output folder>
jmeter -n -t (path to your jmx files is) -l (path and name of the jtl file) Example: jmeter -n -t C:\QA\test.jmx -l C:\QA\testresults.jtl this will make a different .jtl file based on the name you give it.

Resources