Skip to content

Commit 75a60ce

Browse files
committed
test: propagate errors from any failure
1 parent f3c3d83 commit 75a60ce

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

testinfra/test_ami_nix.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,26 @@ def is_healthy(ssh) -> bool:
361361
result = run_ssh_command(ssh, command)
362362
if not result['succeeded']:
363363
logger.warning(f"{service} not ready")
364+
logger.error(f"{service} command failed with rc={cmd.rc}")
365+
logger.error(f"{service} stdout: {cmd.stdout}")
366+
logger.error(f"{service} stderr: {cmd.stderr}")
367+
368+
# For PostgreSQL, also check the logs and systemd status
369+
if service == "postgres":
370+
logger.error("PostgreSQL logs:")
371+
host.run("sudo cat /var/log/postgresql/postgresql-*.log")
372+
logger.error("PostgreSQL systemd status:")
373+
host.run("sudo systemctl status postgresql")
374+
logger.error("PostgreSQL journal logs:")
375+
host.run("sudo journalctl -u postgresql --no-pager")
376+
364377
return False
365-
except Exception:
366-
logger.warning(f"Connection failed during {service} check")
378+
except Exception as e:
379+
logger.warning(
380+
f"Connection failed during {service} check, attempting reconnect..."
381+
)
382+
logger.error(f"Error details: {str(e)}")
383+
host = get_ssh_connection(instance_ip, ssh_identity_file)
367384
return False
368385

369386
return True

0 commit comments

Comments
 (0)