A Locust-based project designed to perform load and stress testing on the Swagger Petstore API. This project simulates concurrent users interacting with API endpoints, measuring the system's performance and responsiveness.
- API Endpoint: Swagger Petstore
- Version: v2
- Focus: User management endpoints, including creating, updating, retrieving, and deleting users.
- Performance testing for CRUD operations on user data.
- Simulates API requests to:
- Create User –
POST /v2/user
- Update User –
PUT /v2/user/<username>
- Get User Info –
GET /v2/user/<username>
- Delete User –
DELETE /v2/user/<username>
- Create User –
- Tracks response time, failure rates, and throughput metrics.
locust-petstore-performance-testing/
├── UserTest.py # Locust task definitions
├── requirements.txt # Python dependencies
├── README.md # Project documentation
└── reports/ # Test reports and CSV files
├── report_1735264922.html
├── failures_1735265107.csv
├── exceptions_1735265110.csv
└── requests_1735265102.csv
-
Clone the Repository
git clone https://github.com/cihat-kose/locust-petstore-performance-testing.git cd locust-petstore-performance-testing
-
Install Dependencies
Ensure Python 3.8+ is installed.pip install -r requirements.txt
-
Verify Locust Installation
locust --version
-
Start Locust
locust -f UserTest.py
-
Access Locust Web Interface
Open http://localhost:8089 in your browser. -
Configure Test Parameters
- Set the number of users and spawn rate.
- Click Start Swarming to begin the test.
- Endpoint:
POST /v2/user
- Example Payload:
{ "id": 249897, "username": "testuser", "firstName": "Test", "lastName": "User", "email": "testuser@gmail.com", "password": "12345678", "phone": "1234567890", "userStatus": 0 }
- Endpoint:
PUT /v2/user/testuser
- Example Payload:
{ "firstName": "Updated", "lastName": "User" }
- Endpoint:
GET /v2/user/testuser
- Endpoint:
DELETE /v2/user/testuser
After executing tests, results can be found in the reports/
directory. The Locust web interface also provides real-time data:
- Requests per second (RPS)
- Response time distribution
- Failures and exceptions
This project is licensed under the MIT License. See the LICENSE file for details.
If you encounter any issues, please open an issue in this repository.