https://github.com/cihat-kose/locust-petstore-performance-testing
A Locust project for load testing the Swagger Petstore API, simulating concurrent user interactions to measure system performance under heavy load. Target API: Swagger Petstore (petstore.swagger.io)
https://github.com/cihat-kose/locust-petstore-performance-testing
api-testing load-testing locust locust-tests performance-testing python rest-api
Last synced: about 1 month ago
JSON representation
A Locust project for load testing the Swagger Petstore API, simulating concurrent user interactions to measure system performance under heavy load. Target API: Swagger Petstore (petstore.swagger.io)
- Host: GitHub
- URL: https://github.com/cihat-kose/locust-petstore-performance-testing
- Owner: cihat-kose
- License: mit
- Created: 2024-11-29T22:24:39.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-07-31T18:18:37.000Z (11 months ago)
- Last Synced: 2025-08-30T08:47:16.026Z (10 months ago)
- Topics: api-testing, load-testing, locust, locust-tests, performance-testing, python, rest-api
- Language: Python
- Homepage: https://petstore.swagger.io
- Size: 276 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Locust Petstore Performance Testing


A Locust-based project designed to perform load and stress testing on the [Swagger Petstore API](https://petstore.swagger.io). This project simulates concurrent users interacting with API endpoints, measuring the system's performance and responsiveness.
---
## 🌐 Target API
- **API Endpoint**: [Swagger Petstore](https://petstore.swagger.io)
- **Version**: v2
- **Focus**: User management endpoints, including creating, updating, retrieving, and deleting users.
---
## 🚀 Features
- Performance testing for CRUD operations on user data.
- Simulates API requests to:
- **Create User** – `POST /v2/user`
- **Update User** – `PUT /v2/user/`
- **Get User Info** – `GET /v2/user/`
- **Delete User** – `DELETE /v2/user/`
- Tracks response time, failure rates, and throughput metrics.
---
## 💂️ Project Structure
```
locust-petstore-performance-testing/
├── locustfile.py # Locust task definitions
├── requirements.txt # Python dependencies
└── README.md # Project documentation
# Generated after running tests
reports/
```
---
## 🛠️ Installation
1. **Clone the Repository**
```bash
git clone https://github.com/cihat-kose/locust-petstore-performance-testing.git
cd locust-petstore-performance-testing
```
2. **Install Dependencies**
Ensure Python 3.8+ is installed.
```bash
pip install -r requirements.txt
```
3. **Verify Locust Installation**
```bash
locust --version
```
---
## ⚙️ Usage
### Running the Locust Test
1. **Start Locust**
```bash
# optional: customise target host and username
export TARGET_HOST=https://petstore.swagger.io
export TEST_USER=myuser
locust -f locustfile.py
```
2. **Access Locust Web Interface**
Open [http://localhost:8089](http://localhost:8089) in your browser.
3. **Configure Test Parameters**
- Set the number of users and spawn rate.
- Click **Start Swarming** to begin the test.
---
## 🔍 Example API Tasks
### 1. **Create User**
- Endpoint: `POST /v2/user`
- Example Payload:
```json
{
"id": 249897,
"username": "testuser",
"firstName": "Test",
"lastName": "User",
"email": "testuser@gmail.com",
"password": "12345678",
"phone": "1234567890",
"userStatus": 0
}
```
---
### 2. **Update User**
- Endpoint: `PUT /v2/user/testuser`
- Example Payload:
```json
{
"firstName": "Updated",
"lastName": "User"
}
```
---
### 3. **Retrieve User Info**
- Endpoint: `GET /v2/user/testuser`
---
### 4. **Delete User**
- Endpoint: `DELETE /v2/user/testuser`
---
## 📊 Results and Reports
After executing tests, results are stored in the `reports/` directory (which is generated automatically). The Locust web interface also provides real-time metrics:
- **Requests per second (RPS)**
- **Response time distribution**
- **Failures and exceptions**
---
## 📉 License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
---
## ❓ Contact
If you encounter any issues, please open an issue in this repository.