Skip to content

Commit

Permalink
improve load-testing documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
samonaisi committed Nov 26, 2024
1 parent aff2aa1 commit f6d7776
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
54 changes: 54 additions & 0 deletions load-testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Load-testing for projects backend

## Setup

Open a shell in the load-testing directory and execute the following actions:

### Create a virtual environment

```bash
python3 -m venv .venv
```

### Activate the virtual environment

```bash
source .venv/bin/activate
```

### Install the required packages

```bash
pip install -r requirements.txt
```

## Configuration

- Choose the host and the number of users in the `locust.conf` file.
- Choose the tested endpoints in the `locustfile.py` file.


## Usage

### Retrieve the token

You need the client secret for the `projects-frontend-dev` Keycloak client.

Run the followin command :
```bash
CLIENT_SECRET=${CLIENT_SECRET} locust
```
Then click on the output link, this will open a browser window. This will redirect you instantly. Copy the url you have been redirected to, paste it in the terminal, and press enter.

You can now copy the token that has been displayed in the browser window (don't forget the equal signs at the end).

### Start locust using the token

Run the following command :
```bash
CLIENT_SECRET=${CLIENT_SECRET} TOKEN="${TOKEN}" locust
```

Then click on the link displayed in the terminal to open the locust web interface.

You can now run the tests.
3 changes: 2 additions & 1 deletion load-testing/locust.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
host = https://api-ref.projects.k8s.lp-i.dev
# host = https://api-ref.projects.k8s.lp-i.dev
host = "https://cri.projects.k8s.lp-i.dev"
users = 5
spawn-rate = 1
run-time = 10m
2 changes: 1 addition & 1 deletion load-testing/locustfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import os

from locust import HttpUser, task
from locust import HttpUser, task # type: ignore
from requests_oauthlib import OAuth2Session

client_id = "projects-frontend-dev"
Expand Down

0 comments on commit f6d7776

Please sign in to comment.