Skip to content

feat: [#380] add JSON output support to the test command - #383

Merged
josecelano merged 2 commits into
mainfrom
380-add-json-output-to-test-command
Feb 23, 2026
Merged

josecelano merged 2 commits into
mainfrom
380-add-json-output-to-test-command

Conversation

@josecelano

Copy link
Copy Markdown
Member

Overview

Adds --output-format support to the test command, making its results machine-readable for automation, scripts, and AI agents. Closes #380.

Usage

# Default (text)
torrust-tracker-deployer test my-env

# Explicit text
torrust-tracker-deployer test my-env --output-format text

# JSON for automation
torrust-tracker-deployer test my-env --output-format json

Output Examples

Text (default):

Test Results:
  Environment:       my-env
  Instance IP:       10.140.190.149
  Result:            pass

JSON:

{
  "environment_name": "my-env",
  "instance_ip": "10.140.190.149",
  "result": "pass",
  "dns_warnings": []
}

Manual E2E Test

The complete deployment workflow was verified manually:

create environment → provision → configure → release → run → test --output-format json ✅

Both output formats (text and json) were validated against a live environment.

Note: During testing, a bug was found where the docker-compose template renders an invalid empty networks: key for the tracker service in minimal configs (SQLite, no domains, no Prometheus). This causes run to fail with services.tracker.networks must be a list. Opened #382 to track and fix it.

Related

Add Strategy Pattern views (JSON/Text) for the test command output,
following the same architecture as the release command.

Changes:
- Add TestResultData and DnsWarningData DTOs in presentation layer
- Add JsonView and TextView rendering implementations with tests
- Extend TestResult with instance_ip field for output context
- Update TestCommandController to accept OutputFormat parameter
- Update router to pass output_format to test controller
- Update doc examples for new execute() signature
- Mark all completed implementation checklist items in spec (Steps 1-7 done)
- Rewrite docs/user-guide/commands/test.md to match actual implementation:
  - Replace inaccurate test categories (Docker, SSH, permissions checks)
    with actual behavior (external health checks + DNS resolution)
  - Remove incorrect state validation claim (accepts any state, not just Configured)
  - Remove fictional exit codes section
  - Add JSON output format documentation with examples
  - Add text output format examples
  - Add JSON field reference tables
  - Rewrite troubleshooting section to match real failure modes
  - Document HTTPS support and DNS advisory checks
@josecelano josecelano self-assigned this Feb 23, 2026
@josecelano

Copy link
Copy Markdown
Member Author

ACK 836dbc7

@josecelano
josecelano merged commit 8e6a912 into main Feb 23, 2026
31 checks passed
@josecelano josecelano mentioned this pull request Feb 23, 2026
14 tasks done
josecelano added a commit that referenced this pull request Feb 26, 2026
- 12.8 Add JSON output to test command - Issue #380, PR #383
- 12.9 Add JSON output to destroy command - Issue #386, PR #387
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.

Add JSON output to test command

1 participant