01. Install jmeter on the machine
Download : http://jmeter.apache.org/download_jmeter.cgi _
Here I use a Windows installation jmeter to write interface test scripts, and modify the value of jmeter.save.saveservice.output_format in jmeter.properties to xml before starting.
Write an interface test script:
The script test.jmx is saved.
Another centos machine also downloads and installs jmeter.
mkdir -p /usr/local/jmeter , download the compressed package ending with tgz and decompress it to this directory, create log, script (the interface test script test.jmx is stored in this directory)
vim apache-jmeter-5.1.1/bin/jmeter.properties
Modify the value of jmeter.save.saveservice.output_format in jmeter.properties to xml:
02. Jenkins configuration
1. Install the plug-in
Performance Plugin is used to display test results
add post-build step select the execution shell:
Run the test script using non-GUI mode:
-
-n : non-GUI mode -> run JMeter in non-GUI mode
-
-t : test file -> JMeter test script file to run
-
-l : log file -> file to record results
-
-e : After the test, generate a test report
-
-o : Specify the storage location of the test report
Script text:
rm -rf /usr/local/jmeter/log/*
rm -rf /usr/local/jmeter/html/*
rm -rf ${WORKSPACE}/test.jtl
/usr/local/jmeter/apache-jmeter-5.1.1/bin/jmeter.sh -n -t /usr/local/jmeter/script/test.jmx -l test.jtl -j /usr/local/jmeter/log/test.log
After the script is executed, if the unit test fails, you can use the shell script to terminate the build and continue execution:
Script text:
Post-build action options:
Generate a test result report.
2, publish performance test result report placement:
Workspace:
When the test script is executed, there are cases where it fails:
log:
The results are displayed in Jenkins:
The use case executes successfully:
Finally, I would like to thank everyone who has read my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, you can take it away if you need it:
These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey, and I hope it can help you! Partners can click the small card below to receive