This guide describes how to run a load-test locally (and mostly manually).
Doing this is particularly useful when testing changes to the load-test tool itself.
It's also a great way to learn how the whole load-testing process works before trying with more advanced deployments.
There are a few ways to run a load-test locally, in order of complexity:
- Run the
ltagent
command directly. - Run a load-test through the load-test agent API server.
- Run a load-test through the
coordinator
.
Before starting a new load-test, a newly created (and running) Mattermost instance with system admin credentials is required.
git clone https://github.com/mattermost/mattermost-load-test-ng
cd mattermost-load-test-ng
It's suggested to copy the required config files and edit them accordingly.
cp config/config.default.json config/config.json
cp config/simplecontroller.default.json config/simplecontroller.json
The load-test config file is documented here.
The default UserController
is the SimpleController
. Its config file is documented here.
go run ./cmd/ltagent init
Running this command will create initial teams and channels for the users to join on the target MM instance.
A new load-test can be started with the following command:
go run ./cmd/ltagent -c config/config.json -s config/simplecontroller.json -d 60
This will run a load-test with the given configs for 60 seconds.
A more advanced way to run a load-test is to use the provided load-test agent API server.
go run ./cmd/ltagent server
This will start the server and expose the HTTP API on port 4000 (default).
Using a different terminal it's possible to issue commands to create and run a load-test agent:
curl -d @config/config.json http://localhost:4000/loadagent/create?id=lt0
curl -X POST http://localhost:4000/loadagent/lt0/run
curl -X POST http://localhost:4000/loadagent/lt0/addusers?amount=10
curl -X POST http://localhost:4000/loadagent/lt0/removeusers?amount=10
curl -X POST http://localhost:4000/loadagent/lt0/stop
curl -X DELETE http://localhost:4000/loadagent/lt0
An even more advanced way to run a load-test is through the use of the coordinator
.
This is especially needed when we need to figure out the maximum number of users the target instance supports.
The coordinator
does also help running a load-test across a cluster of agents.
In order to run the coordinator
a Prometheus server needs to be running and
correctly configured for the target Mattermost instance.
The first step is having the server running.
go run ./cmd/ltagent server
Before starting the coordinator
, the default configuration file should be copied and modified accordingly.
cp config/coordinator.default.json config/coordinator.json
Its documentation can be found here.
From a different terminal we can then run the coordinator
.
go run ./cmd/ltcoordinator -c config/coordinator.json -l config/config.json
This will start running a load-test across the configured cluster of load-test agents.