[Performance testing] Ideas for building Jenkins+Ant+Jmeter automation framework


Preface The application and extension of Jmeter in performance testing were mentioned earlier . With the deepening of the test, we found that there will be a lot of repetitive work in the performance test. For example, an emerging business is on the rise, and it is necessary to perform performance tests on some new interfaces in each version, and sometimes it is necessary to perform performance tests at different times of the day. If manual triggering is blindly adopted, when the interface When the number is large, there will be a lot of duplication of work. At this time, we should think about whether there is a way to run the designed Jmeter script regularly and in batches, and automatically output the test report. The following combines Jenkins+Ant+Jmeter to introduce a method of building a performance test automation framework.

Ideas for building an automation framework
Ideas: Jmeter can do interface testing and stress testing, and it is open source software; Ant is a Java-based construction tool that can cross platforms; Jenkins is a continuous integration tool. Combining these three can build a set of continuous construction environment for Web HTTP interface performance testing, and realize the automation of performance testing. Construction steps: 1. Install Ant on the Jmeter host, Ant is used to build, build Jmeter execution, report generation and other tasks; 2. Schedule Ant through Jenkins to build tests. After the test is executed, call Ant through Jenkins to generate a report. These two steps will be described separately below.

JMeter+Ant integration
1. Introduction of Apache Ant Apache Ant is an automation tool provided by the Apache Software Foundation to link software compilation, testing, deployment and other steps together. It is developed by Java language, so it supports cross-platform. 2. Features of Apache Ant

Ant is the most complete build and deployment tool based on the Java language;
the Apache Ant build is defined through an XML file, and Ant parses the XML file and calls the target tree to perform various tasks;
Ant is good at automatically completing repetitive tasks;
3 , Apache Ant build test plan Apache Ant installation and environment configuration you can Google by yourself, so I won't go into details here. The build method is as follows. Step 1: Build a Jmeter test plan.

Step 2: Copy the ant-jmeter-1.1.1.jar file in the /apache-jmeter-5.1.1/extras directory to the /apache-ant-1.9.14/lib directory where Ant is located. Step 3: Modify the configuration file of Jmeter. (1) Reason for modification:

The Jmeter execution result file is not saved in xml format by default and cannot be converted into html format;
a lot of data in the Jmeter execution result file is not saved, but we need to reflect it in the test report;
(2) Configuration file path: /apache-jmeter-5.1. 1/bin/jmeter.properties (3) The modification method is shown in the figure below:

 Step 4: Modify the configuration file build.xml in Ant. Ant uses xml format to build build files, and the default name is build.xml. The original build.xml file path is: /apache-jmeter-5.1.1/extras. After the modification is complete, put the build.xml file and the Jmeter script under the same path. The modification method is as follows:

 4. Execute Jmeter scripts in batches, enter the jmx script directory, and execute Ant. Enter the reports directory to view the generated test report :

Jenkins+Ant
1. Build Jenkins The installation and configuration of Jenkins can be Googled by yourself. The following steps are how Jenkins schedules Ant for construction. Step 1: Download the required plug-ins. For example: Performance plugin, HTML Publisher plugin, Ant Plugin, etc. Step 2: Add Jmeter plugins to the configuration: Performance plugin, HTML Publisher plugin. Function: Display Jmeter execution results.

 

 Step 3:  Add the Ant plugin to the configuration: Ant Plugin. Function: used to execute Ant

 2. Modify the build.xml file and modify the build.xml file to generate the jtl and html file directories to the Jenkins working directory

 3. Project construction Configure the above files and directories, click Build Now, you can call Ant to automatically execute the Jmeter script

 performance test results

Enter the html directory to view the generated test report. It can be seen that the number of samples, error rate, maximum and minimum response time are given in the report, and the specific situation of the error request is given, so as to have a general understanding of the performance of the interface.

 

 conclusion

Of course, the currently used report template does not include QPS, and there are few performance result charts. You can expand the content and format of the output report by modifying the build.xml file. At the same time, you can configure scheduled automatic execution and automatic report email sending in Jenkins, which is a greatly expanded tool.

Guess you like

Origin blog.csdn.net/2301_76643199/article/details/131086982