pg_orrery/test/pg-version-matrix.sh
Ryan Malloy b18cded4c2 Add PG version test matrix (14-18)
Shell script drives the Dockerfile builder stage across PG versions,
capturing pass/fail + timing per version. Makefile targets: test-matrix,
test-pg%, test-matrix-clean. Also runs standalone DE reader test in the
builder stage to catch compiler-version regressions.

Fix pork chop grid test: add ORDER BY to CROSS JOIN (optimizer chooses
different join nesting across PG versions, reordering rows).
2026-02-17 14:53:32 -07:00

93 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# test/pg-version-matrix.sh — Test pg_orrery across PostgreSQL versions
#
# Uses the Dockerfile builder stage as the test engine: compile, install,
# initdb, installcheck, and standalone DE reader test for each PG version.
#
# Usage:
# ./test/pg-version-matrix.sh # Test PG 14-18
# PG_VERSIONS="16 17" ./test/pg-version-matrix.sh # Subset
# ./test/pg-version-matrix.sh --no-cache # Force fresh builds
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
LOG_DIR="$SCRIPT_DIR/matrix-logs"
PG_VERSIONS="${PG_VERSIONS:-14 15 16 17 18}"
# Parse flags
DOCKER_EXTRA_ARGS=()
for arg in "$@"; do
case "$arg" in
--no-cache) DOCKER_EXTRA_ARGS+=(--no-cache) ;;
*) echo "Unknown flag: $arg" >&2; exit 1 ;;
esac
done
mkdir -p "$LOG_DIR"
# Track results: "version status seconds"
declare -a RESULTS=()
FAILURES=0
echo "pg_orrery version matrix"
echo "========================"
echo "Versions: $PG_VERSIONS"
echo "Logs: $LOG_DIR/"
echo ""
for ver in $PG_VERSIONS; do
log="$LOG_DIR/pg${ver}.log"
printf "Testing PG %-4s... " "$ver"
start=$(date +%s)
if docker build \
--build-arg PG_MAJOR="$ver" \
--target builder \
"${DOCKER_EXTRA_ARGS[@]}" \
-t "pg_orrery-test:pg${ver}" \
"$PROJECT_DIR" \
> "$log" 2>&1; then
end=$(date +%s)
elapsed=$((end - start))
printf "PASS (%ds)\n" "$elapsed"
RESULTS+=("$ver PASS $elapsed")
else
end=$(date +%s)
elapsed=$((end - start))
printf "FAIL (%ds) -> %s\n" "$elapsed" "$log"
RESULTS+=("$ver FAIL $elapsed")
FAILURES=$((FAILURES + 1))
fi
done
# Summary table
echo ""
echo "Summary"
echo "-------"
printf "%-6s %-6s %s\n" "PG" "Result" "Time"
printf "%-6s %-6s %s\n" "---" "------" "----"
for entry in "${RESULTS[@]}"; do
read -r ver status secs <<< "$entry"
printf "%-6s %-6s %ds\n" "$ver" "$status" "$secs"
done
# Cleanup test images
echo ""
echo "Cleaning test images..."
for ver in $PG_VERSIONS; do
docker rmi "pg_orrery-test:pg${ver}" >/dev/null 2>&1 || true
done
if [ "$FAILURES" -gt 0 ]; then
echo ""
echo "$FAILURES version(s) failed. Check logs in $LOG_DIR/"
exit 1
fi
echo ""
echo "All versions passed."