Skip to content

Commit d6a5c3b

Browse files
committed
refactor: [#220] create external_validators module structure
1 parent 223b83d commit d6a5c3b

File tree

3 files changed

+172
-10
lines changed

3 files changed

+172
-10
lines changed

docs/implementation-plans/issue-220-test-command-architecture.md

Lines changed: 138 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ Phase 2: Multiple HTTP Trackers
6363
[x] Step 2.4: Update E2E test task
6464
[x] Step 2.5: Add multiple tracker tests
6565
66-
Phase 3: Service Location
67-
[ ] Step 3.1: Create TrackerHealthService
68-
[ ] Step 3.2: Update application services module
69-
[ ] Step 3.3: Remove old validator
66+
Phase 3: Infrastructure Module Reorganization
67+
[ ] Step 3.1: Create external_validators module
68+
[ ] Step 3.2: Move running_services.rs to external_validators
69+
[ ] Step 3.3: Update infrastructure module exports
7070
[ ] Step 3.4: Update all imports
71-
[ ] Step 3.5: Update error types and documentation
71+
[ ] Step 3.5: Update documentation and ADR
7272
7373
Phase 4: Documentation
7474
[x] Step 4.1: Update command documentation
@@ -466,12 +466,142 @@ Phase 4: Documentation
466466

467467
---
468468

469-
## Phase 3: Move to Application Services Layer
469+
## Phase 3: Infrastructure Module Reorganization
470470

471-
**Priority**: Medium | **Effort**: Low | **Time**: 45 minutes
471+
**Priority**: Medium | **Effort**: Low | **Time**: 30 minutes
472472
**Incremental Commits**: 5 commits (one per step)
473473

474-
### Step 3.1: Create TrackerHealthService
474+
**Goal**: Clarify the distinction between SSH-based validators (executed inside VM) and external validators (E2E validation from outside VM)
475+
476+
**Current Problem**: `running_services.rs` performs external HTTP validation but is located in `remote_actions/validators/` alongside SSH-based validators (cloud_init, docker, docker_compose). This creates architectural confusion about execution context.
477+
478+
**Solution**: Create `src/infrastructure/external_validators/` to separate:
479+
480+
- **remote_actions**: Actions executed INSIDE the VM via SSH
481+
- **external_validators**: Validation from OUTSIDE the VM via HTTP (E2E testing)
482+
483+
Both remain in infrastructure layer (correct DDD placement - external system interactions) but with clear execution context distinction.
484+
485+
### Step 3.1: Create External Validators Module
486+
487+
**Commit**: `refactor: [#220] create external_validators module structure`
488+
489+
**Actions**:
490+
491+
1. Create: `src/infrastructure/external_validators/mod.rs`
492+
2. Content:
493+
494+
```rust
495+
//! External validators module
496+
//!
497+
//! This module contains validators that perform end-to-end validation from
498+
//! OUTSIDE the VM, testing services as an external user would access them.
499+
//!
500+
//! ## Execution Context
501+
//!
502+
//! Unlike `remote_actions` which execute commands INSIDE the VM via SSH,
503+
//! external validators:
504+
//! - Run from the test runner or deployment machine
505+
//! - Test service accessibility via HTTP/HTTPS from outside
506+
//! - Validate end-to-end functionality including network and firewall
507+
//!
508+
//! ## Available Validators
509+
//!
510+
//! - `running_services` - Validates Docker Compose services via external HTTP health checks
511+
512+
pub mod running_services;
513+
514+
pub use running_services::RunningServicesValidator;
515+
```
516+
517+
**Pre-commit**: Run linters, commit
518+
519+
---
520+
521+
### Step 3.2: Move running_services.rs to external_validators
522+
523+
**Commit**: `refactor: [#220] move running_services validator to external_validators`
524+
525+
**Actions**:
526+
527+
1. Move file:
528+
529+
```bash
530+
git mv src/infrastructure/remote_actions/validators/running_services.rs \
531+
src/infrastructure/external_validators/running_services.rs
532+
```
533+
534+
2. Update file header documentation in `running_services.rs`:
535+
- Change module intro to emphasize "external validation from outside VM"
536+
- Add section explaining why it's in `external_validators` not `remote_actions`
537+
538+
**Pre-commit**: Run tests (expect failures), commit anyway
539+
540+
---
541+
542+
### Step 3.3: Update Infrastructure Module Exports
543+
544+
**Commit**: `refactor: [#220] update infrastructure exports for external validators`
545+
546+
**Actions**:
547+
548+
1. Edit: `src/infrastructure/mod.rs` - Add external_validators module
549+
2. Edit: `src/infrastructure/remote_actions/mod.rs` - Remove RunningServicesValidator export
550+
3. Edit: `src/infrastructure/remote_actions/validators/mod.rs` - Remove running_services module
551+
552+
**Pre-commit**: Run tests (expect failures), run linters, commit
553+
554+
---
555+
556+
### Step 3.4: Update All Imports
557+
558+
**Commit**: `refactor: [#220] update imports to use external_validators path`
559+
560+
**Actions**:
561+
562+
1. Find all files importing `RunningServicesValidator`:
563+
564+
```bash
565+
git grep "RunningServicesValidator" --name-only
566+
```
567+
568+
2. Update import paths in each file:
569+
570+
```rust
571+
// Old
572+
use crate::infrastructure::remote_actions::RunningServicesValidator;
573+
574+
// New
575+
use crate::infrastructure::external_validators::RunningServicesValidator;
576+
```
577+
578+
**Pre-commit**: Run tests, run linters, commit
579+
580+
---
581+
582+
### Step 3.5: Update Documentation and Create ADR
583+
584+
**Commit**: `docs: [#220] add ADR for infrastructure module organization`
585+
586+
**Actions**:
587+
588+
1. Create: `docs/decisions/infrastructure-module-organization.md`
589+
2. Document decision to separate:
590+
- `remote_actions/` - SSH-based operations inside VM
591+
- `external_validators/` - HTTP-based E2E validation from outside
592+
3. Update: `docs/codebase-architecture.md` - Document new module structure
593+
4. Update module docs in `src/infrastructure/remote_actions/mod.rs` to clarify scope
594+
595+
**Pre-commit**: Run linters, commit
596+
597+
---
598+
599+
## Phase 4: Documentation
600+
601+
**Priority**: High | **Effort**: Low | **Time**: 30 minutes
602+
**Incremental Commits**: 4 commits (one per step)
603+
604+
### Step 4.1: Update Run Command Documentation
475605

476606
**Commit**: `step: [#220] create TrackerHealthService in application layer`
477607

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! External validators module
2+
//!
3+
//! This module contains validators that perform end-to-end validation from
4+
//! OUTSIDE the VM, testing services as an external user would access them.
5+
//!
6+
//! ## Execution Context
7+
//!
8+
//! Unlike `remote_actions` which execute commands INSIDE the VM via SSH,
9+
//! external validators:
10+
//! - Run from the test runner or deployment machine
11+
//! - Test service accessibility via HTTP/HTTPS from outside
12+
//! - Validate end-to-end functionality including network and firewall
13+
//!
14+
//! ## Distinction from Remote Actions
15+
//!
16+
//! **Remote Actions** (`infrastructure/remote_actions/`):
17+
//! - Execute commands via SSH inside the VM
18+
//! - Examples: cloud-init validation, Docker installation checks
19+
//! - Scope: Internal VM state and configuration
20+
//!
21+
//! **External Validators** (this module):
22+
//! - Make HTTP requests from outside the VM
23+
//! - Examples: Service health checks, API accessibility tests
24+
//! - Scope: End-to-end service validation including network/firewall
25+
//!
26+
//! ## Available Validators
27+
//!
28+
//! - `running_services` - Validates Docker Compose services via external HTTP health checks
29+
30+
pub mod running_services;
31+
32+
pub use running_services::RunningServicesValidator;

src/infrastructure/remote_actions/validators/running_services.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl RunningServicesValidator {
182182
"Checking tracker API health endpoint (external from test runner)"
183183
);
184184

185-
let url = format!("http://{server_ip}:{port}/api/health_check");
185+
let url = format!("http://{server_ip}:{port}/api/health_check"); // DevSkim: ignore DS137138
186186
let response =
187187
reqwest::get(&url)
188188
.await
@@ -231,7 +231,7 @@ impl RunningServicesValidator {
231231
"Checking HTTP tracker health endpoint (external from test runner)"
232232
);
233233

234-
let url = format!("http://{server_ip}:{port}/api/health_check");
234+
let url = format!("http://{server_ip}:{port}/api/health_check"); // DevSkim: ignore DS137138
235235
match reqwest::get(&url).await {
236236
Ok(response) if response.status().is_success() => {
237237
info!(

0 commit comments

Comments
 (0)