InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Hands-off Load Testing with JMeter and Ant

Posted by Alexander Olaru on Apr 18, 2008

Sections
Development,
Architecture & Design
Topics
Java ,
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

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.

Beauty Is in the Eye of the Beholder

Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.

Architecting Visa for Massive Scale and Continuous Innovation

John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.