Testing

make test        # pytest
make lint        # ruff
python -m pytest --cov=relational_transformers_gateway --cov-report=term-missing

The suite holds coverage at ~94% with no AWS access and no mock patching of boto3: every AWS client is a constructor argument, and the tests inject small fakes (tests/conftest.py). Three layers:

  1. Unit — config parsing, auth caching, rate limiting, discovery fallbacks, LLM body validation, usage extraction, the manage CLI against fake clients.

  2. CoreGateway.handle end to end with fake AWS: auth failures, rate limits, 404/405/413, metering-failure 503s, duplicate-id 409s, /v1/models filtering.

  3. Real sockets — the actual ThreadingHTTPServer against stub worker and stub OpenAI servers on loopback: forward proxying with retry past a dead worker, SSE streaming with usage metering, malformed content-length, oversized bodies, SIGTERM shutdown.

Live wiring test

For an end-to-end check against real AWS and a real GPU box:

  1. Start scripts/vast-test-worker.sh on the box (serves /health and a /v1/forward stub on :8500).

  2. Tunnel it locally (ssh -N -L 8500:localhost:8500 ...) and register http://127.0.0.1:8500 with rtg-manage register-worker.

  3. Run rtg-serve with the real environment and exercise /gateway/health, /health, /v1/forward, a duplicate x-request-id (expect 409), and rtg-manage revoke-key (expect 401 within the auth cache window).

  4. Clean up: deregister the worker, delete the test key, and remove the test rows from the usage table.

This flow was last validated 2026-08-04 against a Vast RTX 5070.