lycan: loadtester script
A simple load testing script using locust and pyyaml. The story behind this is Ko Setkyar wants to test some APIs and not-so-complex and light weight solution. I found locust but tasks are defined in python. To overcome this, I create this python wrapper which generates HttpLocust
and TaskSet
classes from yaml
file at runtime.
First, a python environment or python 3.6+ is required. To resolve this, I would like to recommend miniconda. To install miniconda, please refer to https://docs.conda.io/en/latest/miniconda.html.
- python 3.6+
Install required python libraries.
cd /path/to/lycan
# NOTE:
# To create python 3.6 environment,
# $ conda create -n <env-name> python=3.6
#
# To activate environment, if not yet.
# $ conda activate <env-name>
# Then, install required dependencies
$ pip install -r requirements.txt
First, create a yaml
file inside rules
directory.
Rule format is as follows:
name: TestThisHost
proto: http
host: localhost
port: 8000
tasks:
- endpoint: /api/v1/users/
method: POST
# To define Headers
headers:
Content-Type: application/json
...
data:
name: kyawkyaw
address: Yangon
- endpoint: /api/v1/users/1
method: GET
headers:
Content-Type: application/json
- ...
Then, run following command:
$ locust -f loadtester.py
To start load testing, please open http://localhost:8089
in browser.
Ref: https://docs.locust.io/en/stable/quickstart.html#open-up-locust-s-web-interface.