diff --git a/scripts/test_infra_monitoring.sh b/scripts/test_infra_monitoring.sh index 3b3226f..636dc99 100755 --- a/scripts/test_infra_monitoring.sh +++ b/scripts/test_infra_monitoring.sh @@ -127,7 +127,23 @@ assert "Docker Stats probed at port 9324 via SSH" \ assert "PVE Exporter probed at port 9221 via SSH" \ 'grep -q "9221" "$SSH_LOG"' -# ── 5a. Stale port 9323 (dockerd) NOT probed ────────────────────────────── +# ── 5a. Per-leg assertions (proves which leg owns which port) ────────────── +# The script source must show Docker Stats using $DOCKER_STATS_PORT and +# PVE Exporter using $PVE_EXPORTER_PORT in the correct leg sections +assert "Docker Stats leg uses DOCKER_STATS_PORT constant" \ + 'grep -A 3 "# 6. Docker Stats" "$SCRIPT" | grep -q "\$DOCKER_STATS_PORT"' + +assert "PVE Exporter leg uses PVE_EXPORTER_PORT constant" \ + 'grep -A 3 "# 7. PVE Exporter" "$SCRIPT" | grep -q "\$PVE_EXPORTER_PORT"' + +# Verify the constants themselves are set to the correct values +assert "DOCKER_STATS_PORT constant set to 9324" \ + 'grep -q "^DOCKER_STATS_PORT=\"9324\"" "$SCRIPT"' + +assert "PVE_EXPORTER_PORT constant set to 9221" \ + 'grep -q "^PVE_EXPORTER_PORT=\"9221\"" "$SCRIPT"' + +# ── 5b. Stale port 9323 (dockerd) NOT probed ────────────────────────────── assert "Port 9323 (dockerd) NOT in SSH log" \ '! grep -q "9323" "$SSH_LOG"'