Parent Epic: #2 - Scaffolding for main app
Related:
Overview
Implement the presentation layer (CLI interface) for the test command, enabling users to verify deployment infrastructure through the command-line interface. The application layer TestCommandHandler is already implemented and performs validation checks for cloud-init completion, Docker installation, and Docker Compose installation.
This task focuses exclusively on creating the user-facing CLI subcommand that calls the existing business logic, following the same architectural pattern used in the configure command controller.
Goals
🏗️ Architecture Requirements
DDD Layer: Presentation
Module Path: src/presentation/controllers/test/
Pattern: CLI Subcommand Controller (orchestrates Application layer command handler)
Module Structure
src/presentation/controllers/test/
├── mod.rs # Module documentation and re-exports
├── handler.rs # Main controller implementation
├── errors.rs # Presentation-layer error types
└── tests/ # Unit tests for controller logic
└── mod.rs
Key Requirements
- Follow presentation layer conventions from
src/presentation/controllers/configure/
- No business logic in presentation layer - delegate all validation to
TestCommandHandler
- Error types must implement
.help() methods with actionable troubleshooting guidance
- Use
ProgressReporter for user feedback during multi-step validation
- Support both
ExecutionContext pattern and direct dependency injection
Implementation Plan
Phase 1: Module Structure and Error Types (1-2 hours)
Phase 2: Controller Implementation (2-3 hours)
Phase 3: CLI Integration (1 hour)
Phase 4: Testing (2-3 hours)
Phase 5: Documentation and Manual Testing (2-3 hours)
Phase 6: Quality Assurance (30 minutes)
Acceptance Criteria
Note for Contributors: These criteria define what the PR reviewer will check. Use this as your pre-review checklist before submitting the PR.
Quality Checks:
Task-Specific Criteria:
User Experience Examples
Success case:
$ torrust-tracker-deployer test my-env
[1/3] Validating cloud-init completion... ✓
[2/3] Validating Docker installation... ✓
[3/3] Validating Docker Compose installation... ✓
✓ Infrastructure validation completed successfully
Error case - environment not provisioned:
$ torrust-tracker-deployer test my-env
Error: Environment 'my-env' does not have instance IP set
Environment 'my-env' must be provisioned before testing.
Provision infrastructure:
torrust-tracker-deployer provision my-env
Notes
- The controller only orchestrates - all validation logic is in
TestCommandHandler
- Follow the exact same pattern as
configure controller for consistency
- See the full specification for complete details including:
- Complete code examples
- Error type implementations
- Manual testing workflow (10 steps)
- Design rationale and future enhancements
Estimated Total Time: 8-12 hours
Parent Epic: #2 - Scaffolding for main app
Related:
Overview
Implement the presentation layer (CLI interface) for the
testcommand, enabling users to verify deployment infrastructure through the command-line interface. The application layerTestCommandHandleris already implemented and performs validation checks for cloud-init completion, Docker installation, and Docker Compose installation.This task focuses exclusively on creating the user-facing CLI subcommand that calls the existing business logic, following the same architectural pattern used in the
configurecommand controller.Goals
testCLI subcommandTestCommandHandlerbusiness logic🏗️ Architecture Requirements
DDD Layer: Presentation
Module Path:
src/presentation/controllers/test/Pattern: CLI Subcommand Controller (orchestrates Application layer command handler)
Module Structure
Key Requirements
src/presentation/controllers/configure/TestCommandHandler.help()methods with actionable troubleshooting guidanceProgressReporterfor user feedback during multi-step validationExecutionContextpattern and direct dependency injectionImplementation Plan
Phase 1: Module Structure and Error Types (1-2 hours)
src/presentation/controllers/test/directorymod.rswith module documentationerrors.rswith all error variants and.help()methodstests/mod.rsskeletonPhase 2: Controller Implementation (2-3 hours)
TestCommandControllerstruct inhandler.rsProgressReporterfor 4-step workflowPhase 3: CLI Integration (1 hour)
Testvariant toCommandsenum inmain.rstestsubcommandsrc/presentation/controllers/mod.rsto export test controllerPhase 4: Testing (2-3 hours)
.help()messagesPhase 5: Documentation and Manual Testing (2-3 hours)
docs/console-commands.mdwith test command usagePhase 6: Quality Assurance (30 minutes)
./scripts/pre-commit.shAcceptance Criteria
Quality Checks:
./scripts/pre-commit.shTask-Specific Criteria:
torrust-tracker-deployer test <environment-name>executes successfullyTestCommandHandler.help()with specific troubleshooting stepsdocs/console-commands.mdUser Experience Examples
Success case:
$ torrust-tracker-deployer test my-env [1/3] Validating cloud-init completion... ✓ [2/3] Validating Docker installation... ✓ [3/3] Validating Docker Compose installation... ✓ ✓ Infrastructure validation completed successfullyError case - environment not provisioned:
Notes
TestCommandHandlerconfigurecontroller for consistencyEstimated Total Time: 8-12 hours