Skip to content

Add initial locustfile for load testing#380

Merged
m-goggins merged 8 commits into
mainfrom
load-testing-local
May 16, 2025
Merged

Add initial locustfile for load testing#380
m-goggins merged 8 commits into
mainfrom
load-testing-local

Conversation

@m-goggins

@m-goggins m-goggins commented May 16, 2025

Copy link
Copy Markdown
Collaborator

Description

This PR adds an initial locustfile for running load testing initially. It will need to be modified as the load testing plan develops but this gives you an idea of how load testing might work locally.

How to run the load test:
For now (eventually will make this a single script):

  1. Spin up the API locally. I used ./scripts/local_server.sh
  2. Run locust -f ./tests/load/locustfile.py --headless -u1 -r 1 --run-time 3s --host http://localhost:8000

Interpreting the output:
You will get two sets out output after the load test has completed:

  1. of requests, # fails, and time for each endpoint that is hit

  2. Approximate response time percentiles

We can save the output as a CSV for easier sharing with --csv example

Details about locustfile:

  1. The seed data is loaded: I went with loading a simple file for now, but as we increase the number of records, we may need to read in the file incrementally in case it is too large to open in memory or generate the seed data on the fly.
  2. On start, the seed data is added into the MPI: currently this runs once per user (not once per test) and will need to be fixed in future iterations. To avoid seeding multiple times, I have set the number of users to 1.
  3. Randomize the seed data: A random record from the seed data is chosen and run through record linkage by hitting the /link endpoint. In future iterations, the record will be duplicated a random number of times and randomized once I have updated expand_test_data to work with PIIRecords (ticket Refactor expand_test_data.py to accept PIIRecords #376)

Related Issues

Closes #377

Additional Notes

There are likely lots of iterations we can make on this file as we learn more about how locust works so let me know if you find something neat!

@codecov

codecov Bot commented May 16, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.51%. Comparing base (53408fc) to head (19b99f3).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #380   +/-   ##
=======================================
  Coverage   98.51%   98.51%           
=======================================
  Files          33       33           
  Lines        1948     1948           
=======================================
  Hits         1919     1919           
  Misses         29       29           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@m-goggins m-goggins marked this pull request as ready for review May 16, 2025 17:23
Comment thread src/recordlinker/assets/test_data.json
Comment thread tests/load/locustfile.py Outdated
Comment thread tests/load/locustfile.py
@m-goggins m-goggins merged commit bb812c1 into main May 16, 2025
15 checks passed
@m-goggins m-goggins deleted the load-testing-local branch May 16, 2025 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create locustfile.py for load testing

2 participants