Skip to main content

Python connector and CLI tool for uploading Locust performance

Project description

Load Testing Hub

Load Testing Hub is a Python library and CLI tool designed to upload performance testing results into the load-testing-hub-api. It provides a convenient connector for reading and transforming Locust reports and sending them to the Load Testing Hub API over HTTP.

Key Features

  • Easy integration with Locust reports (CSV/JSON).
  • Raw Python API for programmatic usage.
  • CLI support for quick uploads from configuration files (YAML or JSON).
  • Pydantic-powered configuration for strict validation and clear error messages.

Installation

pip install load-testing-hub

For development:

git clone https://github.com/Nikita-Filonov/load-testing-hub.git
cd load-testing-hub
pip install -e .

Usage

1. Python API

You can upload Locust results directly from your Python code by using the raw API:

import asyncio
from pathlib import Path

from load_testing_hub import (
    Service,
    Scenario,
    upload_locust_report,
    UploadLocustReportParams
)


# Main async function to upload Locust test results
async def main():
    await upload_locust_report(
        UploadLocustReportParams(
            # Base URL of the Load Testing Hub API
            api_url="http://localhost:8000",

            # Information about the service for which results are uploaded
            service=Service(id=1),

            # Scenario metadata (name, configuration file, version, and load parameters)
            scenario=Scenario(
                id=1,
                name="get accounts",  # Scenario name
                file="./scenarios/get_accounts/v1.0.conf",  # Path to scenario config file
                version="v1.0",  # Scenario version
                number_of_users=500,  # Number of virtual users in the test
                runtime_duration="3m"  # Test duration (3 minutes)
            ),

            # Paths to Locust report files
            csv_locust_stats_file=Path("locust_stats.csv"),  # Aggregated statistics
            json_locust_ratio_file=Path("locust_ratio.json"),  # Response time percentiles
            csv_locust_exceptions_file=Path("locust_exceptions.csv"),  # Exceptions during test
            csv_locust_stats_history_file=Path("locust_stats_history.csv"),  # Time-series stats
        )
    )


# Run the async main function
asyncio.run(main())

2. CLI Usage

The package provides a built-in CLI command for uploading reports.

Example with YAML configuration

Configuration file (./examples/locust.yaml):

# Base URL of the Load Testing Hub API
api_url: http://localhost:8000

# Information about the service for which results are uploaded
service:
  id: 1  # Unique service identifier

# Scenario metadata
scenario:
  id: 1  # Unique scenario identifier
  name: "get account"  # Scenario name (for reference in the UI or reports)
  file: "./scenarios/get_accounts/v1.0.conf"  # Path to the scenario configuration file
  version: "v1.0"  # Version of the scenario
  number_of_users: 500  # Number of virtual users executed in the test
  runtime_duration: "3m"  # Test runtime duration (3 minutes)

# Paths to Locust output files generated after test execution
csv_locust_stats_file: "locust_stats.csv"  # Aggregated test statistics
json_locust_ratio_file: "locust_ratio.json"  # Percentile and ratio statistics
csv_locust_exceptions_file: "locust_exceptions.csv"  # Exceptions captured during the test
csv_locust_stats_history_file: "locust_stats_history.csv"  # Time-series performance stats

Command:

load-testing-hub upload-locust-report --yaml-config=./examples/locust.yaml

Example with JSON configuration

Configuration file (./examples/locust.json):

{
  "api_url": "http://localhost:8000",
  "service": {
    "id": 1
  },
  "scenario": {
    "id": 1,
    "name": "get account",
    "file": "./scenarios/get_accounts/v1.0.conf",
    "version": "v1.0",
    "number_of_users": 500,
    "runtime_duration": "3m"
  },
  "csv_locust_stats_file": "locust_stats.csv",
  "json_locust_ratio_file": "locust_ratio.json",
  "csv_locust_exceptions_file": "locust_exceptions.csv",
  "csv_locust_stats_history_file": "locust_stats_history.csv"
}

Command:

load-testing-hub upload-locust-report --json-config=./examples/locust.json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

load_testing_hub-0.1.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

load_testing_hub-0.1.0-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

Details for the file load_testing_hub-0.1.0.tar.gz.

File metadata

  • Download URL: load_testing_hub-0.1.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for load_testing_hub-0.1.0.tar.gz
Algorithm Hash digest
SHA256 54a258324e809f5ddbc49eccec5753a926a78a744c9d3629e21e887723cdd5c0
MD5 021be760509486740818cf3da7311a86
BLAKE2b-256 5090976674d12c9908cda053ca0080377854ab8a8c7ab3ea3a210d3176bd1eba

See more details on using hashes here.

File details

Details for the file load_testing_hub-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for load_testing_hub-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de87e5ffac1a1274e6f2dd03c0adc355ca85e74378fcdc5a8673f2b2072d33fb
MD5 511fa1c8eb9beaef5a5129a73c4318ac
BLAKE2b-256 77dbedf0461b6b4fd8ed079a8fc816cd640521120b653b360f7d55b4ce836a4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page