Skip to main content

Module handler

Expand description

Test command handler implementation

Purpose: Smoke test for running Torrust Tracker services

This handler validates that a deployed Tracker application is running and accessible from external clients. The command performs comprehensive end-to-end verification including service status, health checks, and external accessibility validation.

§Validation Strategy

The test command validates deployed services through:

  1. External Health Checks - Tests service accessibility from outside the VM:
    • Tracker API health endpoint (required)
    • HTTP Tracker health endpoint (required)

§HTTPS Support

When services have TLS enabled via Caddy reverse proxy:

  • Uses HTTPS URLs with the configured domain
  • Resolves domains locally to the VM IP (no DNS dependency for testing)
  • Accepts self-signed certificates for .local domains

This approach allows testing to work without DNS configuration while still being realistic (Caddy receives the correct SNI/Host header).

§Why External-Only Validation?

We perform external accessibility checks (from test runner to VM) rather than internal checks (via SSH to localhost) because:

  • External checks are a superset of internal checks
  • If services are accessible externally, they must be running internally
  • External checks validate firewall configuration automatically
  • Simpler test implementation reduces maintenance burden

§Port Configuration

The test command extracts tracker ports from the environment’s tracker configuration:

  • HTTP API port from environment.context.user_inputs.tracker.http_api.bind_address
  • HTTP Tracker port from environment.context.user_inputs.tracker.http_trackers[0].bind_address

For rationale and alternatives, see:

  • docs/decisions/test-command-as-smoke-test.md - Architectural decision record

Structs§

TestCommandHandler
TestCommandHandler orchestrates smoke testing for running Torrust Tracker services