Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx9FNLG2CqeBbVGGd9bFsP
31 lines
891 B
Bash
Executable File
31 lines
891 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Runs the store tests against a throwaway Postgres 16 container.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
name=nmon-test-pg
|
|
port=55432
|
|
|
|
docker rm -f "$name" >/dev/null 2>&1 || true
|
|
trap 'docker rm -f "$name" >/dev/null 2>&1 || true' EXIT
|
|
|
|
docker run --rm -d --name "$name" -p "$port:5432" \
|
|
-e POSTGRES_USER=nmon -e POSTGRES_PASSWORD=nmon -e POSTGRES_DB=nmon postgres:16 >/dev/null
|
|
|
|
# The image restarts the server once after init, so require two consecutive successes.
|
|
ok=0
|
|
for _ in $(seq 1 60); do
|
|
if docker exec "$name" pg_isready -U nmon -d nmon -q 2>/dev/null; then
|
|
ok=$((ok + 1))
|
|
[ "$ok" -ge 2 ] && break
|
|
else
|
|
ok=0
|
|
fi
|
|
sleep 1
|
|
done
|
|
[ "$ok" -ge 2 ] || { echo "postgres did not become ready" >&2; exit 1; }
|
|
|
|
NMON_TEST_PG_DSN="postgres://nmon:nmon@localhost:$port/nmon?sslmode=disable" \
|
|
go test -race -count=1 ${NMON_TEST_FLAGS:-} ./internal/store/...
|