locust-scripts contains all the scenarios to do performance testing written on Python using Locust library locust-load-shapes contains different custom load shapes for performance scenarios
Run basic scenario with GUI just typing locust
which will pick locustfile.py or by custom specifying
locust scenario:
locust -f locust-scripts/basic_user_scenario.py
Run basic scenario with custom load shape:
step load shape
locust -f locust-scripts/basic_user_scenario.py,locust-load-shapes/step_load_shape.py
Stress load shape
locust -f locust-scripts/basic_user_scenario.py,locust-load-shapes/stress_shape.py
Spike load shape
locust -f locust-scripts/basic_user_scenario.py,locust-load-shapes/spike_shape.py
Load shape
locust -f locust-scripts/basic_user_scenario.py,locust-load-shapes/load_shape.py
Soak shape
locust -f locust-scripts/basic_user_scenario.py,locust-load-shapes/soak_shape.py
python app.py
User login
curl --location --request POST 'http://127.0.0.1:5000/api/v1/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"username": "batman",
"password": "password"
}'
Response example:
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTY2MzIyNzcyNywianRpIjoiNDNiM2EzYjAtNzFiNS00NjFlLTk5YWYtNzljYzQyOTI5MGZkIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6InRlc3QiLCJuYmYiOjE2NjMyMjc3MjcsImV4cCI6MTY2MzIyODYyN30.A0OHY0qK5Tc8BDMSC5kLYhA69zme0pn08kHcoW5rmUE"
}
- go to my_user_id url with access token
curl --location --request GET 'http://127.0.0.1:5000/my_user_id' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTY2MzIyNzcyNywianRpIjoiNDNiM2EzYjAtNzFiNS00NjFlLTk5YWYtNzljYzQyOTI5MGZkIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6InRlc3QiLCJuYmYiOjE2NjMyMjc3MjcsImV4cCI6MTY2MzIyODYyN30.A0OHY0qK5Tc8BDMSC5kLYhA69zme0pn08kHcoW5rmUE'
Response example
{
"logged_in_as": "1"
}
- Get all users (public)
curl --location --request GET 'http://127.0.0.1:5000/public/api/v1/users'
Response example:
[
{
"full_name": "Bruce Wayne",
"id": 1,
"username": "batman"
},
{
"full_name": "Ann Takamaki",
"id": 2,
"username": "panther"
},
{
"full_name": "Jester Lavore",
"id": 3,
"username": "little_sapphire"
}
]