I have to say: “I am a big fan of automation”, so I am happy to see that more and more projects integrate continuous integration solutions to check if commits are correct and unit tests are running. In my on-going mission to automate everything (that is meaningful to automate) I usually don’t stop at continuous integration, but want to automate the release and deploy process as well, continuous delivery here we come.

But as I am also a big fan of application performance, automation does not stop here either. Just think about it, you already have everything automated: your application is working and already deployed and running on your testing environment. You already have testing for functional correctness, but what about non-functional correctness. The road is clear for loadtests as well. Perhaps not the full-fledged “let’s see what this system can do” loadtest (a.k.a. stresstest), but why not execute a meaningful loadtest automatically.

In this post I will show how one can easily integrate jmeter (http://jmeter.apache.org) loadtests with Jenkins.

Step 1: Automate loadtest tool and scripts deployment

In order to automate your loadtest you should also automate the deploy of the loadtesting tool and all necessary files to run the loadtest (scripts, datapools, …). Just a few pointers: The loadtest script and data belongs to the project like the junit tests do as well, so keep them in the configuration management with the project. If you use jmeter as loadtesting tool you can easily just download it on-demand if it is not yet available on the test environment. If you can get your hands on a server in your organisation where you can put the file, even better. At NovaTec we use a simple FTP server.

Step 2: Automate the execution of your JMeter loadtest

As you are automating the execution of your loadtest, you want to start jMeter in non-gui mode. You can easily do that in multiple ways. The easiest way is simply to execute the jmeter startscript

To automate this execution you can simply integrate this call in your favorite build tool. I love Ant, so here is an example of how you can integrate that in ANT

If you want to execute the loadtest from the machine that executes the continuous integration, that is you want to make your Jenkins server the load driver, then you might want to use an ANT task for JMeter directly (check  http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php for more information)

Step 3: Ensure output format is XML

JMeter results can be formatted as csv or xml file. All reporting tools operate only on xml formats of the jmeter results. Thus you should ensure that you force jmeter to provide the result as xml. Ensure the JMeter property jmeter.save.saveservice.output_format is set to xml (you can define this in the jmeter.properties file). If you forget this step you might encounter errors like “Error! Content is not allowed in prolog.” when generating the report.

Step 4: Integrate in Jenkins

Jenkins already provides the great “Performance” plugin (https://wiki.jenkins-ci.org/display/JENKINS/Performance+Plugin) for reporting JMeter results. Simply activate this plugin (it comes out of the box). I execute loadtests on the weekend, as nobody is working and the hardware is just idling, so this is the perfect time to run a longer loadtest.

jmeter performance report

I set the build to fail as soon as 40% of the tests fail. Jenkins now automatically builds a performance trend of your application

jenkins-automated-loadtesting

 

Conclusion

Automating the execution of non-functional tests is the next logical step to continuous integration. In order to further improve you loadtest you might want to think about additional files that jenkins can tranfer from the testing environment and archive with the job. Thus you have all information available by looking at Jenkins and do not need to connect to the testing environment.

 

 

Leave a Comment

3 comments

  1. B

    Useful article, thanks! I would like to know about content of JMX file. I should remove all listener and leave only Aggregate Report listener to generate jtl file? There is also Jenkins Load testing plugin where all processes run on-demand, including visualizing results.

  2. m

    I am new to Jenkins, please share step by step procedure to integrate jmeter plugin to Jenkins. following is the mail id madhu.anilreddy@gmail.com

  3. M

    Thanks a lot for the article. I try to run jmeter(ver.2.11) from Jenkins om Windows 7.
    I have got .jtl file from run >java -jar ApacheJMeter.jar -n -t C:\Tools\apache-jmeter-2.11\My_Tests\Test_Plan_Users_2_To_31.jmx -l /reports/2-31_login_test_result.jtl.
    I have install performance plugin to Jenkins, but any script didn’t work.
    Would you like to send me step by step procedure to run jmeter script from Jenkins?
    my e-mail: mymfinkel@gmail.com

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close