Skip to content

Commit 95fca05

Browse files
committed
refactor: rename deployment validation to configuration validation
- Rename run_deployment_validation module to run_configuration_validation - Rename run_deployment_validation function to run_configuration_validation - Extract validate_docker_installation and validate_docker_compose_installation functions - Update all module references and imports throughout codebase - Update documentation to reflect new naming conventions The new naming better reflects that this validates the configuration of installed software rather than the deployment process itself.
1 parent 6554b54 commit 95fca05

File tree

4 files changed

+94
-34
lines changed

4 files changed

+94
-34
lines changed

docs/refactors/e2e-config-tests-cleanup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ This refactor plan outlines the improvements needed for `src/bin/e2e_config_test
120120

121121
- **Task**: Replace nested match statements with `?` operator
122122
- **Pattern**: Convert `match result { Ok(x) => ..., Err(e) => return Err(...) }` to direct `?` usage
123-
- **Focus**: `run_ansible_configuration()` and `run_deployment_validation()` ✅
123+
- **Focus**: `run_ansible_configuration()` and `run_configuration_validation()` ✅
124124

125125
**Status**:COMPLETE - Replaced nested match patterns with `?` operator in both functions, improved readability
126126

src/bin/e2e_config_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use torrust_tracker_deploy::e2e::tasks::{
5858
run_provision_simulation::run_provision_simulation,
5959
},
6060
preflight_cleanup,
61-
run_deployment_validation::run_deployment_validation,
61+
run_configuration_validation::run_configuration_validation,
6262
};
6363
use torrust_tracker_deploy::logging::{self, LogFormat};
6464

@@ -167,9 +167,9 @@ async fn run_configuration_tests(test_env: &TestEnvironment) -> Result<()> {
167167
// Step 2: Run Ansible configuration
168168
run_configure_command(test_env)?;
169169

170-
// Step 3: Run deployment validation
170+
// Step 3: Run configuration validation
171171
let socket_addr = running_container.ssh_socket_addr();
172-
run_deployment_validation(socket_addr, &test_env.config.ssh_credentials).await?;
172+
run_configuration_validation(socket_addr, &test_env.config.ssh_credentials).await?;
173173

174174
// Step 4: Cleanup container
175175
cleanup_infrastructure(running_container);

src/e2e/tasks/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//!
1111
//! ### Infrastructure-agnostic tasks (can be used with both containers and VMs):
1212
//! - `run_configure_command` - Infrastructure configuration via Ansible and playbook execution
13-
//! - `run_deployment_validation` - Deployment validation and testing
13+
//! - `run_configuration_validation` - Configuration validation and testing
1414
//! - `run_test_command` - Deployment validation and testing
1515
//!
1616
//! ### Container-specific tasks (`container` submodule):
@@ -28,7 +28,7 @@
2828
2929
pub mod container;
3030
pub mod preflight_cleanup;
31+
pub mod run_configuration_validation;
3132
pub mod run_configure_command;
32-
pub mod run_deployment_validation;
3333
pub mod run_test_command;
3434
pub mod virtual_machine;

src/e2e/tasks/run_deployment_validation.rs renamed to src/e2e/tasks/run_configuration_validation.rs

Lines changed: 88 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! Deployment validation task for E2E testing
1+
//! Configuration validation task for E2E testing
22
//!
3-
//! This module provides the E2E testing task for validating that deployments
4-
//! are working correctly after configuration. It performs comprehensive checks
3+
//! This module provides the E2E testing task for validating that configurations
4+
//! are working correctly after deployment. It performs comprehensive checks
55
//! to ensure all required services and components are properly installed and running.
66
//!
77
//! ## Key Operations
@@ -29,9 +29,84 @@ use crate::infrastructure::remote_actions::{
2929
DockerComposeValidator, DockerValidator, RemoteAction,
3030
};
3131

32-
/// Run deployment validation tests on a configured instance
32+
/// Validate Docker installation on a configured instance
3333
///
34-
/// This function performs comprehensive validation of a deployed instance,
34+
/// This function validates that Docker is properly installed and functioning
35+
/// on the target instance by connecting via SSH and running validation commands.
36+
///
37+
/// # Arguments
38+
///
39+
/// * `ip_addr` - IP address of the target instance
40+
/// * `ssh_credentials` - SSH credentials for connecting to the instance
41+
///
42+
/// # Returns
43+
///
44+
/// Returns `Ok(())` when Docker validation passes successfully.
45+
///
46+
/// # Errors
47+
///
48+
/// Returns an error if:
49+
/// - SSH connection cannot be established
50+
/// - Docker validation fails (not installed or not working)
51+
async fn validate_docker_installation(
52+
ip_addr: std::net::IpAddr,
53+
ssh_credentials: &SshCredentials,
54+
port: u16,
55+
) -> Result<()> {
56+
info!("Validating Docker installation");
57+
58+
let ssh_connection = ssh_credentials.clone().with_host_and_port(ip_addr, port);
59+
60+
let docker_validator = DockerValidator::new(ssh_connection);
61+
docker_validator
62+
.execute(&ip_addr)
63+
.await
64+
.context("Docker validation failed")?;
65+
66+
Ok(())
67+
}
68+
69+
/// Validate Docker Compose installation on a configured instance
70+
///
71+
/// This function validates that Docker Compose is properly installed and functioning
72+
/// on the target instance by connecting via SSH and running validation commands.
73+
///
74+
/// # Arguments
75+
///
76+
/// * `ip_addr` - IP address of the target instance
77+
/// * `ssh_credentials` - SSH credentials for connecting to the instance
78+
/// * `port` - SSH port to connect to
79+
///
80+
/// # Returns
81+
///
82+
/// Returns `Ok(())` when Docker Compose validation passes successfully.
83+
///
84+
/// # Errors
85+
///
86+
/// Returns an error if:
87+
/// - SSH connection cannot be established
88+
/// - Docker Compose validation fails (not installed or not working)
89+
async fn validate_docker_compose_installation(
90+
ip_addr: std::net::IpAddr,
91+
ssh_credentials: &SshCredentials,
92+
port: u16,
93+
) -> Result<()> {
94+
info!("Validating Docker Compose installation");
95+
96+
let ssh_connection = ssh_credentials.clone().with_host_and_port(ip_addr, port);
97+
98+
let compose_validator = DockerComposeValidator::new(ssh_connection);
99+
compose_validator
100+
.execute(&ip_addr)
101+
.await
102+
.context("Docker Compose validation failed")?;
103+
104+
Ok(())
105+
}
106+
107+
/// Run configuration validation tests on a configured instance
108+
///
109+
/// This function performs comprehensive validation of a configured instance,
35110
/// checking that all required services and components are properly installed
36111
/// and functioning. It uses SSH to connect to the target instance and run
37112
/// validation commands.
@@ -56,7 +131,7 @@ use crate::infrastructure::remote_actions::{
56131
/// # Example
57132
///
58133
/// ```rust,no_run
59-
/// use torrust_tracker_deploy::e2e::tasks::run_deployment_validation::run_deployment_validation;
134+
/// use torrust_tracker_deploy::e2e::tasks::run_configuration_validation::run_configuration_validation;
60135
/// use torrust_tracker_deploy::config::SshCredentials;
61136
/// use std::net::{IpAddr, Ipv4Addr, SocketAddr};
62137
///
@@ -69,48 +144,33 @@ use crate::infrastructure::remote_actions::{
69144
/// "testuser".to_string()
70145
/// );
71146
///
72-
/// run_deployment_validation(socket_addr, &ssh_credentials).await?;
73-
/// println!("All deployment validations passed");
147+
/// run_configuration_validation(socket_addr, &ssh_credentials).await?;
148+
/// println!("All configuration validations passed");
74149
/// Ok(())
75150
/// }
76151
/// ```
77-
pub async fn run_deployment_validation(
152+
pub async fn run_configuration_validation(
78153
socket_addr: SocketAddr,
79154
ssh_credentials: &SshCredentials,
80155
) -> Result<()> {
81156
info!(
82157
socket_addr = %socket_addr,
83158
ssh_user = %ssh_credentials.ssh_username,
84-
"Running deployment validation tests"
159+
"Running configuration validation tests"
85160
);
86161

87162
let ip_addr = socket_addr.ip();
88163

89-
// Create SSH connection with the instance's address and port
90-
let ssh_connection = ssh_credentials
91-
.clone()
92-
.with_host_and_port(ip_addr, socket_addr.port());
93-
94164
// Validate Docker installation
95-
info!("Validating Docker installation");
96-
let docker_validator = DockerValidator::new(ssh_connection.clone());
97-
docker_validator
98-
.execute(&ip_addr)
99-
.await
100-
.context("Docker validation failed")?;
165+
validate_docker_installation(ip_addr, ssh_credentials, socket_addr.port()).await?;
101166

102167
// Validate Docker Compose installation
103-
info!("Validating Docker Compose installation");
104-
let compose_validator = DockerComposeValidator::new(ssh_connection);
105-
compose_validator
106-
.execute(&ip_addr)
107-
.await
108-
.context("Docker Compose validation failed")?;
168+
validate_docker_compose_installation(ip_addr, ssh_credentials, socket_addr.port()).await?;
109169

110170
info!(
111171
socket_addr = %socket_addr,
112172
status = "success",
113-
"All deployment validation tests passed successfully"
173+
"All configuration validation tests passed successfully"
114174
);
115175

116176
Ok(())

0 commit comments

Comments
 (0)