InfoQ

News

Hands-off Load Testing with JMeter and Ant

Posted by Alexander Olaru on Apr 18, 2008

Community
Java
Topics
Software Testing ,
Performance & Scalability
Tags
Ant ,
CruiseControl

Paul Duvall, CTO, Stelligent Inc. describes in the "Automation for the people" series, how JMeter and Ant can be integrated with a continuous integration server to allow developers to quickly determine the behavior of the developed system under certain load conditions and adapt to changes. Duvall starts by enumerating some of the metrics that can be measured by these tests:

  • How many concurrent users can access your software system?
  • How much data can be loaded without performance degradation?
  • What are your system's throughput requirements?
  • How often are these requirements tested?
  • What if you could specify and validate that these load and performance requirements are being met at least once a day?

Duvall adds that the automated tests scheduled by a CI server can be run at those times during the day when machine usage is lower as well as allow to "reduce bottlenecks and errors that can occur when you depend on a single person to configure and run the tests". He describes the main steps needed to setup such an environment:

1. Run JMeter and Create a Test Plan.    An Apache project, JMeter is a Java tool designed to load test functional behavior and measure performance. It provides both GUI and command-line invocation facilities and allows the execution of various load tests which can be defined by using a test plan. Sample test plans include Web test plans, FTP test plans, Web service test plans, etc.  These test plans can be setup through a GUI interface and then saved in an XML format. This accommodates the parameterization of configuration values in order to customize the way the tests are run.

2. Drive JMeter Tests with Ant

Define a JMeter Ant task, based on a implementation already written, ie: "<taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>".  Then run a JMeter load test from Ant. Duvall provided an setup example for a test defined in the BreweryTestPlan.jmx file (the XML representation of the test plan):

<jmeter
  jmeterhome="${jmeter.home}"
  resultlog="${basedir}/target/JMeterResults.xml">
  <testplans includes="BreweryTestPlan.jmx" dir="${basedir}/tests/load">
  </testplans>
</jmeter>

3. Render test results reports using XSLT AND HTML.  He then presents how the output of the test execution - "JMeterResults.xml" - can be transformed into an HTML report using an XSLT script provided in the JMeter extras directory. The generated report displays each of the load tests run, along with test status, time, and aggregate status and time of all of the tests.

4. Customize JMeter tests. The way tests are run can be customized through the use of parameters and proprieties. In order to adapt the tests to a specific environment (e.g. testing or staging), tokens can be placed in the .jmx file and later on filtered and modified before the tests are run against a specific environment. Duvall demonstrated an example of how to increase the JVM memory and specify the number of threads and loops.

5. Integrate JMeter tests within a CI environment. Duvall provided an example of integration with the Continuous Integration server CruiseControl to schedule a build to run on a daily basis at 11PM:
...
<modificationset>
  <svn repositorylocation="${svnrepo.location}">
  <timebuild time="2300"/>
...
  </svn>
</modificationset>

JMeter test results reports can then be made available from the CruiseControl project dashboard by adding a few lines to CruiseControl's config.xml file. 

Continuous performance has also been covered by Kirk Pepperdine's InfoQ article Iterative, Automated and Continuous Performance, and also Steve Haines'  continuous performance management presentation (PPT downloadable).

No comments

Watch Thread Reply

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.