mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
test(multiplayer): add real-Redis integration coverage for the candidate index
Every existing RedisCandidateIndex test runs against miniredis -- a
from-scratch Go reimplementation of the Redis command set, not real
Redis's own float64 score encoding, TTL/expiry, or RESP behavior.
Add an opt-in integration suite (mirroring postgres_integration_test.go's
pattern: //go:build integration, COSMIC_CLASH_REDIS_ADDR-gated) plus
scripts/run_redis_integration.sh against a disposable redis:7-alpine
container, covering:
- upsert/snapshot/remove against a real server
- a real TTL actually waited out (not miniredis's manual
FastForward), proving expiry really happens on the wire
- the documented 'Redis restart or lost keyspace' repair path
exercised against an actual FLUSHALL, not a simulated empty map,
including that the repair actually persists back to Redis (a
second snapshot reads it without a second durable-source call)
Verified stable across 3 runs with -race against a real container.
This commit is contained in:
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
container_name="cosmic-clash-redis-integration"
|
||||
|
||||
cleanup() {
|
||||
docker rm -f "$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
|
||||
Reference in New Issue
Block a user