Skip to content

Latest commit

 

History

History
104 lines (64 loc) · 2.9 KB

Building_locust.md

File metadata and controls

104 lines (64 loc) · 2.9 KB

Locust Tests for Stratus

This is a configuration for using a tool named Locust to do load testing against Stratus.

There's not much to locust config, but this tries to make it a little simpler for people who aren't too conversant with python.

Data

The WMS tests require a data file named wms_256_tiles.csv. This file can be generated by running mercantile_gen.py in a python environment where the python package mercantile is installed.

run_locust.sh should try to do this automatically for you if you don't have this data file already.

install_locust.sh

This bash script sets up locust inside a virtualenv for you. You shouldn't have to know anything about python and many of the recent linux distributions will work (see the source for details).

If you run it inside a virtualenv it should work with that virtualenv (subject to the limitations of what Python version that virtualenv has). Otherwise it is currently looking for a virtualenv at ~/locust_env and creating it if need be.

If Python stuff like virtualenv isn't already installed and you want the script to take care of that, run it with root permissions (sudo or in a container or whatever) because this probably requires installing distro packages.

Dockerfile

This dockerfile lets you run your locust tests from a docker container. Internally it just uses install_locust.sh and run_locust.sh.

Build the image with e.g.::

docker build -t ec_locust .

Run it with::

docker run -p 8089:8089 -it ec_locust

If you want to pass a different URL to test against, use::

URL="http://example.com"
docker run -p 8089:8089 --env URL="$URL" -it ec_locust

run_locust.sh

If you are in an environment where install_locust.sh ran (e.g. you ran it on your laptop and you are in your laptop shell, or you ran it in a docker container and you are in a shell in that container) then you can use run_locust.sh to run the Locust server, which provides a web interface on port 8089.

The script needs you to specify a URL to run against, passed either as the first argument or in an environment variable named URL. e.g.::

./run_locust.sh "https://example.com"

When the web interface is running, you can access it at::

http://127.0.0.1:8089/

If there are any obvious errors, they should show up on stdout/stderr.

If you want more detailed logging, edit run_locust.sh e.g. changing::

LOGLEVEL=CRITICAL

to::

LOGLEVEL=DEBUG

(That would give you apache-style lines for each outgoing request, at the obvious performance penalty)

Headless

Locust doesn't need to be run with the interface if you prefer to do it in batch mode.

If you want to run this headless, see locust --help, but here's an example::

env/bin/locust --no-web --clients=2 --hatch-rate=1

Distributed

If you want to run distributed tests, see locust --help and the locust manual