@@ -32,43 +32,6 @@ use crate::e2e::containers::{RunningProvisionedContainer, StoppedProvisionedCont
3232use crate :: e2e:: environment:: TestEnvironment ;
3333use crate :: infrastructure:: ansible:: AnsibleTemplateRenderer ;
3434
35- /// Create and start a Docker container for E2E testing
36- ///
37- /// This function creates a new Docker container from the provisioned instance image
38- /// and starts it, making it ready for SSH connectivity and configuration testing.
39- ///
40- /// # Returns
41- ///
42- /// Returns a `RunningProvisionedContainer` that can be used for:
43- /// - SSH connectivity testing
44- /// - Ansible configuration
45- /// - Service validation
46- /// - Container cleanup
47- ///
48- /// # Errors
49- ///
50- /// Returns an error if:
51- /// - Container creation fails
52- /// - Container startup fails
53- /// - Docker daemon is not available
54- async fn create_and_start_container ( ) -> Result < RunningProvisionedContainer > {
55- info ! ( "Creating and starting Docker container for E2E testing" ) ;
56-
57- let stopped_container = StoppedProvisionedContainer :: default ( ) ;
58- let running_container = stopped_container
59- . start ( )
60- . await
61- . context ( "Failed to start provisioned instance container" ) ?;
62-
63- info ! (
64- container_id = %running_container. container_id( ) ,
65- ssh_socket_addr = %running_container. ssh_socket_addr( ) ,
66- "Docker container setup completed successfully"
67- ) ;
68-
69- Ok ( running_container)
70- }
71-
7235/// Run provision simulation to prepare templates for container-based testing
7336///
7437/// This function simulates the provision phase specifically for Docker containers
@@ -119,6 +82,7 @@ pub async fn run_provision_simulation(
11982
12083 // Step 1: Setup Docker container
12184 let running_container = create_and_start_container ( ) . await ?;
85+
12286 let socket_addr = running_container. ssh_socket_addr ( ) ;
12387
12488 // Step 2: Establish SSH connectivity
@@ -151,48 +115,42 @@ pub async fn run_provision_simulation(
151115 Ok ( running_container)
152116}
153117
154- /// Render Ansible configuration templates for container-based E2E testing
118+ /// Create and start a Docker container for E2E testing
155119///
156- /// This function renders Ansible templates with the container's connection details,
157- /// preparing the configuration files needed for Ansible playbook execution.
158- /// SSH connectivity is assumed to be already established by the container startup process.
120+ /// This function creates a new Docker container from the provisioned instance image
121+ /// and starts it, making it ready for SSH connectivity and configuration testing.
159122///
160- /// # Arguments
123+ /// # Returns
161124///
162- /// * `ansible_template_renderer` - Renderer for creating Ansible inventory and configuration
163- /// * `ssh_credentials` - SSH credentials for connecting to the container
164- /// * `socket_addr` - Socket address (IP and port) where the container can be reached
125+ /// Returns a `RunningProvisionedContainer` that can be used for:
126+ /// - SSH connectivity testing
127+ /// - Ansible configuration
128+ /// - Service validation
129+ /// - Container cleanup
165130///
166131/// # Errors
167132///
168133/// Returns an error if:
169- /// - Ansible template rendering fails
170- async fn render_ansible_configuration (
171- ansible_template_renderer : Arc < AnsibleTemplateRenderer > ,
172- ssh_credentials : SshCredentials ,
173- socket_addr : SocketAddr ,
174- ) -> Result < ( ) > {
175- info ! (
176- socket_addr = %socket_addr,
177- "Rendering Ansible configuration templates"
178- ) ;
134+ /// - Container creation fails
135+ /// - Container startup fails
136+ /// - Docker daemon is not available
137+ async fn create_and_start_container ( ) -> Result < RunningProvisionedContainer > {
138+ info ! ( "Creating and starting Docker container for E2E testing" ) ;
179139
180- // Step 1: Render Ansible templates with container connection details
181- info ! ( "Rendering Ansible templates for container" ) ;
182- RenderAnsibleTemplatesStep :: new ( ansible_template_renderer, ssh_credentials, socket_addr)
183- . execute ( )
184- . await
185- . context ( "Failed to render Ansible templates for container" ) ?;
140+ let stopped_container = StoppedProvisionedContainer :: default ( ) ;
186141
187- // Note: SSH connectivity check is skipped for Docker containers since
188- // the container setup process already ensures SSH is ready and accessible
142+ let running_container = stopped_container
143+ . start ( )
144+ . await
145+ . context ( "Failed to start provisioned instance container" ) ?;
189146
190147 info ! (
191- socket_addr = %socket_addr,
192- "Ansible configuration templates rendered successfully"
148+ container_id = %running_container. container_id( ) ,
149+ ssh_socket_addr = %running_container. ssh_socket_addr( ) ,
150+ "Docker container setup completed successfully"
193151 ) ;
194152
195- Ok ( ( ) )
153+ Ok ( running_container )
196154}
197155
198156/// Establish SSH connectivity for a running Docker container
@@ -253,3 +211,47 @@ async fn establish_ssh_connectivity(
253211
254212 Ok ( ( ) )
255213}
214+
215+ /// Render Ansible configuration templates for container-based E2E testing
216+ ///
217+ /// This function renders Ansible templates with the container's connection details,
218+ /// preparing the configuration files needed for Ansible playbook execution.
219+ /// SSH connectivity is assumed to be already established by the container startup process.
220+ ///
221+ /// # Arguments
222+ ///
223+ /// * `ansible_template_renderer` - Renderer for creating Ansible inventory and configuration
224+ /// * `ssh_credentials` - SSH credentials for connecting to the container
225+ /// * `socket_addr` - Socket address (IP and port) where the container can be reached
226+ ///
227+ /// # Errors
228+ ///
229+ /// Returns an error if:
230+ /// - Ansible template rendering fails
231+ async fn render_ansible_configuration (
232+ ansible_template_renderer : Arc < AnsibleTemplateRenderer > ,
233+ ssh_credentials : SshCredentials ,
234+ socket_addr : SocketAddr ,
235+ ) -> Result < ( ) > {
236+ info ! (
237+ socket_addr = %socket_addr,
238+ "Rendering Ansible configuration templates"
239+ ) ;
240+
241+ // Step 1: Render Ansible templates with container connection details
242+ info ! ( "Rendering Ansible templates for container" ) ;
243+ RenderAnsibleTemplatesStep :: new ( ansible_template_renderer, ssh_credentials, socket_addr)
244+ . execute ( )
245+ . await
246+ . context ( "Failed to render Ansible templates for container" ) ?;
247+
248+ // Note: SSH connectivity check is skipped for Docker containers since
249+ // the container setup process already ensures SSH is ready and accessible
250+
251+ info ! (
252+ socket_addr = %socket_addr,
253+ "Ansible configuration templates rendered successfully"
254+ ) ;
255+
256+ Ok ( ( ) )
257+ }
0 commit comments