The document outlines a 7 part tutorial on using Locust for load testing. It discusses basic Locust script structure, host attributes, wait times, multiple user classes, headless mode, hooks, event listeners, task weightage, task attributes, sequential and nested task sets, GET and POST requests, cookies, tags, master/worker distribution, configuration files, and containerization with Docker for scaling workers. The document provides references to the Locust documentation and a GitHub repository for further information.
2. Locust Basics
Part 1:
Basic Locust
Sscript
Part 2:
Host attribute |
HttpUser Class
Part 3:
wait_time
- between
- constant
- constant_pacing
Part 4:
Multiple User class
Weightage Attribute
Part 5:
Headless mode
02
Part 6:
Hooks
- on_start()
- on_stop()
Part 7:
Event Listener
- @events.test_start.add_listener
- @events.test_stop.add_listener
Prashanth Sams
3. Tasks
Part 1:
Task weightage
- @task(2)
Part 2:
Task attribute
tasks = [a, b]
Task Weightage
tasks ={a:2, b:1}
Part 3:
@task inside TaskSet
Part 4:
SequentialTaskSet
Part 5:
Nested TaskSet
- SequentialTaskSet
- Task Weightage
- self.interrupt()
03
Prashanth Sams
4. Http Requests
Part 1:
GET Request
- self.client.get('/', name='A')
Part 2:
POST Request
- self.client.post('/', data='',
headers='', name='',
catch_response=True)
Part 3:
- response.success()
- response.failure(exc='')
Part 4:
Cookies
- .cookies['']
- self.client.cookies.clear()
Part 5:
@tag('')
04
Prashanth Sams
5. Distribution
Part 1:
--master
--worker
Part 2:
--master --expect-worker 2
Part 3:
--config=master.yml
locustfile, host, master,
users, headless, spawn-rate
--config=slave.yml
locustfile, host, worker
05
Prashanth Sams
Part 4:
- Docker containerization
- Scaling workers