Integration of Jenkins with JMeter

Integration of Jenkins with JMeter

2018 / 2 / 12

Load Testing, Performance testing, Best Practices, JMeter

Continuous Integration (CI) is an essential part of the software development lifecycle (SDLC) as it automates software build, testing, and deployment processes, and performance monitoring is a key part of CI. Implementing CI helps in:

  • Monitor source code repositories.
  • Run builds whenever code changes are detected.
  • Run tests against compiled software (unit, acceptance, automated, performance, integration).
  • Generate artifacts (binaries, documentation, installation packages).

Adding testing in CI process helps in reducing performance issues before and after adding (or) making changes in code builds of your software application. As main motto of CI process is to detect any integration related issues as early as possible. Now, let's consider Jenkins as Continuous Integration tool and JMeter tool for load testing.

Download and Install Jenkins:

  • Download latest release of Jenkins (download .war file).
  • Now run Jenkins as java - jar jenkins.war (give path of jenkins.war file). You can find "Jenkins is fully up and running" message.
  • integration of jenkins with jemter
    integration of jenkins with jemter
  • Open your web browser and give http://localhost:8080 URL.
  • You can find this page asking to enter the password to unlock.
  • integration of jenkins with jemter
  • Go to secrets folder which will be in .jenkins folder in your system and open initialAdminPassword and copy the password which was present.
  • integration of jenkins with jemter
  • Paste the password in the browser and say continue
  • integration of jenkins with jemter
  • After on click Continue , you can a find that its asking for suggested plugins or select your plugins to integrate choose accordingly.
  • After the plugins got installed, it will ask to create an Admin User. You can select either continue as Admin (or) Save and continue .
  • integration of jenkins with jemter
  • Great! your Jenkins setup is done. And, it is ready.
  • integration of jenkins with jemter
  • You will find Jenkins dashboard as below:
  • integration of jenkins with jemter

After completing the above setup we will see now how to setup JMeter with Jenkins for performing a load test.

Download and Install Jenkins:

  • We need Performance Plugin (download the latest release) to get JMeter support.
  • integration of jenkins with jemter
  • Copy the downloaded performance.hpi file to plugins of .jenkins folder.
  • integration of jenkins with jemter
  • Now Restart the Jenkins to pick up this plugin.
  • Now you can find Publish Performance Test Result Report option under Jenkins >> Your Project >> Configure >> Add post-build action from dropdown .
  • As Publish Performance Test Result Report generates the average, median and 90 percentile values along with the errors count of each build. Also it compares the build with the previous builds.
  • If your latest build inadvertently causes response times to go above an acceptable threshold or SLA, your CI system will automatically raise a 'red flag' and mark the build as 'failed' . This helps in finding out the cause of the problem.
  • integration of jenkins with jemter

JMeter test with Jenkins:

  • After setting up the entire above configuration, now we will start a JMeter test with Jenkins. We need Non-GUI mode to run test.
  • Before starting the test go to user.properties and set jmeter.save.saveservice.output_format=xml or you send it through command line arguments as -Jjmeter.save.saveservice.output_format=xml
  • Now go to your Jenkins dashboard and select New Item and name it accordingly. And select the project type from the below list and click OK .
  • integration of jenkins with jemter
  • After clicking OK, we can see the configuration page of the build item as below:
  • integration of jenkins with jemter
  • Configure all steps required for your project accordingly and in Post Steps >> Add post-build action; select Execute Windows batch command .
  • And pass command line arguments as path to apache jmeter - bin\jmeter.bat -Jjmeter.save.saveservice.output_format=xml -n -t SampleTest.jmx -l test1.jtl to start the JMeter test..
  • integration of jenkins with jemter
  • Now we will use the Performance Plugin to get the statistics of the build go to Post-build Actions >> Add post-build action >> Publish Performance test result report and give the .jtl file name and save it.
  • integration of jenkins with jemter
  • We can find the project has created and select Build Now to start the test.
  • integration of jenkins with jemter
  • To check the execution of the test go to Console Output of the build you can see the summary report of your JMeter test. And you can find log and .jtl results file under your project.
  • Also Jenkins allows you to build parameters for your JMeter test by selecting This project is parameterised check box.
  • integration of jenkins with jemter

Now you have automated the performance testing, you can spend more time on improving your software instead of struggling with identifying performance problems.

You might also like