Integrate JMeter performance tests with Azure DevOps controlled by an Azure Pipeline
This blog post describes how to integrate JMeter performance tests with Azure DevOps. Microsoft comes with hosted agents, which you can use for free. At least you can play around for free, there are some limitations:
- Public projects: each run can take max. 6 hours.
- Private projects: each run can take max. 1 hour with a limitation of 30 hours a month.
You can use your own agents to bypass these limitations.
If you like to know more about the limitations, I like to suggest you read the following website: Capabilities and limitations
You need to do a couple of things before your performance test is nicely integrated with Azure DevOps.
- First of all, the Microsoft hosted agents do not come with JMeter preinstalled. So, you need to take care of that.
- Then you want to override some of the default settings of JMeter, like the granularity.
- Finally, you want to implement clear reporting and downloadable artifacts.
Add the following code snippet to install JMeter on the Microsoft Hosted Agent. You can specify a different version if you need to.
Run script and override default settings
- script: |
wget -c https://apache.newfountain.nl//jmeter/binaries/apache-jmeter-5.4.1.tgz
tar -xf apache-jmeter-5.4.1.tgz
displayName: 'Install the dependency packages'
The following code snippet executes the JMeter script and overrides the default granularity setting.
Generate JUnit report and downloadable artifacts
- script: |
apache-jmeter-5.4.1/bin/./jmeter -Jjmeter.reportgenerator.overall_granularity=1000 -n -t test.jmx -l results/results.jtl -j results/output.log -e -o report
displayName: 'Run JMeter'
The following code snippet converts results.jtl to an JUnit output XML file. Test results will be displayed as shown in screenshot 3. The code snippet will also create downloadable artifacts from specific result directories.
- script: |
python3 jtl_junit_converter.py $JMETER_RESULTS $JUNIT_RESULTS
displayName: 'RESULTS: Convert JMeter Results to JUnit Format'
- task: PublishTestResults@2
displayName: 'RESULTS: Publish Load Testing Results'
- publish: $(System.DefaultWorkingDirectory)/results
displayName: 'RESULTS: Publish Load Test Artifacts'
- task: PublishPipelineArtifact@1
displayName: 'Publish JMeter HTML Report'
Code used in this repository is available on GitHub: Example JMeter Azure DevOps Integration