Construction and use of Jenkins continuous integration performance testing environment

Construction and use of Jenkins continuous integration performance testing environment

1. CENTOS7 configures JDK 8 environment

Modify the /etc/profile file and add java environment variables.

#java
export JAVA_HOME=/opt/java/jdk1.8.0_181
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin

 source /etc/profile to make the newly added environment variables take effect.

[root@pjenkins ~]# source /etc/profile 
[root@pjenkins ~]# java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

 

i. configure tomcat 8

Using tomcat 8, no installation is required, just configure the JAVA_HOME and JRE_HOME environment variables. Upload the tomcat 8.tar.gz installation package to the /app directory. After decompression, change the name to apache-tomcat-jenkins-8080-perf and start the tomcat service: sh /app/apache-tomcat-jenkins-8080-perf/ bin/startup.sh, visit http://$IP:8080, if the tomcat default page appears, the startup is successful.

ii. Configure the Jenkins service

Upload the jenkins.war package to /app/apache-tomcat-jenkins-8080-perf/webapps/, and change the original ROOT to ROOT-tomcat.bak.

Modify jenkins.war to ROOT.war. Restart the tomcat service, visit http://$IP:8080, the jenkins installation page appears, follow the steps to install.

iii. Install the Jenkins plugin

Commonly used plugins: Git plugin, Gradle plugin, HTML Publisher plugin, Maven Integration plugin, Performance Plugin, Publish Over SSH... Install by yourself.

If the network is restricted and you cannot manage the installation through the jenkins plug-in, you can use the offline package to install, or you can use the plug-in package I installed. The download link of the network disk is https://pan.baidu.com/s/10xiEjvwZHDXaqf5fIbFEvg Password: yvhq.

Unzip the plugins.tar.gz to your installation directory (usually installed in ~/.jenkins), and replace the original plugins. Restart the jenkins service to use these plugins.

3. Configure the performance test environment

A. Configure the Jmeter environment

Jmeter does not need to be installed, it needs a JDK environment, and it can be used by configuring environment variables.

Modify the /etc/profile file and add jmeter environment variables.

#jmeter environment
export JMETER_HOME=/opt/jmeter/apache-jmeter-4.0
export CLASSPATH=.:${JMETER_HOME}/lib/ext/ApacheJMeter_core.jar:${JMETER_HOME}/lib/jorphan.jar
export PATH=$PATH:${JMETER_HOME}/bin

 

source /etc/profile to make the newly added environment variables take effect. jmeter -v verify.

B. Jenkins Performance Test Project

i. Jmeter develops performance test scripts

Create a project performance-test.git on Gitub to store performance test scripts

git clone http://gitlab.weikeu.com/TestDevelopment/performance-test.git

Use jmeter for script development, and push to gitub after completion.

git status

git add .

git commit -m "loan optimization pre-loan application interface debugging"

git push

Take a simple performance test project as an example: during standardization, a filter was added to adapt to the previous interface. In order to test whether the request is affected, a pressure test is required to calculate whether the request response time is affected.

Request url after modification: http://$IP:8080/EsQuery/esquery/zj/qTdUsedPrdDetail

Request url before transformation: http://$IP:8081/EsQuery/esquery/zj/qTdUsedPrdDetail

post request message: {"productNo":"202030345"}

In the test environment of the application server 8C8G, before and after the transformation, the same interface is pressure tested with different concurrency numbers (100, 500, 1000). This test does not need to parameterize $.
In the test plan, each thread group is set to run independently, so that the next thread group starts after running, save the jmeter test script to the performanc-test/jmeter-perf/riskdatafront/ directory, and git push to gitlub.

image.png

ii. Jenkins configuration performance test project

Build a free-style software project named risk_data_front_FGGZYQ167_FGGZYQ169 (application name + jira number). The configuration items are as follows:
image.png

image.png 

Execute shell instructions:

1. Delete the html report generated by the previous build;

2. Delete the pressure test jtl file generated in the previous build;

3. cd to the directory where the jmeter startup file is located;

4. Execute the jmeter test script and generate an html test report.

For html reports, you need to execute the following statements in the Jenkins script command line to display html reports normally.

System.setProperty(“hudson.model.DirectoryBrowserSupport.CSP”, “”), this statement needs to be executed every time the server is restarted, otherwise the html report will not display the test results.

Html report settings, except for the first html report storage path to be filled in correctly, others can be entered freely. Keep past HTML reports keep the previous html test reports.

image.png

The performance test result report can be filled in as shown in the figure below.
image.png

image.png

 

iii. Build a performance test project

Click [Build Now] to view the console output. Pay special attention to the file path, otherwise an error of no permission will be reported.
image.png

Check out the html report (partial screenshot).
image.png

View the performance test result report (partial screenshot).
image.png

The above jenkins continuous integration performance testing platform is deployed 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 

Guess you like

Origin blog.csdn.net/chengxuyuznguoke/article/details/130308854