DHIS2 performance tests using locust.io
There are two options to run the tests locally - with and without Docker.
Requirements
Steps
docker compose pull
or build them with docker compose build
.TIME
, HATCH_RATE
and USERS
according to your needs):
NO_WEB=true TIME=30m HATCH_RATE=10 USERS=100 TARGET=http://localhost:8080 MASTER_HOST=master docker compose up --abort-on-container-exit
_Note that you can also omit the NO_WEB=true
environment variable, which will start the Locust master with a web UI, where you'll be able to configure the Time, Hatch Rate and Users for the tests._
Requirements
Steps
pip3 install locust --upgrade
.locust -f locust-master.py --master --master-bind-host 127.0.0.1 --master-bind-port 5557 --web-host=127.0.0.1
.target.base_uri
in locust.properties is pointing to the DHIS2 server of choice.mvn clean compile exec:java
(you can also start it from IntelliJ via the main() method).http://localhost:8089
enter you desired number of workers and spawn rate, point Host
to: 127.0.0.1
"Locust master".locust.properties is based on the performance test database, but should work with SL database as well.
Key | Default value | Description |
---|---|---|
locust.master.port | 5557 | |
locust.master.host | 127.0.0.1 | Location of the locust master |
target.base_uri | http://localhost:8080/dhis |
URL of DHIS2 instance |
user.admin.username | admin | Super user used to populate the cache and run tests |
user.admin.password | district | |
cache.reuse_cache | true | Indicates if the local cache should be reused in next test execution |
cache.users.pool.size | 40 | Indicates how many DHIS2 users should be stored in the cache. Note that users should exist in DHIS2 DB. |
cache.users.ou_levels | 5 | Used to restrict users to the organisation unit levels (comma separated list). Set lowest level ou to model data entry users. Set to 0 if ou level doesn't matter. |
cache.users.use_admin_user | false | Indicates if the admin user should be used when running the tests. If there are no users matching identifier configured in cache.users.identifier , only admin user will be used |
cache.users.identifier | uio | Identifier used to look up users. Users will be filtered by displayName property |
cache.users.password | Test1212? | Password of users loaded in the cache |
locust.min_wait | 20000 | Indicates how long should locust thread wait between the tasks. The value will be a random number of ms between min_wait and max_wait values. |
locust.max_wait | 30000 | |
cache.users.ou_level | 5 | Used in filtering users to populate the cache |
tracker.importer.async | true | Only applicable to the new tracker importer. Used as a query param in tests interacting with /tracker endpoint. |
Tests will generate data based on the database configuration, but the following assumptions are made due to limitations in data randomizer:
cache.users
)
F_VIEW_EVENT_ANALYTICS
, F_DATAVALUE_ADD
, F_TRACKER_IMPORTER_EXPERIMENTAL
(if NTI category is included)