I want to externalise the value for throughput shaping timer But not from Jmeter or User.properties as I have couple of other script to be executed with different work load model. I want a separate property file specifying the load pattern can you kindly suggest.
There is a load_profile property, you can define the desired Throughput Shaping Timer load model via it.
If you don't want to write down the value into jmeter.properties or user.properties file to permanently change the profile you can pass it via -J command line argument instead like:
jmeter -Jload_profile=const(10,10s) line(10,100,1m) step(5,25,5,1h) -n -t ...
Having separate file is also not a problem,
Create, i.e. test1.properties file in the "bin" folder of your JMeter installation
Put your desired load profile there:
load_profile=const(10,10s) line(10,100,1m) step(5,25,5,1h)
Pass this file to JMeter via -q command-line argument like:
jmeter -q test1.properties -n -t ...
Repeat steps 1-3 for 2nd test, you will be able to run it like:
jmeter -q test2.properties -n -t ...
References:
Full list of JMeter's command-line options
Configuring JMeter
Apache JMeter Properties Customization Guide
Related
I have a Test plan which when I run in the Gui Mode execute the sampler one time, but when I start the Test Plan from the command line I get the sampler to be running twice.
I have deleted the result.jtl file to insure that the results are not accumulated.
Without seeing your test plan it's hard or even impossible to say what's the reason as there are too many possible options, the most straightforward I can think of is:
You have a Listener (or two) somewhere in the test plan configured to write data into the same file which you specify via -l command-line argument
You have resultcollector.action_if_file_exists=APPEND property defined somewhere
So try out the following way of running the test:
jmeter -n -t test.jmx -l result.jtl -f -Jresultcollector.action_if_file_exists=DELETE
where:
-f forces JMeter to overwrite the .jtl results file
resultcollector.action_if_file_exists=DELETE property does the same for Listeners
More information:
Full list of JMeter command-line options
JMeter Properties Reference
Apache JMeter Properties Customization Guide
I faced with a strange issue. I need a jmeter to generate jtl and log files where name of the file will be hostname where jmeter is running on. For this task I found internal variable "__machineName()" in my case it works but only partially. Below is example:
jmeter ... -l ${__machineName()}.jtl -j ${__machineName()}.log
But result is a bit strange:
${__machineName()}.log 328-15-09-2020-15-02-42-95r4v.jtl
It works but only for jtl file! I've tried other variables and had the same result.
Have you faced with such issues?
Additional info: execution of jmeter is wrapped in the script that receives all properties as string and just execute it, therefore ideas about usage of shell commands won't work. Result will look the following way:
`hostname`.log or ${HOSTANME}.log
Workflow:
Python generate string with paramaters for jmeter execution. I'm using Jinja here. Part of the code:
Template( -Djava.net.preferIPv4Stack=true \
-l {{ log_dir }}/${__machineName()}.jtl \
-j {{ log_dir }}/${__machineName()}.log)
Python schedule Kubernetes Job and pass string with properties to the jmeter
Container with jmeter has entrypoint script here it set some Java params and start jmeter. Part where jmeter receives string with properties:
...
export JVM_ARGS="-Xmn${n}m -Xms${s}m -Xmx${x}m"
jmeter $#
Jmeter execute test with specific params and write logs. Exactly here I faced with a problem that ${__machineName()} works ok for -l(jtl log) param and doesn't work for -j(log) param.
The function will not be executed as it's between your shell and log4j logging system, you need to fix your shell script in order to be able to shell commands.
If for some reason you cannot amend your shell script it should be possible to change JMeter logging configuration so it would contain environment variable lookup
Necessary changes to log4j2.xml file (lives in "bin" folder of your JMeter installation)
Add this block to define HOSTNAME property reading the underlying OS environment variable
<Properties>
<Property name="HOSTNAME">${env:HOSTNAME}</Property>
</Properties>
Change this line:
<File name="jmeter-log" fileName="${sys:jmeter.logfile:-jmeter.log}" append="false">
to this one:
<File name="jmeter-log" fileName="${HOSTNAME}.log" append="false">
so next time you start your test JMeter will create the log file with using your machine hostname as the filename and you won't have to pass it via command-line argument.
More information: How to Configure JMeter Logging
I want to create an HTML report automatically after running each test in JMeter, also I want to create a folder dynamically with the current timestamp as a folder name for placing the report on my local drive. So how can we do this operation using Bean Shell sampler in tear down thread group?
Your approach is not very good as it violates 2 major JMeter Best Practices:
You will need a Listener in order to write down the results and using Listeners is a performance anti-pattern
Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting
So I would recommend:
Run your JMeter test in non-GUI mode and generate dashboard after it
Use your operating system date and time command to create the folder with the timestamp
Windows example:
jmeter -f -n -t test.jmx -l result.jtl -e -o results-%date:~10,4%-%date:~4,2%-%date:~7,2%
Linux example:
jmeter -f -n -t test.jmx -l result.jtl -e -o results-`date +%Y-%m-%d`
My test is running on Linux VM via JMeter [command line]. Access logs of apache server shows that few requests didn't reached to it and for few requests, it is giving 400 response [i.e. bad request]
So i wanted to capture all requests going from JMeter and with parameters if possible.
Is there any way of doing it?
You can do it using tcpdump tool like:
tcpdump -i any -s0 -w /path/to/dump.pcap
And once JMeter test finishes open dump.pcap file with Wireshark and inspect packets
Alternative option is configure JMeter to save request and response data. It can be done in 2 ways:
Add the following lines to user.properties file (lives in "bin" folder of your JMeter installation)
jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.url=true
jmeter.save.saveservice.responseHeaders=true
pass above properties via -J command-line argument like:
./jmeter -Jjmeter.save.saveservice.output_format=xml -Jjmeter.save.saveservice.response_data=true -Jjmeter.save.saveservice.samplerData=true -Jjmeter.save.saveservice.requestHeaders=true -Jjmeter.save.saveservice.url=true -Jjmeter.save.saveservice.responseHeaders=true -n -t example.jmx -l example.jtl
Once test finishes open resulting example.jtl file in JMeter GUI with View Results Tree listener - you will be able to see request and response details along with parameters, variables, etc.
References:
JMeter Non-GUI Mode (Command Line mode)
Apache JMeter Properties Customization Guide
I have a simple HTTP Request sampler in a test plan. And, viewing the result through "Aggregate Report" and writing the same results to a file. I have used "SMTP Sampler" in "tearDown Thread Group" and also used the "Test Action" to wait for a while.
Issue is, once I execute the test-case, in mail I got the previous run results instead of the new one.
Here is the screen-shot of my test plan.
Please help. Thanks in advance!
I don't like your "Test Action to wait for a while" approach as it may be not enough so you won't be able to tell for sure whether JMeter stored the most recent results or not.
I would suggest the following: add jmeter.save.saveservice.autoflush=true line to user.properties file (it's located under /bin folder of your JMeter installation) and on next JMeter start it will be storing every single line.
So
Apply aforementioned property change
Configure your SMTP Sampler to send results.jtl file
Disable all the listeners.
Run JMeter in command-line non-GUI mode as follows
jmeter -n -t /path/to/your/testplan.jmx -l /path/to/results.jtl
As an alternative to editing user.properties file you can pass the property via -J command line argument like:
jmeter -Jjmeter.save.saveservice.autoflush=true -n -t /path/to/your/testplan.jmx -l /path/to/results.jtl
See Apache JMeter Properties Customization Guide for more information on JMeter properties and ways of working with them.