How to email the updated test result in jmeter - jmeter

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.

Related

Jmeter displays doubled results when running in non gui mode

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

How will I know how many API requests are failed and passed when I am using the Jmeter in Non-GUI mode?

I am a beginner to Jmeter.My goal is to test the performance of 1000000 API requests.I have started testing in GUI mode but after reaching 5000 requests it's throwing an error.From that error I noticed that I have to run the Jmeter in Non-GUI mode to run more number of requests.I have started running in Non-GUI mode it's giving the result in summary format.I want to see which API is success and failed as in GUI mode we are able to see in view results tree listener.
You can create JMeter Dashboard to see the results. Run the test in non gui mode as below:
jmeter -n -t /path/to/testplan -l /path/to/result.jtl
once your test is complete you can use (.jtl) file to generate dashboard
run the command as below:
jmeter -g /path/to/result.jtl -o OUTPUT_FOLDER
Check the output folder --> index.html, you will see the list of API requests you have sent.
Normally when you run JMeter in command-line non-GUI mode you should specify the .jtl results file where the test output will be stored like:
jmeter -n -t test.jmx -l result.jtl
^test ^file with
plan test results
Once your test is finished you can:
Open the result.jtl (it's a normal CSV file) with MS Excel or LibreOffice Calc and analyze the results there
Open the result.jtl file with the Listener of your choice, i.e. Aggregate Report
Generate tables and/or charts you need using JMeterPluginsCMD Command Line Tool
Generate HTML Reporting Dashboard from the .jtl results file

How can i create HTML report in JMeter using Bean shell sampler in tear down thread?

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`

Throughput Shaping timer- Externalising

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

how can we capture all requests going from JMeter running on Linux?

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

Resources