Installation Locust

Проверьте, что ваш Python не ниже версии 3.6 командой python -V или pyhthon3 -V

Активируйте ваше виртуальное окружение и установите locust командой

pip install locust

Изучите список установленных модулей

python3 -m pip list

Package Version ---------- --------- Package Version ---------------- --------- certifi 2020.6.20 chardet 3.0.4 click 7.1.2 ConfigArgParse 1.2.3 Flask 1.1.2 Flask-BasicAuth 0.2.0 gevent 20.9.0 geventhttpclient 1.4.4 greenlet 0.4.17 idna 2.10 itsdangerous 1.1.0 Jinja2 2.11.2 locust 1.3.1 MarkupSafe 1.1.1 msgpack 1.0.0 pip 20.2.3 psutil 5.7.3 pyzmq 19.0.2 requests 2.24.0 setuptools 50.3.1 six 1.15.0 urllib3 1.25.11 Werkzeug 1.0.1 wheel 0.35.1 zope.event 4.5.0 zope.interface 5.1.2

locust подтягивает за собой очень много, как видите, даже Flask уже здесь. Всё кроме pip, setuptools и wheel установилось вместе с locust.

Проверить куда установился locust в этом окружении можно командой

python -m pip show locust

Name: locust Version: 1.3.1 Summary: Developer friendly load testing framework Home-page: https://locust.io/ Author: None Author-email: None License: MIT Location: /home/andrei/python/virtualenvs/locust1_env/lib/python3.8/site-packages Requires: Flask-BasicAuth, msgpack, gevent, psutil, pyzmq, requests, ConfigArgParse, flask, geventhttpclient, Werkzeug Required-by:

Проверить работоспособность

Для проверки качества установки нужно сделать пробный запуск

To запустить простейший вариант теста создайте файл locustfile.py и скопируйте в него следюущий код ( источник )

import time from locust import HttpUser, task, between class QuickstartUser(HttpUser): wait_time = between(1, 2) @task def index_page(self): self.client.get("/hello") self.client.get("/world") @task(3) def view_item(self): for item_id in range(10): self.client.get(f"/item?id={item_id}", name="/item") time.sleep(1) def on_start(self): self.client.post("/login", json={"username":"foo", "password":"bar"})

Перейдите в ту же директорию где лежит файл locustfile.py и запустите командой

locust

[2020-10-27 11:33:44,124] andrei-ubuntu/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces) [2020-10-27 11:33:44,133] andrei-ubuntu/INFO/locust.main: Starting Locust 1.3.1

Если locust жалуется:

[2020-10-27 11:33:16,969] andrei-ubuntu/WARNING/locust.main: System open file limit '1024' is below minimum setting '10000'. It's not high enough for load testing, and the OS didn't allow locust to increase it by itself. See https://github.com/locustio/locust/wiki/Installation#increasing-maximum-number-of-open-files-limit for more info.

Прочитатйте решение здесь

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: