Jenkins integrates Jmeter for automated testing

1. Jenkins introduction

There are many introductions to Jenkins on the Internet, here is only a brief introduction

1.1 Introduction

Official website: https://www.jenkins.io/
Introduction: https://www.cnblogs.com/iread9527/p/14433601.html

1.2 deployment

Jenkins can be deployed on tomcat very conveniently using the war package.
Download war package: https://get.jenkins.io/war-stable/2.401.2/jenkins.war
Download Tomcat: https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.76/bin/ apache-tomcat-9.0.76.zip
deploy war in the webapps directory under tomcat, then start tomcat directly

./bin/startup.sh 

After the startup is complete, visit the address http://192.168.0.109:8080/jenkins

1.3 configuration

When starting for the first time, Jenkins will actively prompt you to configure an administrator account. You can not configure it and let the system automatically configure it for you. After the configuration is completed, the address where the administrator password is stored will appear on the page.

  • 1. Enter the \Jenkins\secrets directory, open the initialAdminPassword file, and copy the password;
  • 2. Visit the Jenkins page, enter the administrator admin, and the password just now;
  • 3. After entering, you can change other administrator passwords;
    the next step is to install the Jenkins plug-in. It is recommended to install the plug-in recommended by jenkins. In addition, it is recommended to install the following plugins
  • 1. Role-based Authorization Strategy: role security control plug-in, which can realize project management according to roles
  • 2. Extended Choice Parameter Plugin: Extended Choice Parameter Plugin, used when parameterization starts
  • 3.Performance Plugin: performance test plug-in, supports Jmeter, JUnit, etc.
    Finally, jenkins also supports the configuration of custom environment variables, which can make some commonly used parameters into environment variables

2. Jmeter introduction

There are many introductions to Jmeter on the Internet, here we focus on the introduction of practical experience

1.1 Introduction

Official website: https://jmeter.apache.org/
Download: https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.zip
Chinese manual: https://www.renrendoc.com/paper /232238448.html

1.2 Precautions for use

  • Use "HTTP request default value" to realize unified management of http request addresses
  • Practical "HTTP Information Header Manager" to realize http information header management
  • Reasonable and practical controllers, especially Loop, IF controllers
  • Learn and be proficient in the preparation of beanshell
  • Jmeter supports the introduction of third-party packages, just copy them to the jmeter/lib directory
  • Practical parameter -J, realize dynamic variable introduction
  • Practical assertion to determine whether the test is successful

1.3 Execution machine environment preparation

According to the operation requirements, the execution machine needs to install the following environment, note that the python environment must be version 3 or above

pip install virtualenv
pip install bzt

3. Jenkins integrates Jmeter

After installing the corresponding plug-ins in jenkins, you can realize the integration of jmeter, which can be completed according to the following steps (list the most core parameters)

3.1 Run jmeter and generate results

insert image description here

3.2 Analysis results

insert image description here

3.3 Results reporting

insert image description here

3.4 run

insert image description here

Results view

insert image description here

4. Run the screenshot

insert image description here
insert image description here

Summarize

  • Generally speaking, jenkins and jmeter are relatively simple to use, and there are a lot of corresponding information on the Internet
  • After the pre-configuration is completed, most of the work is jmeter
  • When using Jmeter, you should pay more attention to the learning and use of beanshell, especially suitable for complex business logic testing tasks
  • For the use of jenkins, please use it in conjunction with the Role-based Authorization Strategy plug-in to achieve role management for different projects
  • In addition to the test integration mentioned above, jenkins can also do other CI tasks, such as compilation, release, etc., which focuses on the learning of the shell
  • Both jenkins and jmeter support distributed deployment, which you can explore by yourself

Guess you like

Origin blog.csdn.net/whg1016/article/details/131488884