CI/CD Testing with JMeter

In this post, we’ll talk about how to do a performance test in CI/CD environment with the use of JMeter.

Usually, JMeter can run in two different modes: GUI, and non-GUI. The importance of the non-GUI mode is it will allow running the test with minimum resources. For CI/CD test we use this non-GUI mode. For this example, I’m using Jenkins as the CI tool.

First of all, you need to install and start Jenkins in your CI environment.

Install Performance Plugin

  • Click on ‘Manage Plugins’

Screen Shot 2018-05-30 at 3.47.09 PM

  • Search ”Performance” in ‘Available’ tab

Screen Shot 2018-05-30 at 3.47.48 PM

  • Click on ‘Download now and install after restart’ button

Create a Jenkins Project

  • Click ‘New Item’
    Create the ‘Freestyle project’ and click ‘OK’

Screen Shot 2018-05-30 at 3.44.39 PM.png

  • ‘Add build step’ according to your environment (eg: ‘Execute Windows batch command’ for Windows & ‘Execute shell’ for mac/Linux)

Screen Shot 2018-05-31 at 2.28.32 PM.png

  • For the command space, add JMeter run command in non-GUI mode.Screen Shot 2018-05-30 at 3.46.10 PM.png


<JMeter_location>/bin/ -n -t <JMX_Location>/<JMXFile>.jmx -l results.jtl


/Applications/apache-jmeter-4.0/bin/ -n -t /Users/deranthika/JMeterAPI/APITest.jmx -l results.jtl

-n : Non-GUI mode – this specifies JMeter is to run in non-GUI mode

-t : JMX file – location of the test plan and the name of JMX file that contains the Test Plan

-l : log file name of JTL file to log sample results to

  • ‘Add post-build action’ and select ‘Publish Performance test result report’

Screen Shot 2018-05-31 at 2.57.37 PM.png

  • For the source data file provide .jtl file name (eg: results.jtl)

Screen Shot 2018-05-30 at 4.06.49 PM.png

  • Click on ‘Save’

Build and View Graph

  • Build the project
  • You will be able to see results graph on your dashboard. NOTE: graph values will display after the second build finish.


Screen Shot 2018-05-31 at 3.04.51 PM.png

You can view graph by clicking ‘Performance Trend’ link in the left corner

Screen Shot 2018-05-31 at 3.05.00 PM.png

Screen Shot 2018-05-31 at 3.07.28 PM.png

Last Report

Screen Shot 2018-05-31 at 3.07.35 PM.png


Download Files Using JMeter

Hola Testers,

Let’s talk about how to download a file from API call using JMeter. First you have to create a JMeter project by adding Thread Group, HTTP Requests and etc. Then, add a “Save Responses to a file” Listener to the download HTTP Request

  • Right click on the HTTP Request > Add > Listener > Save Responses to a file

Screen Shot 2017-03-24 at 3.41.52 PM

And Then, you can add further inputs to the save file

Filename prefix: File will download to this location (~ sign mentioned: file will download to the location where jmeter script saves in your machine)

Screen Shot 2017-03-20 at 6.42.11 PM

After run test you can see the downloaded file in the mentioned location.

Screen Shot 2017-03-20 at 6.44.32 PM

Send SOAP Request using JMeter (2)

Hola Testers,

Today I would like to show another method for send SOAP request. In my previous post I showed with “HTTP Request”. Today, I’m going to do the same request using “SOAP/XML-RPC Request”.

1. First, add a Thread Group
2. Then add a “SOAP/XML-RPC Request” by right click on the Thread Group > Add > Sampler > SOAP/XML-RPC Request
Screen Shot 2016-04-24 at 9.09.21 PM.png

3. The SOAP/XML-RPC Request allows you to add following variables,
-URL of the WSDL
-SOAP Action
-And SOAP data
I’ve add request XML, WSDL URL and SOAP Action as below. (It depends with your SOAP request)
Screen Shot 2016-04-24 at 9.10.08 PM.png

4. Then, add a listener, save the project and run it.
You’ll be able to see the response in listener (I added “View Results Tree” listener and I can see the response in “Response data” tab of the listener)
Screen Shot 2016-04-24 at 9.10.36 PM.png

Send SOAP Request Using JMeter

SOAP (Simple Object Access Protocol) is a protocol specification for exchanging structured information the implementation of web services using XML. But how we implement this on jmeter? Yes, there are some solutions. Today I’ll show one simple way to do it.

1. Open JMeter > Add a Thread Group
2. Add a HTTP Request for the Thread Group
Screen Shot 2016-04-17 at 10.04.29 AM.png

3. Fill host, port, method and path according to your WSDL name
For example I’m using file
My variables will be,
Method: POST
Screen Shot 2016-04-19 at 10.41.57 AM

4. Select “Body Data” tab of the HTTP Request and add request URL with parameter
Screen Shot 2016-04-19 at 10.42.10 AM

5. Add a HTTP Header Manager to the Thread Group and add needed Header requests
Screen Shot 2016-04-19 at 10.42.24 AM

6. Add a Listener to get the results. I used “View Results Tree”
7. Save and Run the test. You can see response xml on “Response data” tab of the Listener
Screen Shot 2016-04-19 at 10.42.40 AM.png

Write values in CSV using JMeter

Hola Testers,

On my last post we were talking about read values from csv external data source. I thought this time we should talk about write values on csv. Imagine our jmeter script is creating some number of files in our web application, and you need to know the names of those files to use it later. In this kind of scenario, we can use csv writer to keep our files name for future use.

Add a Beanshell PostProcessor for the HTTP request which creating files
Right click on HTTP request > Add > Post Processors > Beanshell Postprocessors
Screen Shot 2016-04-10 at 8.25.09 AM.png
(You may need a regular expression extractor to HTTP Request for extract the file name.)

Write a write script to write the file name on csv
You can write a simple beanshell script to write file’s name on csv. A sample script like below,

generatedDocID = vars.get("DocID");
filepath =vars.get("FilePath");
f = new FileOutputStream(filepath, true);
p = new PrintStream(f);

Where “DocID” is the variable we used in regular expression extractor and “FilePath” is the variable name for the csv filepath/name. That variable you can initialise in user defined variables. 🙂

Read values from CSV using JMeter

Hola Testers!

What would you do if you have to test dynamic values for a specific test field. For example you have to test login for N number of users. How do you use Jmeter for that? Today I’m going to tell how to deal with that kind of situation.

For above kind of a scenario, you can use an external data source to keep your test data. Jmeter support with CSV files greatly. SO we’ll use a CSV file to demonstrate this. Let’s take a scenario. I’m taking login scenario for alfresco. So, in order to log, you need username and password. That are our test data. Let’s create test data in CSV.

CSV Test Data
In our scenario we need to store username and password in CSV. I already created 4users with admin in alfresco. Now we’ll create a CSV file.
You can create a CSV in two ways
With heading
Without heading

You can use either with heading or without heading. Then save this file as a .csv

Add CSV Configuration file to Jmeter projet
Right click on the Test Plan > Add > Config Element > CSV Data Set Config
Screen Shot 2016-04-04 at 2.01.53 PM.png

Configuration CSV Config Element
Open “CSV Data Set Config”
Filename: CSV doc path with csv filename
If you write csv with heading, this is enough
Screen Shot 2016-04-04 at 2.09.05 PM.png

If you write csv without heading, then you need to add “Variable Names” for the values with separate by comma(,)
Screen Shot 2016-04-04 at 2.10.54 PM.png

Add parameters to the HTTP request
As we set our variables as “username” and “password”, we need to replace the HTTP request’s send parameters like ${username} and ${password}
Screen Shot 2016-04-04 at 2.17.27 PM.png

Now save the project and run again 🙂


Delete Files inside a Folder using Jmeter

Hola Testers,

After a long time I’m gonna tell you how to delete files inside of folder using Jmeter. Actually sometimes we need this trick while we are removing created test data.

Step 1:
Open JMeter. Obviously, since we are using JMeter. We need to open it first

Add “User defined Variables” element
Right Click on the Test Plan > Add > Config Element > User Defined Variables
Screen Shot 2016-03-22 at 11.29.50 AM.png

Step 3:
Add user defined variable
Click on the “User Defined Variables” element
Click “Add” button
Give the folder path with a variable name.
Screen Shot 2016-03-22 at 11.33.23 AM

Step 4:
Add a Thread Group
Right click on the Test Plan > Add > Threads (Users) > Thread Group
Screen Shot 2016-03-22 at 11.35.10 AM.png

Step 5:
Add a request (I’m adding HTTP Request)
Right click on the Thread Group > Add > Sampler > HTTP Request
Screen Shot 2016-03-22 at 11.38.27 AM.png

Step 6:
Add a Beanshell PreProcessor for the Request
Right click on the HTTP Request > Add > Pre Processors > Beanshell PreProcessor
Screen Shot 2016-03-22 at 11.40.14 AM.png

Step 7:
Write a beanshell script to delete files inside of the folder (I’m deleting all the .csv files inside of “jmeterFolder” on my desktop)
Select Beanshell PreProcessor
Enter below script

List files = FileUtils.listFiles(new File("${folderPath}"), new String[]{"csv"}, true);
for (File file : files) {

${folderPath}: variable which you declare on “User Defined Variables”
Screen Shot 2016-03-22 at 11.47.19 AM.png

Step 8:
Save the script and Run.