Httprunner_Locust performance test

table of Contents

1. Install the performance testing tool Locust

1.1 Check whether it is installed and execute the command

1.2 Install locust 

2. Run performance test

2.1 First try

2.2 N attempts to troubleshoot the problem until successful

3. Multi-process running mode


1. Install the performance testing tool Locust

1.1 Check whether it is installed and execute the command

 locusts -V 

As shown in the figure below, it means that it has not been installed yet

 

1.2 Install locust 

pip install locustio

After a successful installation, you will be prompted:

Run locusts -h to view the help documentation.

2. Run performance test

2.1 First try

-f can directly execute the .yml file. The execution process includes generating the corresponding py file and starting locust. During the execution process, I reported an error, but the .py file was successfully generated, and locust was successfully started.

The generated .py file

In the browser, enter http: // localhost: 8089 / , this address is given by the result printed when starting locust.

Number of users to simulate: Set the number of simulated users

Hatch rate (users spawned / second): Number of virtual users generated (started) per second
Host: interface server

Enter the corresponding information, which is 10 concurrent, adding 2 virtual users per second, host: http://127.0.0.1:5000 , click Start swarming to execute the test:

Found that the indicators are all 0, so I looked for the reason from scratch

2.2 N attempts to troubleshoot the problem until successful

1. There is an error when executing locusts: The reason why the following directory is located under the api directory is because the previously resolved path appears:

So I tried to execute get_token.yml alone, and found that it could not succeed, and error: get_sign is not found:

The debugtalk.py file cannot actually be read

2. Adjust the operation back to the root directory of the test case again and find that it still does not work. The path it recognizes is strange:

3. So the absolute path was changed to a relative path, this time finally succeeded:

Re-enter the locust interface, you can successfully perform performance tests.

It took a lot of trouble, but it still succeeded.

At this time, it is found that the path of the locustfile.py file generated previously is also incorrect. The correct location is shown in the following figure:

 

3. Multi-process running mode

执行:locusts -f testcases\get_token.yml

报:locust.main: Running teardowns...

Reason: The previous execution has not been turned off. In the command line that was run previously, close the command line window or use Ctrl + c to close the command being executed, and execute it again successfully:

Enter the locust interface again, you can see that the value of slaves is 4

Implementation process:

Published 8 original articles · won 27 · views 1500

Guess you like

Origin blog.csdn.net/niuhaoyuan/article/details/105488045