Automated performance testing using JMeter and Maven
Geschrieben von: George Barnett Donnerstag, den 22. Oktober 2009 um 19:20 Uhr
| Beitragsseiten |
|---|
| Automated performance testing using JMeter and Maven |
| performance test |
| JMeter tests |
| Packing Jmetertest |
| Structure for tests |
| Alle Seiten |
When I think of Agile, I tend to think of the awesomeness it can bring me as a performance engineer. I see short cycles where the code is usually always stable and features are delivered incrementally. I get to watch the performance of the system evolve over time. Unfortunately, this means I'm testing software all the time. Thats fine though - none of this is by hand - this kind of repetitive task is perfect for automation.
It's clear that automating testing is important - automated tests mean you have more time to do investigation while you make your build system do the repetitive tasks, and when your build system does the heavy lifting then it's easier to test more regularly. More regular testing means you find problems sooner and go home on time.
In this blog, I'm going to go over how to take your JMeter performance tests and put them into a Maven build which you can run on your continuous integration server as often as is needed. I'll introduce you to the Chronos Maven plugin which can control JMeter in a repeatable way and has reporting features which can be used to gain useful information about the performance test.
Prerequisites:
For this blog, you'll need the following prerequisites:
- A working knowledge of Maven
- Working JMeter Performance tests
- A Maven repository set up for retrieving artifacts and deploying new ones.
Atlassian has a well maintained Maven infrastructure - if you're just getting started, I'd suggest you read Sherali Karimov's great guide on setting up Maven infrastructure here.
The JMeter tests used in this paper are fairly complete, however this is not necessary for your first pass at getting the automation running. Its more important to get started and then improve what you have as your need more features.
When you are writing your JMeter tests, I would suggest keeping the information about the data you're going to be testing separate from the testing logic. By this, I mean keep the "flow" of your test in JMeter but use CSV files to define what URLs or options need to be used when testing. For example, instead of hardcoding a list of pages to sample rather put this into the CSV and load that into JMeter using the "CSV Dataset" controller. This way, you can change the CSV files to test a different set of pages or data in your application.
Here are the main steps I'm going to cover:
- Create a performance test Maven artefact
- Write a Maven pom.xml for the performance tests
- Package & deploy the tests to the Maven repository
- Write a Maven pom.xml to run the performance tests against an application
- Run the tests
- Automate the tests with Bamboo
George Barnett discusses performance testing inside Atlassian 
