Skip to content

Commit c779d8e

Browse files
committed
test: adding even more logging
1 parent 8b66a45 commit c779d8e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

testinfra/test_ami_nix.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ def is_healthy(host, instance_ip, ssh_identity_file) -> bool:
338338
logger.error(f"systemd status: {systemd_status.stdout}")
339339
logger.error(f"systemd error: {systemd_status.stderr}")
340340

341+
# Get detailed systemd status
342+
logger.error("Detailed systemd status:")
343+
host.run("sudo systemctl status postgresql -l --no-pager")
344+
341345
# Check init script logs
342346
logger.error("Init script logs:")
343347
host.run("sudo journalctl -u cloud-init --no-pager")
@@ -350,6 +354,44 @@ def is_healthy(host, instance_ip, ssh_identity_file) -> bool:
350354
logger.error("Init script status:")
351355
host.run("ls -la /tmp/init.sh")
352356
host.run("cat /tmp/init.sh")
357+
358+
# Check PostgreSQL configuration
359+
logger.error("PostgreSQL configuration:")
360+
host.run("sudo cat /etc/postgresql/*/main/postgresql.conf")
361+
host.run("sudo cat /etc/postgresql/*/main/pg_hba.conf")
362+
363+
# Check PostgreSQL data directory permissions
364+
logger.error("PostgreSQL data directory permissions:")
365+
host.run("sudo ls -la /var/lib/postgresql/*/main/")
366+
367+
# Check PostgreSQL startup logs
368+
logger.error("PostgreSQL startup logs:")
369+
host.run("sudo cat /var/log/postgresql/postgresql-*.log")
370+
371+
# Check systemd journal for PostgreSQL
372+
logger.error("Systemd journal for PostgreSQL:")
373+
host.run("sudo journalctl -u postgresql -n 100 --no-pager")
374+
375+
# Check for any PostgreSQL-related errors in system logs
376+
logger.error("System logs with PostgreSQL errors:")
377+
host.run("sudo journalctl | grep -i postgres | tail -n 100")
378+
379+
# Check for any disk space issues
380+
logger.error("Disk space information:")
381+
host.run("df -h")
382+
host.run("sudo du -sh /var/lib/postgresql/*")
383+
384+
# Check for any memory issues
385+
logger.error("Memory information:")
386+
host.run("free -h")
387+
388+
# Check for any process conflicts
389+
logger.error("Running processes:")
390+
host.run("ps aux | grep postgres")
391+
392+
# Check for any port conflicts
393+
logger.error("Port usage:")
394+
host.run("sudo netstat -tulpn | grep 5432")
353395

354396
if socket_check.failed:
355397
logger.error("PostgreSQL socket directory check failed")

0 commit comments

Comments
 (0)