This repo contains a set of load tests that can be run against the Palace backend to simulate user load on the servers.
Please read the fair warning!
These tests are built in Python using Locust. The Locust page contains good documentation about writing tests.
Install dependencies:
poetry install
Write a configuration file, place its fully-qualified path in
the CIRCULATION_LOAD_CONFIGURATION_FILE
environment variable, and run Locust:
poetry run \
env CIRCULATION_LOAD_CONFIGURATION_FILE=$(realpath hosts.json) \
locust
The locust dashboard will then be available at: http://localhost:8089
.
Do not run this code against production servers!
Some tests involve borrowing books. Borrowing a book, on many CMs, will consume a license. This may cost money!
A good example is the bookmark tests; in order to create bookmarks, the bookmarks must be associated with a loan. The bookmark test loans a random book, adds a lot of bookmarks, and then returns the book.
The configuration file specifies the Library Registry and Circulation Manager instances against which tests will run. For the CM, a list of users (along with their passwords) must also be specified. One user must be declared as primary, as some tests will use this user as the default user for various reasons.
{
"registry": {
"host": "http://registry.example.com/"
},
"circulation_manager": {
"host": "http://cm.example.com/",
"users": {
"user0": {
"primary": "true",
"password": "abcd1234"
},
"user1": {
"password": "abcd1234"
},
"user2": {
"password": "abcd1234"
}
}
}
}
Unit tests can be executed using tox. At the time of writing, the only
available environment is py310
(which tests against Python 3.10.*):
tox -e py310