Skip to content

Commit 4e5c3f4

Browse files
committed
test: move logging here
1 parent 1f4f065 commit 4e5c3f4

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

testinfra/test_ami_nix.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,7 @@ def is_healthy(host, instance_ip, ssh_identity_file) -> bool:
302302
# Then check if the socket directory exists and has correct permissions
303303
h.run("sudo ls -la /run/postgresql"),
304304
# Then try pg_isready
305-
h.run("sudo -u postgres /usr/bin/pg_isready -U postgres"),
306-
# Check Nix profile setup
307-
h.run("echo 'Check Nix profile setup'"),
308-
h.run("sudo -u postgres ls -la /home/postgres/.nix-profile"),
309-
h.run("sudo -u postgres ls -la /home/postgres/.nix-profile/bin"),
310-
h.run("sudo -u postgres test -x /home/postgres/.nix-profile/bin/switch_pg_cron_version"),
311-
h.run("sudo -u postgres cat /home/postgres/.nix-profile/bin/switch_pg_cron_version")
305+
h.run("sudo -u postgres /usr/bin/pg_isready -U postgres")
312306
),
313307
),
314308
(
@@ -339,6 +333,20 @@ def is_healthy(host, instance_ip, ssh_identity_file) -> bool:
339333
# For PostgreSQL, we need to check multiple things
340334
systemd_status, socket_check, pg_isready = check(host)
341335

336+
# Log Nix profile setup checks
337+
logger.info("Checking Nix profile setup:")
338+
nix_profile_result = host.run("sudo -u postgres ls -la /home/postgres/.nix-profile")
339+
logger.info(f"Nix profile directory:\n{nix_profile_result.stdout}\n{nix_profile_result.stderr}")
340+
341+
nix_bin_result = host.run("sudo -u postgres ls -la /home/postgres/.nix-profile/bin")
342+
logger.info(f"Nix profile bin directory:\n{nix_bin_result.stdout}\n{nix_bin_result.stderr}")
343+
344+
nix_script_result = host.run("sudo -u postgres test -x /home/postgres/.nix-profile/bin/switch_pg_cron_version")
345+
logger.info(f"Switch script executable check: {'success' if not nix_script_result.failed else 'failed'}")
346+
347+
nix_script_output = host.run("sudo -u postgres /home/postgres/.nix-profile/bin/switch_pg_cron_version")
348+
logger.info(f"Switch script output:\n{nix_script_output.stdout}\n{nix_script_output.stderr}")
349+
342350
if systemd_status.failed:
343351
logger.error("PostgreSQL systemd service is not active")
344352
logger.error(f"systemd status: {systemd_status.stdout}")

0 commit comments

Comments
 (0)