Skip to content

Commit 4995ff0

Browse files
committed
refactor: rename E2E task files to use consistent command naming
- Rename cleanup_docker_container.rs -> cleanup_infrastructure.rs - Rename provision_infrastructure.rs -> run_provision_command.rs - Rename validate_deployment.rs -> run_test_command.rs - Merge run_ansible_configuration.rs and configure_infrastructure.rs into run_configure_command.rs - Update all module imports and references to reflect new file names - Maintain backward compatibility with wrapper functions
1 parent 4b81876 commit 4995ff0

File tree

11 files changed

+48
-71
lines changed

11 files changed

+48
-71
lines changed

src/bin/e2e_config_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ use torrust_tracker_deploy::config::InstanceName;
5353
use torrust_tracker_deploy::e2e::environment::{TestEnvironment, TestEnvironmentType};
5454
use torrust_tracker_deploy::e2e::tasks::{
5555
container::{
56-
cleanup_docker_container::cleanup_docker_container,
56+
cleanup_infrastructure::cleanup_docker_container,
5757
configure_ssh_connectivity::configure_ssh_connectivity,
5858
run_provision_simulation::run_provision_simulation,
5959
setup_docker_container::setup_docker_container,
6060
},
6161
preflight_cleanup,
62-
run_ansible_configuration::run_ansible_configuration,
62+
run_configure_command::run_ansible_configuration,
6363
run_deployment_validation::run_deployment_validation,
6464
};
6565
use torrust_tracker_deploy::logging::{self, LogFormat};

src/bin/e2e_provision_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use torrust_tracker_deploy::e2e::tasks::{
2828
preflight_cleanup::cleanup_lingering_resources,
2929
virtual_machine::{
3030
cleanup_infrastructure::cleanup_infrastructure,
31-
provision_infrastructure::provision_infrastructure,
31+
run_provision_command::provision_infrastructure,
3232
},
3333
};
3434
use torrust_tracker_deploy::logging::{self, LogFormat};

src/bin/e2e_tests_full.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ use tracing::{error, info};
3030
use torrust_tracker_deploy::config::InstanceName;
3131
use torrust_tracker_deploy::e2e::environment::TestEnvironment;
3232
use torrust_tracker_deploy::e2e::tasks::{
33-
configure_infrastructure::configure_infrastructure,
3433
preflight_cleanup::cleanup_lingering_resources,
35-
validate_deployment::validate_deployment,
34+
run_configure_command::configure_infrastructure,
35+
run_test_command::validate_deployment,
3636
virtual_machine::{
3737
cleanup_infrastructure::cleanup_infrastructure,
38-
provision_infrastructure::provision_infrastructure,
38+
run_provision_command::provision_infrastructure,
3939
},
4040
};
4141
use torrust_tracker_deploy::logging::{self, LogFormat};

src/e2e/tasks/configure_infrastructure.rs

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/e2e/tasks/container/cleanup_docker_container.rs renamed to src/e2e/tasks/container/cleanup_infrastructure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use crate::e2e::containers::RunningProvisionedContainer;
3737
/// # Example
3838
///
3939
/// ```rust,no_run
40-
/// use torrust_tracker_deploy::e2e::tasks::container::cleanup_docker_container::cleanup_docker_container;
40+
/// use torrust_tracker_deploy::e2e::tasks::container::cleanup_infrastructure::cleanup_docker_container;
4141
/// use torrust_tracker_deploy::e2e::containers::StoppedProvisionedContainer;
4242
///
4343
/// #[tokio::main]

src/e2e/tasks/container/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
//!
88
//! ## Tasks Overview
99
//!
10-
//! - `cleanup_docker_container` - Stops and cleans up Docker containers after testing
10+
//! - `cleanup_infrastructure` - Stops and cleans up Docker containers after testing
1111
//! - `configure_ssh_connectivity` - Sets up SSH connectivity specifically for containers
1212
//! - `preflight_cleanup` - Container-specific preflight cleanup operations
1313
//! - `provision_docker_infrastructure` - Simulates infrastructure provisioning for containers
1414
//! - `run_provision_simulation` - Simulates provision phase for container-based testing
1515
//! - `setup_docker_container` - Creates and starts Docker containers for testing
1616
17-
pub mod cleanup_docker_container;
17+
pub mod cleanup_infrastructure;
1818
pub mod configure_ssh_connectivity;
1919
pub mod preflight_cleanup;
2020
pub mod provision_docker_infrastructure;

src/e2e/tasks/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,21 @@
1010
//!
1111
//! ### Infrastructure-agnostic tasks (can be used with both containers and VMs):
1212
//! - `clean_and_prepare_templates` - Template cleanup and preparation
13-
//! - `configure_infrastructure` - Infrastructure configuration via Ansible
14-
//! - `run_ansible_configuration` - Ansible playbook execution
13+
//! - `run_configure_command` - Infrastructure configuration via Ansible and playbook execution
1514
//! - `run_deployment_validation` - Deployment validation and testing
1615
//! - `setup_ssh_key` - SSH key generation and setup
17-
//! - `validate_deployment` - Deployment validation and testing
16+
//! - `run_test_command` - Deployment validation and testing
1817
//!
1918
//! ### Container-specific tasks (`container` submodule):
20-
//! - `cleanup_docker_container` - Docker container cleanup
19+
//! - `cleanup_infrastructure` - Docker container cleanup
2120
//! - `configure_ssh_connectivity` - SSH connectivity setup for containers
2221
//! - `provision_docker_infrastructure` - Docker container provisioning simulation
2322
//! - `preflight_cleanup` - Container-specific preflight cleanup
2423
//! - `run_provision_simulation` - Provision simulation for container-based testing
2524
//! - `setup_docker_container` - Docker container setup and startup
2625
//!
2726
//! ### Virtual machine-specific tasks (`virtual_machine` submodule):
28-
//! - `provision_infrastructure` - Infrastructure provisioning via `OpenTofu`
27+
//! - `run_provision_command` - Infrastructure provisioning via `OpenTofu`
2928
//! - `cleanup_infrastructure` - Infrastructure resource cleanup
3029
//! - `preflight_cleanup` - VM-specific preflight cleanup (`OpenTofu` + LXD)
3130
//!
@@ -37,12 +36,11 @@
3736
//! testing coverage of the entire deployment system.
3837
3938
pub mod clean_and_prepare_templates;
40-
pub mod configure_infrastructure;
4139
pub mod container;
4240
pub mod preflight_cleanup;
4341
pub mod preflight_cleanup_common;
44-
pub mod run_ansible_configuration;
42+
pub mod run_configure_command;
4543
pub mod run_deployment_validation;
44+
pub mod run_test_command;
4645
pub mod setup_ssh_key;
47-
pub mod validate_deployment;
4846
pub mod virtual_machine;

src/e2e/tasks/run_ansible_configuration.rs renamed to src/e2e/tasks/run_configure_command.rs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use std::net::SocketAddr;
2727
use std::sync::Arc;
2828

29-
use anyhow::Result;
29+
use anyhow::{Context, Result};
3030
use tracing::{info, warn};
3131

3232
use crate::application::commands::ConfigureCommand;
@@ -61,7 +61,7 @@ use crate::e2e::environment::TestEnvironment;
6161
/// # Example
6262
///
6363
/// ```rust,no_run
64-
/// use torrust_tracker_deploy::e2e::tasks::run_ansible_configuration::run_ansible_configuration;
64+
/// use torrust_tracker_deploy::e2e::tasks::run_configure_command::run_ansible_configuration;
6565
/// use torrust_tracker_deploy::e2e::environment::TestEnvironment;
6666
/// use torrust_tracker_deploy::config::InstanceName;
6767
/// use std::net::{IpAddr, Ipv4Addr, SocketAddr};
@@ -98,7 +98,7 @@ pub fn run_ansible_configuration(
9898
info!(
9999
socket_addr = %socket_addr,
100100
status = "success",
101-
"Ansible configuration completed successfully"
101+
"Configuration completed successfully"
102102
);
103103
} else {
104104
warn!(
@@ -129,3 +129,32 @@ pub fn run_ansible_configuration(
129129

130130
Ok(())
131131
}
132+
133+
/// Configure infrastructure using Ansible playbooks (compatibility wrapper)
134+
///
135+
/// This is a simplified wrapper around the `ConfigureCommand` for use in full E2E tests.
136+
/// For more advanced configuration with success/failure handling, use `run_ansible_configuration`.
137+
///
138+
/// # Errors
139+
///
140+
/// Returns an error if:
141+
/// - `ConfigureCommand` execution fails
142+
/// - Infrastructure configuration fails
143+
pub fn configure_infrastructure(env: &TestEnvironment) -> Result<()> {
144+
info!("Configuring test infrastructure");
145+
146+
// Use the new ConfigureCommand to handle all infrastructure configuration steps
147+
let configure_command = ConfigureCommand::new(Arc::clone(&env.services.ansible_client));
148+
149+
configure_command
150+
.execute()
151+
.map_err(anyhow::Error::from)
152+
.context("Failed to configure infrastructure")?;
153+
154+
info!(
155+
status = "complete",
156+
"Infrastructure configuration completed successfully"
157+
);
158+
159+
Ok(())
160+
}

src/e2e/tasks/virtual_machine/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
88
pub mod cleanup_infrastructure;
99
pub mod preflight_cleanup;
10-
pub mod provision_infrastructure;
10+
pub mod run_provision_command;

0 commit comments

Comments
 (0)