Saturday 30 September 2017

Automate JMeter Reporting

The below post will explain how to automate the reporting part in JMeter.

Since, we all know that it is quite challenging to create graphs in jmeter after the load test execution. Also, the summary report that JMeter provides us contains response time of PASSED as well as FAILED transactions. (we require response time for the PASSED transactions only)
Moreover, we also want to get the result data for steady state duration along with full duration.

I have created a script in JMeter that will take care of all the above points.You need to provide the .JTL or .CSV path and my script will do the rest.

Prerequisite(One time work)


You have to install the following plugins
  • https://jmeter-plugins.org/?search=jpgc-synthesis
  • https://jmeter-plugins.org/?search=jpgc-filterresults
  • https://jmeter-plugins.org/?search=jpgc-cmd
  • https://jmeter-plugins.org/?search=jpgc-graphs-basic
  • https://jmeter-plugins.org/?search=jpgc-graphs-additional




Some basic things to consider


  • Make sure there is no space in JMeter path. The path(C:\Users\user\Downloads\apache-jmeter-3.0\apache-jmeter-3.0\bin) is a valid path
  • The working directory for this script is "jmeter\lib" and not "jmeter\bin". Hence, the result directory will be created into "jmeter\lib\"


Script Location


Please use the below link to download the script


Steps to execute


  • Double Click on bin/Jmeter.bat.
  • Open the script in jmeter.
  • Enter the result file path in "Config Settings".
  • Enter time in seconds for steady state (Start offset and End offset)
  • Click on the green button to execute the script.
  • The result file will be created in jmeter\lib

Since, I have used "tearDown Thread Group" to create this script, you can also combine this script with your test script and enter the same JTL file path in both test script summary report and result creation config settings. 


Next, click on the Test Plan and tick " Run tearDown Thread Groups after shutdown of main threads".In this way, the "tearDown Thread Group" will be executed after your load test completion and you will have the results ready in Jmeter\lib directory.

Result file

  • The Result file will be created in the Jmeter/lib directory. The name format for the result file would be Result_currentdateTime. e.g 'Results_01_043_201794309'
  • The result file contains result data for both Overall and steady state duration. Please go through the below screenshots

  



If you have any issues in downloading/accessing the script link, please email me at rahul225sharma@gmail.com. Would be happy to send you. :)

Saturday 2 September 2017

Upload a file via PUT request using Jmeter

If you are unable to upload a file via PUT request using Jmeter, then you are on the right Page.


For PUT request, the Jmeter does not provide option “Use multipart/form-data”. It is disabled. 



Solution:-
Launch wireshark
Execute the PUT request from the browser and capture it in wireshark.


Open Jmeter and add an HTTP sampler. Change the Method to PUT and add server Name, Protocol. See the highlighted items in the below screenshot.


Now, you need to create the same body for this request as you can see in the below wireshark screenshot. Start from line starting with “First boundary” and end till line starting with “Last boundary”. Please see the sample data below. I have removed all the extra fields from the body. Also, here “\r\n” means “new line”. Please take care of “\r\n”. See my final Jmeter request.

The below screenshot shows the ‘header’ that you need to add into the header manager (This should be the child of the HTTP sampler).

Finally, please see below the actual request in Jmeter.

Jmeter Request


Header Manager


Result – View results tree


The file that you want to upload should be present in the Jmeter/bin directory. If the location of the file is different, then you have to provide the full path in the request body.