#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" CONTAINER_NAME="hivegrid-platform-notification-redis-$$" cleanup() { docker rm -f "$CONTAINER_NAME" >/dev/null 2>&1 || true } trap cleanup EXIT INT TERM if ! docker info >/dev/null 2>&1; then echo "FAIL Docker is required for the platform notification Redis integration gate." >&2 exit 1 fi echo "PHASE 1/3 starting ephemeral Redis" docker run --rm -d --name "$CONTAINER_NAME" -p "127.0.0.1::6379" redis:7-alpine >/dev/null REDIS_PORT="$(docker port "$CONTAINER_NAME" 6379/tcp | awk -F: 'NR == 1 { print $NF }')" if [[ -z "$REDIS_PORT" ]]; then echo "FAIL Docker did not expose the ephemeral Redis port." >&2 exit 1 fi echo "PHASE 2/3 waiting for Redis readiness" for _ in $(seq 1 50); do if docker exec "$CONTAINER_NAME" redis-cli ping 2>/dev/null | grep -q '^PONG$'; then break fi sleep 0.2 done if ! docker exec "$CONTAINER_NAME" redis-cli ping 2>/dev/null | grep -q '^PONG$'; then echo "FAIL Ephemeral Redis did not become ready." >&2 exit 1 fi echo "PHASE 3/3 running outbox-to-BullMQ retry proof" cd "$ROOT_DIR" PLATFORM_NOTIFICATION_REDIS_URL="redis://127.0.0.1:${REDIS_PORT}/0" \ pnpm exec vitest run apps/worker/src/jobs/platform-notification-redis.integration.test.ts echo "PASS platform notification outbox-to-Redis-to-worker retry gate"