Skip to content

Commit

Permalink
Upgraded Locust to version 2.31.8 for local development. Upgraded Pyt…
Browse files Browse the repository at this point in the history
…hon to 3.12. Added instructions for using pyenv.
  • Loading branch information
alfredeen committed Oct 3, 2024
1 parent dac4fbc commit a800aed
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ docs/_build/
.pybuilder/
target/

# pyenv
.python-version

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
Expand Down
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,38 @@ Make changes in the develop branch, commit and submit pull requests to merge to

## Setup for local development

### Using virtual environments with venv

cd ./source
python3 -m venv .venv
source ./.venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt

### Using pyenv

cd ./source
pyenv virtualenv 3.12.2 locust-3.12.2
pyenv local locust-3.12.2
pyenv version
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt

### Check the Locust version

locust -V

## Configuration options

To configure the test runs, use the Locust configuration file ./source/locust.conf
For options, see the [Locust docs](https://docs.locust.io/en/stable/configuration.html)

You can override all of the settings set in the configuration file by setting the same
on the command line. For example, to override the log level settings use --loglevel as in example:

locust --headless -f ./tests/test_verify_setup.py --loglevel debug


## Create tests

Create locust tests in the /source/tests directory.
Expand All @@ -45,13 +64,13 @@ Open the generated html report and verify that there are no errors and that the

Run the command

locust --config locust-ui.conf --modern-ui --class-picker -f ./tests/test_verify_setup.py --html ./reports/locust-report-verify-setup-ui.html
locust --config locust-ui.conf --class-picker -f ./tests/test_verify_setup.py --html ./reports/locust-report-verify-setup-ui.html

Open a browser tab at URL http://localhost:8089/

Paste in as host

https://staging.serve-dev.scilifelab.se
https://serve-dev.scilifelab.se

## Verify the setup and access to a host (URL)

Expand Down Expand Up @@ -80,7 +99,10 @@ Move into the source directory if not already there:
cd ./source

- Copy the template environment file .env.template as .env
- Edit the followinf values in the .env file according to your needs.

cp ./.env.template .env

- Edit the following values in the .env file according to your needs.

- SERVE_LOCUST_TEST_USER_PASS=(The password of the test locust users)
- SERVE_LOCUST_DO_CREATE_OBJECTS=(A boolean indicating whether to create objects in Serve such as projects and apps)
Expand All @@ -97,11 +119,15 @@ Use minimum 10 users for the Normal test plan

locust --headless -f ./tests/test_plan_normal.py --html ./reports/locust-report-normal.html --users 10 --run-time 30s

Or using the Web UI

locust --config locust-ui.conf --class-picker -f ./tests/test_plan_normal.py --html ./reports/locust-report-normal-ui.html --users 10 --run-time 30s


### To run the Classroom test plan/scenario

locust --headless -f ./tests/test_plan_classroom.py --html ./reports/locust-report-classroom.html --users 1 --run-time 30s


## Tests under development

These tests are not yet ready to be used in a load testing session.
Expand Down Expand Up @@ -190,7 +216,7 @@ More specifically, we use the dashboards feature or locust-plugins. See

https://github.com/SvenskaSpel/locust-plugins/tree/master/locust_plugins/dashboards

To setup locust-plugins, there is an option or use locust-compose or manually setup. We use manual setup so that the
To setup locust-plugins, there is an option to use locust-compose or manually setup. We use manual setup so that the
dashboards can always be running.

locust-plugins is integrated in the production version of this project (deployed to kubernetes using k8s manifests and a built docker image) but not used in local development. However the dashboards can be installed locally using:
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

[project]
name = "serve-load-testing"
version = "1.0.0"
version = "1.0.1"
description = "Load testing of the SciLifeLab Serve platform."
requires-python = "=3.8"
requires-python = "=3.12"
keywords = ["load testing", "locust", "python"]

[tool.isort]
profile = 'black'

[tool.black]
line-length = 120
target-version = ['py38']
target-version = ['py312']
include = '\.pyi?$'
extend-exclude = '''
/(
Expand All @@ -29,7 +29,7 @@ extend-exclude = '''

[tool.mypy]
strict = false
python_version = "3.8"
python_version = "3.12"
ignore_missing_imports = true
warn_return_any = true
exclude = ["venv", ".venv", "examples"]
Expand Down
2 changes: 1 addition & 1 deletion source/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
locust>=2.20.0
locust>=2.31.8
requests-html>=0.10.0

0 comments on commit a800aed

Please sign in to comment.