Commit 0e85a6d
committed
fd53b7f refactor: [#217] Rename run_configuration_tests to run_configure_release_run_tests (Jose Celano)
3ede934 feat: [#217] Add separate E2E validation modules for release and run commands (Jose Celano)
5c14832 docs: [#217] Update Docker-in-Docker ADR with implementation details (Jose Celano)
30a1c3f fix: [#217] Wrap std::env::set_var in unsafe block (Rust 1.81+) (Jose Celano)
862499c feat: [#217] Enable Docker-in-Docker for E2E tests to test run command (Jose Celano)
1643b44 docs: [#217] document Phase 9 manual E2E test issues and resolution (Jose Celano)
ed6f480 feat: [#217] wire RunCommandController to RunCommandHandler (Jose Celano)
1921015 feat: [#217] implement Phase 9 - StartServicesStep for run command (Jose Celano)
351e6fe refactor: [#217] Add symmetric logging to release and provision handlers (Jose Celano)
6ef21d2 refactor: [#217] Improve configure handler clarity (Jose Celano)
0ec82fd refactor: [#217] Extract load and validate methods in command handlers (Jose Celano)
419e35b fix(clippy): [#217] Fix clippy linting errors (Jose Celano)
92509c9 refactor(error-handling): [#217] Standardize EnvironmentNotFound error across all handlers (Jose Celano)
ca4ee88 refactor(release): [#217] Validate instance IP as precondition for release (Jose Celano)
043560c feat(release): [#217] Complete Phase 8 - Refactor release handler to three-level architecture (Jose Celano)
8a0291a docs: [#217] update phase 6 and 7 documentation with implementation status (Jose Celano)
bc32270 feat: [#217] implement phase 6 - release step prepares docker compose files (Jose Celano)
26528f9 test: [#217] add release and run commands to E2E test workflows (Jose Celano)
fb529ec feat: [#217] implement state transitions for release and run handlers (Jose Celano)
98aec5d feat: [#217] complete application layer handlers for release and run commands (Jose Celano)
7c113c0 feat: [#217] add release and run steps in application layer (Jose Celano)
2d766df feat: [#217] add release and run command handlers in application layer (Jose Celano)
0791846 feat: [#217] add release and run controllers (wired but empty) (Jose Celano)
e97483a refactor: [#217] rename e2e-config-tests to e2e-config-and-release-tests (Jose Celano)
ea55f4f feat: [#217] add release and run CLI commands (no-op) (Jose Celano)
Pull request description:
## Summary
This PR implements the foundational scaffolding for the `release` and `run` commands using a minimal docker-compose deployment with nginx. The goal is to validate the full pipeline (release → run → verify) before adding complexity with the actual Torrust Tracker services.
**Issue**: Closes #217
## Implementation Progress
### Phase Tracking
| Phase | Description | Status |
|-------|-------------|--------|
| **Phase 1** | Presentation Layer - CLI Commands (No-Op) | ✅ Complete |
| **Phase 2** | E2E Test Refactoring (Safety Net) | ✅ Complete |
| **Phase 3** | Presentation Layer - Controllers | ✅ Complete |
| **Phase 4** | Application Layer - Command Handlers (Skeleton) | ✅ Complete |
| **Phase 5** | Application Layer - State Transitions | ✅ Complete |
| **Phase 6** | Steps Layer - Prepare Compose Files | ✅ Complete |
| **Phase 7** | Infrastructure Layer - Docker Compose Template Renderer | ✅ Complete |
| **Phase 8** | Steps Layer - Transfer Files to VM | ✅ Complete |
| **Phase 9** | Steps Layer - Start Services | ✅ Complete |
| **Phase 10** | E2E Test Coverage | ✅ Complete |
### What's Implemented
#### CLI Commands
- `release` - Release application files to a configured environment
- `run` - Run the application stack on a released environment
#### State Transitions
- `Configured` → `Releasing` → `Released` (release command)
- `Released` → `Starting` → `Running` (run command)
#### Infrastructure
**Docker Compose Template Renderer**
- `DockerComposeTemplateRenderer` following the same pattern as `AnsibleTemplateRenderer` and `TofuTemplateRenderer`
- Embedded docker-compose.yml template with nginx:alpine demo service
- Template extraction via `TemplateManager` (double-indirection pattern)
**Release Handler - Three-Level Architecture (Phase 8)**
- `ReleaseCommandHandler` refactored to follow Provision Handler patterns
- `RenderDockerComposeTemplatesStep` - Renders templates locally
- `DeployComposeFilesStep` - Deploys files to VM via Ansible playbook
- `ReleaseTraceWriter` - Generates trace files for failure diagnostics
- `ReleaseStep` enum and `ReleaseFailureContext` for step tracking
- Ansible playbook `deploy-compose-files.yml` for file transfer
**Run Handler - Three-Level Architecture (Phase 9)**
- `RunCommandHandler` with full step architecture
- `StartServicesStep` - Starts Docker Compose services on VM
- `RunTraceWriter` - Generates trace files for failure diagnostics
- `RunStep` enum and `RunFailureContext` for step tracking
- Ansible playbook `start-services.yml.tera` for service management
**E2E Test Coverage (Phase 10)**
- `RunningServicesValidator` - Remote action to validate running services via SSH
- Separate validation modules per command (SRP):
- `run_configuration_validation` - Validates configure command (Docker installed)
- `run_release_validation` - Validates release command (Compose files deployed)
- `run_run_validation` - Validates run command (services running)
- Full workflow tested: create → register → configure → release → run → destroy
### Files Changed
**Application Layer**
- `src/application/command_handlers/release/` - ReleaseCommandHandler (refactored)
- `src/application/command_handlers/run/` - RunCommandHandler (fully implemented)
- `src/application/steps/application/deploy_compose_files.rs` - DeployComposeFilesStep
- `src/application/steps/application/start_services.rs` - StartServicesStep (NEW)
- `src/application/steps/rendering/docker_compose_templates.rs` - RenderDockerComposeTemplatesStep
**Domain Layer**
- `src/domain/environment/state/release_failed.rs` - ReleaseStep enum, ReleaseFailureContext
- `src/domain/environment/state/run_failed.rs` - RunStep enum, RunFailureContext (NEW)
**Infrastructure Layer**
- `src/infrastructure/external_tools/docker_compose/template/renderer/mod.rs` - DockerComposeTemplateRenderer
- `src/infrastructure/remote_actions/running_services.rs` - RunningServicesValidator (NEW)
- `src/infrastructure/trace/writer/commands/release.rs` - ReleaseTraceWriter
- `src/infrastructure/trace/writer/commands/run.rs` - RunTraceWriter (NEW)
**Presentation Layer**
- `src/presentation/controllers/release/` - Release controller
- `src/presentation/controllers/run/` - Run controller
**Testing**
- `src/testing/e2e/tasks/run_configuration_validation.rs` - Configure command validation
- `src/testing/e2e/tasks/run_release_validation.rs` - Release command validation (NEW)
- `src/testing/e2e/tasks/run_run_validation.rs` - Run command validation (NEW)
- `src/bin/e2e_config_and_release_tests.rs` - Full workflow E2E tests
**Templates**
- `templates/docker-compose/docker-compose.yml` - nginx:alpine demo service
- `templates/ansible/deploy-compose-files.yml` - File deployment playbook
- `templates/ansible/start-services.yml.tera` - Service start playbook (NEW)
### Manual E2E Test
```bash
# Full workflow verified:
cargo run -- create environment --env-file envs/e2e-full.json
cargo run -- provision e2e-full
cargo run -- configure e2e-full
cargo run -- release e2e-full
# Verified: docker-compose.yml deployed to VM at /opt/torrust/
cargo run -- run e2e-full
# Verified: nginx service running
cargo run -- destroy e2e-full
```
## All Phases Complete ✅
This PR is ready for review. All phases have been implemented:
- Full `release` and `run` command implementation
- Complete E2E test coverage with separate validation per command
- Three-level architecture (Commands → Steps → Actions) consistently applied
## Related Documentation
See `docs/issues/217-demo-slice-release-run-commands.md` for detailed implementation plan.
ACKs for top commit:
josecelano:
ACK fd53b7f
Tree-SHA512: 0bb61a847cd332a9afdff102783b34c69059975d151de853d0d248882cbcea4ba252dddf3edbfc338ea806a727868e6a2cb838ef10b692bd0471e46608174985
File tree
91 files changed
+8715
-531
lines changed- .cargo
- .github/workflows
- docker
- provisioned-instance
- ssh-server
- docs
- contributing
- copilot-agent
- decisions
- features/environment-state-management/implementation-plan
- issues
- research
- scripts
- src
- application
- command_handlers
- configure
- create
- destroy
- provision
- register
- release
- run
- test
- steps
- application
- rendering
- bin
- bootstrap
- domain/environment/state
- infrastructure
- external_tools
- ansible/template/renderer
- docker_compose
- template
- renderer
- remote_actions
- trace
- writer
- commands
- presentation
- controllers
- release
- run
- dispatch
- input/cli
- testing/e2e
- containers
- tasks
- black_box
- templates
- ansible
- docker-compose
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
91 files changed
+8715
-531
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
| 133 | + | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
40 | 47 | | |
41 | 48 | | |
42 | 49 | | |
| |||
45 | 52 | | |
46 | 53 | | |
47 | 54 | | |
48 | | - | |
| 55 | + | |
49 | 56 | | |
50 | 57 | | |
51 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
11 | 19 | | |
12 | 20 | | |
13 | 21 | | |
14 | 22 | | |
15 | 23 | | |
16 | 24 | | |
17 | | - | |
| 25 | + | |
18 | 26 | | |
19 | 27 | | |
20 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
0 commit comments