#!/usr/bin/env bash set -euo pipefail repo_root="$(cd "$(dirname "$0")/.." && pwd)" container_name="cosmic-clash-redis-integration" cleanup() { # -v matters: the container runs with --rm, which would reclaim its # anonymous volume on a normal exit, but this trap force-removes it instead # and `docker rm -f` alone leaves the volume behind. Each run then leaks one # throwaway database volume, which accumulates silently until the Docker VM # disk fills and the next container fails to start -- surfacing only as this # script's own readiness timeout, never as a disk error. See # multiplayer-next.md ยง9 gotcha 52. docker rm -f -v "$container_name" >/dev/null 2>&1 || true } trap cleanup EXIT cleanup docker run --rm -d --name "$container_name" \ -p 56379:6379 redis:7-alpine >/dev/null for attempt in $(seq 1 30); do if docker exec "$container_name" redis-cli ping >/dev/null 2>&1; then break fi if [ "$attempt" = 30 ]; then echo "Redis did not become ready" >&2 exit 1 fi sleep 1 done cd "$repo_root/server" COSMIC_CLASH_REDIS_ADDR="127.0.0.1:56379" \ go test -tags integration ./store -run TestRealRedis -count=1