Skip to content

Commit 98d1d72

Browse files
committed
refactor: remove emojis and implement structured logging in e2e tests
- Remove all emoji characters from logging messages across the codebase - Replace emoji-based logging with structured tracing fields - Eliminate decorative headers for cleaner, machine-readable output - Implement consistent field naming: operation, stage, action, status, component - Update e2e tests, command execution, SSH connectivity, and validation modules - Add clippy allow annotation for long function in docker_compose validation The logging output is now suitable for JSON formatting and automated processing.
1 parent 7b947f7 commit 98d1d72

File tree

9 files changed

+340
-99
lines changed

9 files changed

+340
-99
lines changed

src/actions/cloud_init.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ impl RemoteAction for CloudInitValidator {
3030
}
3131

3232
async fn execute(&self, _server_ip: &IpAddr) -> Result<(), RemoteActionError> {
33-
info!("🔍 Validating cloud-init completion...");
33+
info!(
34+
action = "cloud_init_validation",
35+
"Validating cloud-init completion"
36+
);
3437

3538
// Check cloud-init status
3639
let status_output = self
@@ -64,9 +67,21 @@ impl RemoteAction for CloudInitValidator {
6467
});
6568
}
6669

67-
info!("✅ Cloud-init validation passed");
68-
info!(" ✓ Cloud-init status is 'done'");
69-
info!(" ✓ Completion marker file exists");
70+
info!(
71+
action = "cloud_init_validation",
72+
status = "success",
73+
"Cloud-init validation passed"
74+
);
75+
info!(
76+
action = "cloud_init_validation",
77+
check = "status_done",
78+
"Cloud-init status is 'done'"
79+
);
80+
info!(
81+
action = "cloud_init_validation",
82+
check = "completion_marker",
83+
"Completion marker file exists"
84+
);
7085

7186
Ok(())
7287
}

src/actions/docker.rs

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,43 @@ impl RemoteAction for DockerValidator {
3030
}
3131

3232
async fn execute(&self, _server_ip: &IpAddr) -> Result<(), RemoteActionError> {
33-
info!("🔍 Validating Docker installation...");
33+
info!(
34+
action = "docker_validation",
35+
"Validating Docker installation"
36+
);
3437

3538
// Check Docker version
3639
let Ok(docker_version) = self.ssh_client.execute("docker --version") else {
37-
warn!("⚠️ Docker installation validation skipped");
38-
warn!(" ℹ️ This is expected in CI environments with network limitations");
39-
warn!(" ℹ️ The playbook ran successfully but Docker installation was skipped");
40+
warn!(
41+
action = "docker_validation",
42+
status = "skipped",
43+
reason = "ci_network_limitations",
44+
"Docker installation validation skipped"
45+
);
46+
warn!(
47+
action = "docker_validation",
48+
note = "expected_in_ci",
49+
"This is expected in CI environments with network limitations"
50+
);
51+
warn!(
52+
action = "docker_validation",
53+
note = "playbook_success",
54+
"The playbook ran successfully but Docker installation was skipped"
55+
);
4056
return Ok(()); // Don't fail the test, just skip validation
4157
};
4258

4359
let docker_version = docker_version.trim();
44-
info!("✅ Docker installation validated");
45-
info!(" ✓ Docker version: {docker_version}");
60+
info!(
61+
action = "docker_validation",
62+
status = "success",
63+
"Docker installation validated"
64+
);
65+
info!(
66+
action = "docker_validation",
67+
version = docker_version,
68+
"Docker version detected"
69+
);
4670

4771
// Check Docker daemon status (only if Docker is installed)
4872
let daemon_active = self
@@ -54,9 +78,18 @@ impl RemoteAction for DockerValidator {
5478
})?;
5579

5680
if daemon_active {
57-
info!(" ✓ Docker daemon is active");
81+
info!(
82+
action = "docker_validation",
83+
check = "daemon_active",
84+
"Docker daemon is active"
85+
);
5886
} else {
59-
warn!(" ⚠️ Docker daemon check skipped (service may not be running)");
87+
warn!(
88+
action = "docker_validation",
89+
check = "daemon_skipped",
90+
reason = "service_not_running",
91+
"Docker daemon check skipped"
92+
);
6093
}
6194

6295
Ok(())

src/actions/docker_compose.rs

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ impl RemoteAction for DockerComposeValidator {
2929
"docker-compose-validation"
3030
}
3131

32+
#[allow(clippy::too_many_lines)]
3233
async fn execute(&self, _server_ip: &IpAddr) -> Result<(), RemoteActionError> {
33-
info!("🔍 Validating Docker Compose installation...");
34+
info!(
35+
action = "docker_compose_validation",
36+
"Validating Docker Compose installation"
37+
);
3438

3539
// First check if Docker is available (Docker Compose requires Docker)
3640
let docker_available =
@@ -42,23 +46,47 @@ impl RemoteAction for DockerComposeValidator {
4246
})?;
4347

4448
if !docker_available {
45-
warn!("⚠️ Docker Compose validation skipped");
46-
warn!(" ℹ️ Docker is not available, so Docker Compose cannot be validated");
47-
warn!(" ℹ️ This is expected in CI environments with network limitations");
49+
warn!(
50+
action = "docker_compose_validation",
51+
status = "skipped",
52+
reason = "docker_unavailable",
53+
"Docker Compose validation skipped"
54+
);
55+
warn!(
56+
action = "docker_compose_validation",
57+
note = "dependency_missing",
58+
"Docker is not available, so Docker Compose cannot be validated"
59+
);
60+
warn!(
61+
action = "docker_compose_validation",
62+
note = "expected_in_ci",
63+
"This is expected in CI environments with network limitations"
64+
);
4865
return Ok(()); // Don't fail the test, just skip validation
4966
}
5067

5168
// Check Docker Compose version
5269
let Ok(compose_version) = self.ssh_client.execute("docker-compose --version") else {
5370
warn!(
54-
"⚠️ Docker Compose not found, this is expected if Docker installation was skipped"
71+
action = "docker_compose_validation",
72+
status = "not_found",
73+
note = "expected_if_docker_skipped",
74+
"Docker Compose not found, this is expected if Docker installation was skipped"
5575
);
5676
return Ok(()); // Don't fail, just note the situation
5777
};
5878

5979
let compose_version = compose_version.trim();
60-
info!("✅ Docker Compose installation validated");
61-
info!(" ✓ Docker Compose version: {compose_version}");
80+
info!(
81+
action = "docker_compose_validation",
82+
status = "success",
83+
"Docker Compose installation validated"
84+
);
85+
info!(
86+
action = "docker_compose_validation",
87+
version = compose_version,
88+
"Docker Compose version detected"
89+
);
6290

6391
// Test basic docker-compose functionality with a simple test file (only if Docker is working)
6492
let test_compose_content = r"services:
@@ -78,7 +106,12 @@ impl RemoteAction for DockerComposeValidator {
78106
})?;
79107

80108
if !create_test_success {
81-
warn!(" ⚠️ Could not create test docker-compose.yml file");
109+
warn!(
110+
action = "docker_compose_validation",
111+
check = "test_file_creation",
112+
status = "failed",
113+
"Could not create test docker-compose.yml file"
114+
);
82115
return Ok(()); // Don't fail, just skip the functional test
83116
}
84117

@@ -92,9 +125,19 @@ impl RemoteAction for DockerComposeValidator {
92125
})?;
93126

94127
if validate_success {
95-
info!(" ✓ Docker Compose configuration validation passed");
128+
info!(
129+
action = "docker_compose_validation",
130+
check = "configuration_validation",
131+
status = "success",
132+
"Docker Compose configuration validation passed"
133+
);
96134
} else {
97-
warn!(" ⚠️ Docker Compose configuration validation skipped");
135+
warn!(
136+
action = "docker_compose_validation",
137+
check = "configuration_validation",
138+
status = "skipped",
139+
"Docker Compose configuration validation skipped"
140+
);
98141
}
99142

100143
// Clean up test file

src/ansible/template_renderer.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ impl AnsibleTemplateRenderer {
170170
template_manager: &TemplateManager,
171171
inventory_context: &InventoryContext,
172172
) -> Result<(), ConfigurationTemplateError> {
173-
tracing::info!("🎭 Stage 3: Rendering configuration templates with variables...");
173+
tracing::info!(
174+
stage = "configuration_rendering",
175+
template_type = "ansible",
176+
"Rendering configuration templates with variables"
177+
);
174178

175179
// Create build directory structure
176180
let build_ansible_dir = self.create_build_directory().await?;
@@ -183,19 +187,30 @@ impl AnsibleTemplateRenderer {
183187
.await?;
184188

185189
tracing::debug!(
186-
" ✅ Configuration templates rendered to: {}",
187-
build_ansible_dir.display()
190+
stage = "configuration_rendering",
191+
template_type = "ansible",
192+
output_dir = %build_ansible_dir.display(),
193+
"Configuration templates rendered"
188194
);
189195
tracing::debug!(
190-
" ✅ Inventory rendered with IP: {}",
191-
inventory_context.ansible_host()
196+
stage = "configuration_rendering",
197+
template_type = "ansible_inventory",
198+
ansible_host = %inventory_context.ansible_host(),
199+
"Inventory rendered with IP"
192200
);
193201
tracing::debug!(
194-
" ✅ Inventory rendered with SSH key: {}",
195-
inventory_context.ansible_ssh_private_key_file()
202+
stage = "configuration_rendering",
203+
template_type = "ansible_inventory",
204+
ssh_key = %inventory_context.ansible_ssh_private_key_file(),
205+
"Inventory rendered with SSH key"
196206
);
197207

198-
tracing::info!("✅ Stage 3 complete: Configuration templates ready");
208+
tracing::info!(
209+
stage = "configuration_rendering",
210+
template_type = "ansible",
211+
status = "complete",
212+
"Configuration templates ready"
213+
);
199214
Ok(())
200215
}
201216

0 commit comments

Comments
 (0)