Skip to content

Conversation

@sysid
Copy link
Owner

@sysid sysid commented Dec 31, 2025

Summary

Add exhaustive load testing infrastructure to detect memory leaks, validate Issue #152 watcher deduplication at scale, and prevent performance regressions.

Test Coverage (15 tests)

Category Tests What it validates
Memory stability 3 Leak detection, baseline return, event set cleanup
Watcher scale 3 Single watcher verification, rapid connect/disconnect, cleanup
Throughput 4 Single/multi-client throughput, TTFE, inter-event latency
Shutdown 2 Graceful termination with active connections
Backpressure 3 Slow client isolation, connection churn, send_timeout

Infrastructure

  • Docker-based test server with /metrics endpoint (psutil)
  • testcontainers fixtures with health check wait strategies
  • httpx-sse + asyncio.gather() for concurrent SSE clients
  • Manual GitHub Actions workflow (workflow_dispatch)

Changes

  • New tests/load/ directory with 15 load tests
  • New tests/Dockerfile.loadtest for test server image
  • New .github/workflows/load-test.yml (manual trigger)
  • New Makefile target: make test-load
  • New dev dependency: httpx-sse

Usage

# Run with defaults (100 connections, 1 minute)
make test-load

# Custom scale and duration
make test-load PYTEST_ARGS="--scale=500 --duration=5"

@sysid sysid force-pushed the feat/loadtest branch 4 times, most recently from 3cc3f76 to 21b0ed9 Compare January 2, 2026 12:21
sysid added 4 commits January 2, 2026 13:23
Add exhaustive load testing to detect memory leaks,
watcher deduplication at scale, and prevent performance regressions.

Test coverage (15 tests):
- Memory stability: leak detection, baseline return, event set cleanup
- Watcher scale: single watcher verification, rapid connect/disconnect
- Throughput: single/multi-client, TTFE, inter-event latency
- Shutdown: graceful termination with active connections
- Backpressure: slow client isolation, connection churn, send_timeout

Infrastructure:
- Docker-based test server with /metrics endpoint (psutil)
- testcontainers fixtures with health check wait strategies
- httpx-sse + asyncio.gather() for concurrent SSE clients
- Manual GitHub Actions workflow (workflow_dispatch)

New dependencies in dev group: httpx-sse
New Makefile target: test-load
Add structured metrics collection, baseline management, and HTML/JSON
reporting to load tests. Tests now produce observable performance data
instead of just pass/fail results.

New components:
- MetricsCollector: aggregates latency, memory, throughput samples
- BaselineManager: stores/loads per-test baselines, detects regressions
- ReportGenerator: produces JSON reports and self-contained HTML with
  inline SVG charts

All 15 load tests updated with:
- Metrics collection integration
- Structured docstrings explaining what/why/how for each test
- Baseline comparison and optional regression detection

CLI options added: --update-baseline, --fail-on-regression,
--output-dir, --baselines-dir, --regression-threshold

GitHub workflow updated with baseline update and regression detection
inputs, plus artifact upload for reports.
Remove --scale and --duration CLI options from load tests. Each test
now defines its own parameters as constants, allowing appropriate
values per test type (e.g., shutdown tests need fewer connections).

Changes:
- conftest.py: remove --scale, --duration options and fixtures
- metrics.py: compute duration_minutes internally from actual duration
- test_*.py: add explicit NUM_CLIENTS, DURATION_SEC, etc. constants
- README.md: update CLI options documentation
- load-test.yml: remove scale/duration workflow inputs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants