Locust is an easy to use, scriptable and scalable performance testing tool. This boilerplate is barebones for testing user behavior focused load testing. This can act as a starting point for testing api's that are unique user focused.
base_user.py
contains the barebone code for log_in, logging_response, validating_response and handling user's pool.- Extend the base_user.py to implement api for login
- Use methods postfix with hook to add or update cookies or locally store token for api calls to follow.
- Update validate_resp
is_valid_response_data
as per your api needs. - You will probably need to generate dummy users. Those will be imported into memory from file named
USER_CREDENTIALS_FILE_NAME
. This script will try to log them in withUSER_API_PASSWORD
as password. - Because locust uses the local copy of code provided to slave nodes. For distributed testing, branch your code and divide your users per machine.
- Setup virtual env
python > 3.7
pip3 install requirements.txt
- run command
locust -f locust_files/your_user.py