Skip to content

Commit 3ede934

Browse files
committed
feat: [#217] Add separate E2E validation modules for release and run commands
Create proper separation of concerns for E2E validations: - run_configuration_validation.rs: Validates 'configure' command (Docker and Docker Compose installed correctly) - run_release_validation.rs: Validates 'release' command (Docker Compose files deployed to /opt/torrust) - run_run_validation.rs: Validates 'run' command (Docker Compose services running and healthy) - RunningServicesValidator: New remote action that checks: - Services listed in 'docker compose ps' output - Services in running status (not exited/restarting) - Health check status if configured - HTTP accessibility for web services (optional) E2E test now validates each command's output: configure → validate config → release → validate release → run → validate run Added documentation notes about future external validation: - Current scope: Demo slice with nginx, internal validation via SSH - Future: External accessibility testing for real Torrust services - Future: Firewall rule verification through external tests This completes Phase 10 of issue #217 with proper validation architecture.
1 parent 5c14832 commit 3ede934

File tree

8 files changed

+776
-25
lines changed

8 files changed

+776
-25
lines changed

docs/issues/217-demo-slice-release-run-commands.md

Lines changed: 78 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ This task implements the foundational scaffolding for the `release` and `run` co
99

1010
## Goals
1111

12-
- [ ] Create `ReleaseCommandHandler` (App layer) with state transitions
13-
- [ ] Create `RunCommandHandler` (App layer) with state transitions
14-
- [ ] Create `release` CLI subcommand (Presentation layer)
15-
- [ ] Create `run` CLI subcommand (Presentation layer)
16-
- [ ] Add docker-compose file infrastructure
17-
- [ ] Deploy and run demo-app (nginx) container on provisioned VM
18-
- [ ] Verify container is running and healthy
19-
- [ ] Rename `e2e_config_tests.rs``e2e_config_and_release_tests.rs` and extend
20-
- [ ] Update `e2e_tests_full.rs` to include release and run commands
12+
- [x] Create `ReleaseCommandHandler` (App layer) with state transitions
13+
- [x] Create `RunCommandHandler` (App layer) with state transitions
14+
- [x] Create `release` CLI subcommand (Presentation layer)
15+
- [x] Create `run` CLI subcommand (Presentation layer)
16+
- [x] Add docker-compose file infrastructure
17+
- [x] Deploy and run demo-app (nginx) container on provisioned VM
18+
- [x] Verify container is running and healthy
19+
- [x] Rename `e2e_config_tests.rs``e2e_config_and_release_tests.rs` and extend
20+
- [x] Update `e2e_tests_full.rs` to include release and run commands
2121

2222
## Architecture Overview
2323

@@ -867,13 +867,68 @@ cargo run -- destroy e2e-full
867867
| Service accessible | nginx welcome page returned ✅ |
868868
| State transitioned to Running | `"Running"` in environment.json ✅ |
869869

870-
### Phase 10: E2E Test Coverage
870+
### Phase 10: E2E Test Coverage ✅ COMPLETE
871871

872-
- Extend E2E tests to cover full release and run workflow
873-
- Test full pipeline: create → provision → configure → release → run
874-
- Verify demo-app container runs successfully and is healthy
872+
> **Status**: ✅ COMPLETE
873+
>
874+
> E2E tests now validate the complete deployment pipeline including service health checks.
875+
876+
#### Implementation Summary
877+
878+
The E2E test coverage has been enhanced with proper separation of validation concerns:
879+
880+
| Component | Module | Description |
881+
| ------------------------------ | --------------------------------- | ------------------------------------------------------------- |
882+
| **`RunningServicesValidator`** | `remote_actions/` | Remote action to validate Docker Compose services are running |
883+
| **`run_release_validation`** | `tasks/run_release_validation.rs` | Validates `release` command: Docker Compose files deployed |
884+
| **`run_run_validation`** | `tasks/run_run_validation.rs` | Validates `run` command: services running and healthy |
885+
886+
#### What Was Implemented
887+
888+
**1. `RunningServicesValidator` Remote Action**
889+
890+
```rust
891+
// src/infrastructure/remote_actions/running_services.rs
892+
pub struct RunningServicesValidator {
893+
ssh_client: SshClient,
894+
deploy_dir: PathBuf,
895+
}
896+
```
897+
898+
Validates:
899+
900+
- Services are listed in `docker compose ps` output
901+
- Services are in "running" status (not "exited" or "restarting")
902+
- Health check status if configured (e.g., "healthy")
903+
- HTTP accessibility for web services (optional, port 8080)
875904

876-
**Deliverable**: Complete E2E test suite for new commands.
905+
**2. Separate Validation Modules (One Per Command)**
906+
907+
Following Single Responsibility Principle:
908+
909+
- `run_configuration_validation.rs` - Validates `configure` command (Docker/Docker Compose installed)
910+
- `run_release_validation.rs` - Validates `release` command (Compose files deployed)
911+
- `run_run_validation.rs` - Validates `run` command (services running)
912+
913+
**3. Test Coverage Summary**
914+
915+
| E2E Test Binary | Workflow Tested | Validations Run |
916+
| --------------------------------- | -------------------------------------------------------- | --------------------------- |
917+
| `e2e_provision_and_destroy_tests` | create → provision → destroy | N/A |
918+
| `e2e_config_and_release_tests` | create → register → configure → release → run → validate | config ✅ release ✅ run ✅ |
919+
| `e2e_tests_full` | create → provision → configure → release → run → destroy | (infrastructure) |
920+
921+
#### Deliverables ✅
922+
923+
All deliverables completed:
924+
925+
1. ✅ E2E tests cover full release and run workflow
926+
2. ✅ Full pipeline tested: create → provision/register → configure → release → run
927+
3. ✅ Demo-app container verified as running and healthy
928+
4. ✅ New `RunningServicesValidator` validates service health
929+
5. ✅ Configuration validation extended with service checks
930+
931+
**Deliverable**: Complete E2E test suite for new commands. ✅
877932

878933
**Manual E2E Test - Full Pipeline**:
879934

@@ -1120,7 +1175,10 @@ All errors must:
11201175
- `src/application/steps/application/deploy_compose_files.rs` ✅ (`DeployComposeFilesStep` - deploys via Ansible)
11211176
- `src/application/steps/rendering/docker_compose_templates.rs` ✅ (`RenderDockerComposeTemplatesStep` - renders templates)
11221177
- `src/application/steps/application/start_services.rs` (future - start docker compose services)
1123-
- `src/application/steps/application/verify_services.rs` (future - verify services are running)
1178+
1179+
### Infrastructure Layer (Remote Actions)
1180+
1181+
- `src/infrastructure/remote_actions/running_services.rs` ✅ (`RunningServicesValidator` - validates running services via E2E tests)
11241182

11251183
### Infrastructure Layer
11261184

@@ -1154,6 +1212,11 @@ All errors must:
11541212
- Update `Cargo.toml` binary definition ✅
11551213
- Update `scripts/pre-commit.sh` to use new test name ✅
11561214

1215+
### E2E Validation Modules
1216+
1217+
- `src/testing/e2e/tasks/run_release_validation.rs` ✅ (validates `release` command - Docker Compose files deployed)
1218+
- `src/testing/e2e/tasks/run_run_validation.rs` ✅ (validates `run` command - services running and healthy)
1219+
11571220
## Related Documentation
11581221

11591222
- [Codebase Architecture](../codebase-architecture.md) - Three-level architecture (Command → Step → Remote Action)

src/bin/e2e_config_and_release_tests.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ use torrust_tracker_deployer_lib::testing::e2e::tasks::black_box::{
7575
};
7676
use torrust_tracker_deployer_lib::testing::e2e::tasks::container::cleanup_infrastructure::stop_test_infrastructure;
7777
use torrust_tracker_deployer_lib::testing::e2e::tasks::run_configuration_validation::run_configuration_validation;
78+
use torrust_tracker_deployer_lib::testing::e2e::tasks::run_release_validation::run_release_validation;
79+
use torrust_tracker_deployer_lib::testing::e2e::tasks::run_run_validation::run_run_validation;
7880

7981
/// Environment name for this E2E test
8082
const ENVIRONMENT_NAME: &str = "e2e-config";
@@ -245,16 +247,26 @@ async fn run_deployer_workflow(
245247
// (CLI: cargo run -- configure <env>)
246248
test_runner.configure_services()?;
247249

250+
// Validate the configuration (Docker and Docker Compose installed correctly)
251+
run_configuration_validation(socket_addr, ssh_credentials)
252+
.await
253+
.map_err(|e| anyhow::anyhow!("{e}"))?;
254+
248255
// Release software to the configured infrastructure
249256
// (CLI: cargo run -- release <env>)
250257
test_runner.release_software()?;
251258

259+
// Validate the release (Docker Compose files deployed correctly)
260+
run_release_validation(socket_addr, ssh_credentials)
261+
.await
262+
.map_err(|e| anyhow::anyhow!("{e}"))?;
263+
252264
// Run services on the released infrastructure
253265
// (CLI: cargo run -- run <env>)
254266
test_runner.run_services()?;
255267

256-
// Validate the configuration
257-
run_configuration_validation(socket_addr, ssh_credentials)
268+
// Validate services are running (Docker Compose services started and healthy)
269+
run_run_validation(socket_addr, ssh_credentials)
258270
.await
259271
.map_err(|e| anyhow::anyhow!("{e}"))?;
260272

src/infrastructure/remote_actions/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ pub enum RemoteActionError {
5555
pub mod cloud_init;
5656
pub mod docker;
5757
pub mod docker_compose;
58+
pub mod running_services;
5859

5960
pub use cloud_init::CloudInitValidator;
6061
pub use docker::DockerValidator;
6162
pub use docker_compose::DockerComposeValidator;
63+
pub use running_services::RunningServicesValidator;
6264

6365
/// Trait for remote actions that can be executed on a server via SSH
6466
///

0 commit comments

Comments
 (0)