Load testing with Locust
http://locust.io

What is Locust?
- An open source load testing tool
- Write test scenarios in python code
- Distributed, can simulate millions
of simultaneous users
What Locust provides
to the developer
- A framework for simulating user behaviour
- An HTTP client (python-requests)
- A web interface that show statistics
- Ability to run your code distributed
across multiple machines
from locust import HttpLocust, TaskSet, task
class UserBehaviour(TaskSet):
@task(30)
def index_page(self):
self.client.get("/")
@task(10)
def press_page(self):
self.client.get("/press")
class WebUser(HttpLocust):
task_set = UserBehaviour
min_wait = 5 * 1000
max_wait = 60 * 1000
$ locust -f locustfile.py --host http://instagram.com
Master -Slave Mode
locust -f my_locustfile.py --master
locust -f my_locustfile.py --slave --master-host=192.168.0.14

Automation-friendly framework for Continuous Testing
-
sudo pip install bzt
- Create a Config
-
bzt test.yml
--- execution: - concurrency: 100 ramp-up: 1m hold-for: 5m scenario: quick-test scenarios: quick-test: requests: - http://blazedemo.com
--- scenarios: request_example: timeout: 10 # global scenario timeout for connecting, receiving results, 30 seconds by default think-time: 1s500ms # global scenario delay between each request default-address: http://blazedemo.com # specify a base address, so you can use short urls in requests keepalive: true # flag to use HTTP keep-alive for connections, default is true requests: - url: / method: post headers: - var1: val1 body: 'body content' assert: - contains: - blazemeter # list of search patterns - Trusted subject: body # subject for check regexp: false # treat string as regular expression, true by default not: false # inverse assertion condition
Load testing with locust
By gökhan karadaş
Load testing with locust
- 656