Skip to content

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)

License

Notifications You must be signed in to change notification settings

cihat-kose/locust-petstore-performance-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Locust Petstore Performance Testing

Locust Python

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.


🌐 Target API

  • API Endpoint: Swagger Petstore
  • 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 UserPOST /v2/user
    • Update UserPUT /v2/user/<username>
    • Get User InfoGET /v2/user/<username>
    • Delete UserDELETE /v2/user/<username>
  • Tracks response time, failure rates, and throughput metrics.

💂️ Project Structure

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

🛠️ Installation

  1. Clone the Repository

    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.

    pip install -r requirements.txt
  3. Verify Locust Installation

    locust --version

⚙️ Usage

Running the Locust Test

  1. Start Locust

    locust -f UserTest.py
  2. Access Locust Web Interface
    Open 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:
    {
      "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:
    {
      "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 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

📂 Example Reports


📉 License

This project is licensed under the MIT License. See the LICENSE file for details.


❓ Contact

If you encounter any issues, please open an issue in this repository.

About

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)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published