18
Sep
2011
Sep
2011
2
Recording test performance with Jenkins
In many (most?) systems performance is an important non-functional requirement. And even if you attained the required performance, it is useful to keep an eye on it to detect if a codechange involuntarily deteriorates it. Enter the Performance plugin for Jenkins. Using it you can record the performance (as in: speed of execution) of your test runs and set alter thresholds which cause the build to fail. Also it can generate graphs like the one below:
To do this:
- Have Jenkins installed
- Intstall the Performance plugin (or upgrade to the latest version, since there was a bug in earlier versions which prevented the parsing of the JUnit reports)
- For your build check “Publish Performance test result report” and add locations where the reports should be collected from.
- That’s it! Future builds will collect the performance data and you can access it using the “Performance Trend” link (at the job level) or the “Performance Report” link (at the build level)
More details / caveats:
- The paths are defined as ANT file expressions (that is you can use “**” to specify an arbitrary level of directories, for example:
target/surefire-reports/**/TEST*.xml
) - JUnit performance is grouped at the test-class level, thus it probably makes sense create separate project / module which group the performance test cases.
- Benchmarking is hard and JUnit doesn’t give you any provisions to do warmup or to repeat the tests multiple times. To make your test as relevant as possible you should do this manually (warmup code can be placed in the @Before method for example). A properly set up JMeter task accounts for this already.
- TestNG tests can also be parsed as long as the test run is set to produce a JUnit compatible report.
- Slightly off-topic: to integrate a JMeter run into your maven build, you can use the AntRun plugin:
<build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <phase>test</phase> <configuration> <target> <taskdef name="jmeter" classpath="C:\work\ant\lib\ant-jmeter-1.1.0.jar" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/> <jmeter jmeterhome="C:\Users\jakarta-jmeter-2.5\" testplan="${basedir}/src/test/resources/example.jmx" resultlog="${basedir}/target/JMeterResults.jtl"/> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build>