Skip to content

Commit e2cd585

Browse files
committed
refactor: move Services container to src/testing/e2e/
The Services dependency injection container was located in src/bootstrap/ but it's only used in E2E tests (src/testing/e2e/). This refactor moves it to its actual usage location for better code organization. Changes: - Moved src/bootstrap/container.rs -> src/testing/e2e/container.rs - Updated imports to use relative paths within e2e module - Removed container module from bootstrap (no longer used there) - Updated documentation references to new location Rationale: - Services is exclusively used for E2E testing scenarios - In production, services are created on-demand per command - This makes the codebase structure more accurate and explicit
1 parent e29b300 commit e2cd585

File tree

7 files changed

+20
-12
lines changed

7 files changed

+20
-12
lines changed

src/bootstrap/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
//! Bootstrap Module
22
//!
33
//! This module contains application initialization and bootstrap concerns.
4-
//! It handles application lifecycle, dependency injection, logging setup,
5-
//! and help display.
4+
//! It handles application lifecycle, logging setup, and help display.
65
//!
76
//! ## Modules
87
//!
98
//! - `app` - Main application bootstrap and entry point logic
10-
//! - `container` - Service container for dependency injection
119
//! - `help` - Help and usage information display
1210
//! - `logging` - Logging configuration and initialization
1311
1412
pub mod app;
15-
pub mod container;
1613
pub mod help;
1714
pub mod logging;
1815

1916
// Re-export commonly used types for convenience
20-
pub use container::Services;
2117
pub use logging::{LogFormat, LogOutput, LoggingBuilder, LoggingConfig};

src/config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::path::PathBuf;
2525
/// Centralizes all deployment-related configuration including file paths,
2626
/// service connection details, and runtime behavior settings.
2727
///
28-
/// Created once at deployment start and passed to [`Services::new()`](crate::bootstrap::container::Services::new).
28+
/// Created once at deployment start and passed to [`Services::new()`](crate::testing::e2e::container::Services::new).
2929
pub struct Config {
3030
/// Directory containing template files for rendering configurations.
3131
///
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
//! Dependency injection container for deployment services
1+
//! Dependency injection container for testing services
22
//!
33
//! This module provides the `Services` struct that acts as a dependency injection container,
4-
//! holding all the service clients and template renderers needed for deployment operations.
5-
//! It centralizes service construction and makes them easily accessible throughout the application.
4+
//! holding all the service clients and template renderers needed for E2E testing operations.
5+
//! It centralizes service construction and makes them easily accessible throughout tests.
66
//!
77
//! ## Services Included
88
//!
99
//! - **Command clients**: `OpenTofu`, LXD, Ansible clients for external tool interaction
1010
//! - **Template services**: Template manager and specialized renderers for different tools
1111
//! - **Configuration**: Centralized configuration management
12+
//!
13+
//! ## Usage in Tests
14+
//!
15+
//! This container is primarily used in E2E tests to create all necessary service dependencies
16+
//! in a consistent way. In production, services are created on-demand depending on which
17+
//! command the user is executing.
1218
1319
use std::sync::Arc;
1420
use std::time::Duration;
@@ -36,7 +42,7 @@ use crate::shared::Clock;
3642
/// TODO: Make this configurable via Config in the future
3743
const REPOSITORY_LOCK_TIMEOUT_SECS: u64 = 30;
3844

39-
/// Service clients and renderers for performing actions
45+
/// Service clients and renderers for performing actions in tests
4046
pub struct Services {
4147
// Command wrappers
4248
pub opentofu_client: Arc<OpenTofuClient>,

src/testing/e2e/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use tempfile::TempDir;
2424
use tracing::{info, warn};
2525

26-
use crate::bootstrap::container::Services;
26+
use super::container::Services;
2727
use crate::config::Config;
2828
use crate::domain::environment::state::AnyEnvironmentState;
2929
use crate::domain::Environment;

src/testing/e2e/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//!
77
//! ## Module Structure
88
//!
9+
//! - `container` - Service dependency injection container for E2E tests
910
//! - `context` - Test context configuration and management
1011
//! - `containers` - Container management for E2E testing scenarios
1112
//! - `tasks` - High-level testing tasks and workflows
@@ -16,9 +17,13 @@
1617
//! provisioning, configuration, validation, and cleanup phases to ensure
1718
//! the entire deployment system works correctly.
1819
20+
pub mod container;
1921
pub mod containers;
2022
pub mod context;
2123
pub mod tasks;
2224

25+
// Re-export for convenience
26+
pub use container::Services;
27+
2328
// Re-export provisioned container types for backward compatibility
2429
pub use containers::{ContainerError, RunningProvisionedContainer, StoppedProvisionedContainer};

src/testing/e2e/tasks/container/run_provision_simulation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use tracing::info;
2525

2626
use crate::adapters::ssh::SshCredentials;
2727
use crate::application::steps::RenderAnsibleTemplatesStep;
28-
use crate::bootstrap::container::Services;
2928
use crate::infrastructure::external_tools::ansible::AnsibleTemplateRenderer;
29+
use crate::testing::e2e::container::Services;
3030
use crate::testing::e2e::containers::actions::{SshKeySetupAction, SshWaitAction};
3131
use crate::testing::e2e::containers::timeout::ContainerTimeouts;
3232
use crate::testing::e2e::containers::{RunningProvisionedContainer, StoppedProvisionedContainer};

src/testing/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub use network::{PortChecker, PortCheckerError, PortUsageChecker, PortUsageErro
2323

2424
// Re-export E2E types for convenience
2525
pub use e2e::{
26+
container::Services,
2627
containers::{ContainerError, RunningProvisionedContainer, StoppedProvisionedContainer},
2728
context::{TestContext, TestContextType},
2829
};

0 commit comments

Comments
 (0)