Skip to content

Latest commit

 

History

History
147 lines (94 loc) · 4.03 KB

local_loadtest.md

File metadata and controls

147 lines (94 loc) · 4.03 KB

Running a load-test locally

Introduction

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.

Prerequisites

Before starting a new load-test, a newly created (and running) Mattermost instance with system admin credentials is required.

Clone the repository

git clone https://github.com/mattermost/mattermost-load-test-ng

Enter the source directory

cd mattermost-load-test-ng

Copy and modify needed configuration files

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.

Run the initialization

go run ./cmd/ltagent init

Running this command will create initial teams and channels for the users to join on the target MM instance.

Running a basic load-test

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.

Running a load-test through the load-test agent API server

A more advanced way to run a load-test is to use the provided load-test agent API server.

Start the 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:

Create a new load-test agent

curl -d @config/config.json http://localhost:4000/loadagent/create?id=lt0

Start the load-test agent

curl -X POST http://localhost:4000/loadagent/lt0/run

Add active users

curl -X POST http://localhost:4000/loadagent/lt0/addusers?amount=10

Remove active users

curl -X POST http://localhost:4000/loadagent/lt0/removeusers?amount=10

Stop the load-test agent

curl -X POST http://localhost:4000/loadagent/lt0/stop

Destroy the load-test agent

curl -X DELETE http://localhost:4000/loadagent/lt0

Running a load-test through the coordinator

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.

Prerequisites

In order to run the coordinator a Prometheus server needs to be running and correctly configured for the target Mattermost instance.

Start the load-test agent API server

The first step is having the server running.

go run ./cmd/ltagent server

Configure the coordinator

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.

Run the coordinator

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.