Locust
| Introduction | |
| Quick Start trial run | |
| Locust articles in order |
Introduction
In this
article series
you will learn how to organize load testing in Python 3 with the Locust library.
It is assumed that you work
in
Ubuntu Linux
but that is optional.
I have aliases python - python3 and pip - pip3 set up, so I do not write the trailing 3.
The aliases article «Bash Python alias» is available at this link .
Quick Start
To run the simplest variant, create a locustfile.py file and copy the following code into it ( source )
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"})
Go to the same directory as locustfile.py and run the command
locust
Oct 27 18:53:45 andrei-ubuntu/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces) Oct 27 18:53:45 andrei-ubuntu/INFO/locust.main: Starting Locust 1.3.1
If locust complains:
Oct 27 18:53:45 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.
Read the solution here
Article author: Andrei Olegovich
| Locust | |
| Getting started with Locust | |
| Install Locust | |
| Launch options --help | |
| Locust errors | |
| Install Locust in PyCharm | |
| Software Testing | |
| REST API with Python | |
| Python | |
| Pip | |
| Flask |