Skip to content

Latest commit

 

History

History
212 lines (152 loc) · 5.31 KB

File metadata and controls

212 lines (152 loc) · 5.31 KB

robotmk-bridge-testdatagenerator

Generates synthetic test result files for robotmk-bridge-plugin testing. Produces realistic, randomized output in the formats consumed by the bridge plugin's handlers.

Supported Formats

Handler Format Extension Default count
junit JUnit XML .xml 5 test cases
zaproxy OWASP ZAP XML v2.7.0 .xml 3 sites
gatling Gatling simulation.log v2.0 .log 10 requests
locust Locust stats CSV .csv 5 endpoints

Quick Start with uv

uv is the recommended way to run this tool.

Run without installing (one-liner)

uvx --from robotmk-bridge-testdatagenerator rmkb-testgen --list
uvx --from robotmk-bridge-testdatagenerator rmkb-testgen --output-dir /tmp/test-data

Install as a persistent tool

uv tool install robotmk-bridge-testdatagenerator
rmkb-testgen --help

# Upgrade later
uv tool upgrade robotmk-bridge-testdatagenerator

# Uninstall
uv tool uninstall robotmk-bridge-testdatagenerator

Development Setup with uv

git clone https://github.com/elabit/robotmk-bridge-testdatagenerator.git
cd robotmk-bridge-testdatagenerator

# Install package + all dev dependencies (pytest, ruff, etc.)
uv sync

# Run the CLI from source
uv run rmkb-testgen --list
uv run rmkb-testgen --output-dir /tmp/test-data --verbose

# Build distributable artifacts
uv build
# -> dist/robotmk_bridge_testdatagenerator-*.whl
# -> dist/robotmk_bridge_testdatagenerator-*.tar.gz

# Editable install (changes take effect immediately, no reinstall needed)
uv pip install -e .

# Install local wheel into another project
uv add /path/to/dist/robotmk_bridge_testdatagenerator-0.2.0-py3-none-any.whl

Testing

# Run all tests (unit + acceptance)
uv run pytest

# Run with coverage report
uv run pytest --cov

# Run only unit tests
uv run pytest tests/unit/

# Run only acceptance tests (CLI + library API)
uv run pytest tests/acceptance/

# Lint
uv run ruff check src/ tests/
Test layer Location What it covers
Unit tests/unit/ Each generator in isolation: file creation, format validity, status semantics
Acceptance tests/acceptance/ CLI via subprocess (rmkb-testgen), public library API (generate_*)

CLI Reference

rmkb-testgen [options]
python -m robotmk_bridge_testdatagenerator [options]
Flag Short Default Description
--output-dir PATH -o tests/e2e/data Output directory
--status -s passed passed / failed / mixed
--handlers HANDLER... -H all Generate specific handlers only
--count [HANDLER=]N -n handler default Item count (repeatable)
--pattern -p {handler}.{ext} Filename pattern
--continuous -c off Regenerate on interval
--interval SECS -i 5.0 Seconds between continuous runs
--list -l List available handlers and exit
--verbose -v off Verbose output

Examples

# List available handlers
rmkb-testgen --list

# Generate all with defaults
rmkb-testgen --output-dir /tmp/test-data

# Specific status
rmkb-testgen --status failed --output-dir /tmp/test-data

# Specific handlers only
rmkb-testgen --handlers junit gatling --output-dir /tmp/test-data

# Control item count — all handlers
rmkb-testgen --count 20 --output-dir /tmp/test-data

# Per-handler counts
rmkb-testgen -n junit=20 -n gatling=50 -n zaproxy=2 -n locust=8 --output-dir /tmp/test-data

# Continuous regeneration (Ctrl+C to stop)
rmkb-testgen --continuous --interval 5 --output-dir /tmp/test-data

# Custom handlers.yaml
ROBOTMK_HANDLERS_YAML=/path/to/handlers.yaml rmkb-testgen --output-dir /tmp/test-data

Library Usage

from robotmk_bridge_testdatagenerator import (
    generate_all_handler_files,
    generate_handler_file,
    get_supported_handlers,
)
from pathlib import Path

# Generate all handlers
files = generate_all_handler_files(
    output_dir=Path("/tmp/test-data"),
    test_status="mixed",
    handler_kwargs={
        "junit":   {"num_tests": 20},
        "gatling": {"num_requests": 50},
        "zaproxy": {"num_sites": 2},
        "locust":  {"num_endpoints": 8},
    },
)

# Generate a single handler
generate_handler_file(
    handler_name="junit",
    output_path=Path("/tmp/result.xml"),
    test_status="failed",
    num_tests=10,
)

# List available handlers
handlers = get_supported_handlers()  # ['junit', 'gatling', 'zaproxy', 'locust']

Test Status Semantics

Status JUnit ZAP Gatling Locust
passed All pass Low-risk alerts only All requests OK 0 failures
failed All fail High-risk alerts All requests KO 50%+ failures per endpoint
mixed Every 3rd fails Low + medium risk Every 4th KO Every 2nd endpoint has failures

handlers.yaml

The handler registry is bundled with the package. Override for custom handler definitions:

ROBOTMK_HANDLERS_YAML=/path/to/your/handlers.yaml rmkb-testgen --output-dir /tmp/test-data

Installation without uv

pip install robotmk-bridge-testdatagenerator
rmkb-testgen --help

License

GPLv2, see LICENSE for details.