Skip to content

Commit 6018247

Browse files
committed
test: adding even more logging
1 parent 6db5b45 commit 6018247

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
@@ -410,6 +410,10 @@ def is_healthy(ssh) -> bool:
410410
logger.error(f"systemd status: {systemd_status.stdout}")
411411
logger.error(f"systemd error: {systemd_status.stderr}")
412412

413+
# Get detailed systemd status
414+
logger.error("Detailed systemd status:")
415+
host.run("sudo systemctl status postgresql -l --no-pager")
416+
413417
# Check init script logs
414418
logger.error("Init script logs:")
415419
host.run("sudo journalctl -u cloud-init --no-pager")
@@ -422,6 +426,44 @@ def is_healthy(ssh) -> bool:
422426
logger.error("Init script status:")
423427
host.run("ls -la /tmp/init.sh")
424428
host.run("cat /tmp/init.sh")
429+
430+
# Check PostgreSQL configuration
431+
logger.error("PostgreSQL configuration:")
432+
host.run("sudo cat /etc/postgresql/*/main/postgresql.conf")
433+
host.run("sudo cat /etc/postgresql/*/main/pg_hba.conf")
434+
435+
# Check PostgreSQL data directory permissions
436+
logger.error("PostgreSQL data directory permissions:")
437+
host.run("sudo ls -la /var/lib/postgresql/*/main/")
438+
439+
# Check PostgreSQL startup logs
440+
logger.error("PostgreSQL startup logs:")
441+
host.run("sudo cat /var/log/postgresql/postgresql-*.log")
442+
443+
# Check systemd journal for PostgreSQL
444+
logger.error("Systemd journal for PostgreSQL:")
445+
host.run("sudo journalctl -u postgresql -n 100 --no-pager")
446+
447+
# Check for any PostgreSQL-related errors in system logs
448+
logger.error("System logs with PostgreSQL errors:")
449+
host.run("sudo journalctl | grep -i postgres | tail -n 100")
450+
451+
# Check for any disk space issues
452+
logger.error("Disk space information:")
453+
host.run("df -h")
454+
host.run("sudo du -sh /var/lib/postgresql/*")
455+
456+
# Check for any memory issues
457+
logger.error("Memory information:")
458+
host.run("free -h")
459+
460+
# Check for any process conflicts
461+
logger.error("Running processes:")
462+
host.run("ps aux | grep postgres")
463+
464+
# Check for any port conflicts
465+
logger.error("Port usage:")
466+
host.run("sudo netstat -tulpn | grep 5432")
425467

426468
if socket_check.failed:
427469
logger.error("PostgreSQL socket directory check failed")

0 commit comments

Comments
 (0)