Skip to content

Commit 67a8076

Browse files
committed
test: propagate errors from any failure
1 parent fb3fee2 commit 67a8076

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

testinfra/test_ami_nix.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,25 @@ def is_healthy(host, instance_ip, ssh_identity_file) -> bool:
325325
cmd = check(host)
326326
if cmd.failed is True:
327327
logger.warning(f"{service} not ready")
328+
logger.error(f"{service} command failed with rc={cmd.rc}")
329+
logger.error(f"{service} stdout: {cmd.stdout}")
330+
logger.error(f"{service} stderr: {cmd.stderr}")
331+
332+
# For PostgreSQL, also check the logs and systemd status
333+
if service == "postgres":
334+
logger.error("PostgreSQL logs:")
335+
host.run("sudo cat /var/log/postgresql/postgresql-*.log")
336+
logger.error("PostgreSQL systemd status:")
337+
host.run("sudo systemctl status postgresql")
338+
logger.error("PostgreSQL journal logs:")
339+
host.run("sudo journalctl -u postgresql --no-pager")
340+
328341
return False
329-
except Exception:
342+
except Exception as e:
330343
logger.warning(
331344
f"Connection failed during {service} check, attempting reconnect..."
332345
)
346+
logger.error(f"Error details: {str(e)}")
333347
host = get_ssh_connection(instance_ip, ssh_identity_file)
334348
return False
335349

0 commit comments

Comments
 (0)