1. What is performance automation testing?

Mixer performance

△ System load capacity

△ Stability under overload operation

△ System Bottleneck

Automatic test

Use procedures instead of manual work

Improve test efficiency

◆ Performance automation

Use code to simulate mass users

△ Let users make concurrent requests

△ Multi-page multi-user concurrent request

△ Collection parameters, statistics system load capacity

△ Report generation

2. Performance automated test libraries in Python?

Locust library

Mixer using Python

Use code to create bulk users

In pieces distributed

Distributed performance testing can be performed on multiple servers

△ High scalability

◆ Stable and widely used

▷ Stand the test of various situations

△ Display test details based on web UI interface

△ Can test any system

Two, basic operation

1. Install locust

◆ Use the official PYPI source to install

pip install locustio

◆ Use Douban PYPI source to install (recommended)

pip install -i pypi.douban.com/simple locustio

After the installation is successful, a new command is displayed on the CMD console. You can enter the following command to view the command:

2. Basic usage

Create the locustFile.py file in the project root directory

Perform performance tests

After running, the console listens for a port locally

A. The program file should be named locustfile.py

B. If the name is one_example.py, run this command

locust -f one_example.py

◆ Open the UI setting interface in the browser

△ The default value is localhost:8089

3. Comprehensive case drills

1. Write automated test scripts

◆ Create test_load.py in the root directory of the project

2. Run the command line

◆ Open the Pycharm Terminal console and run the following command:

Note: the –host parameter specifies the HTTP host address, and the -f parameter specifies the pressure program file name

3. Open the Web UI for configuration

Example Set the number of concurrent users to 10 and create a user every five seconds

Screenshot of the pressure test process

Beautiful pressure report

Details of pressure test failure

Download pressure survey statistics

Download the pressure statistics CSV file

Four,

◆ LocUST pressure measurement function is extremely powerful

◆ Support distributed deployment

◆ Simple interface

Pressure test code is very easy to write

Provide a UI interface for configuration

Beautiful and detailed chart statistics