#!/bin/bash # Versions to test versions=( $@ ) # If we weren't given any versions, test them all if [ ${#versions[@]} -eq 0 ] then versions=( 9.2 9.4 9.6 10 11 12 13 14 15 16 17 ) fi # Image tags to use declare -A images=() images["9.2"]='9.2' images["9.3"]='9.3' images["9.4"]='9.4' images["9.5"]='9.5' images["9.6"]='9.6-bullseye' images["10"]='10-bullseye' images["11"]='11-bookworm' images["12"]='12-bookworm' images["13"]='13-bookworm' images["14"]='14-bookworm' images["15"]='15-bookworm' images["16"]='16-bookworm' images["17"]='17-bookworm' declare -A results=() # Make sure everything's down to start with docker compose down # Make sure our agent container is up to date docker compose build agent for version in "${versions[@]}" do echo echo "Testing: PostgreSQL ${version}" # Specify the version we're testing against export PGTAG="${images["$version"]}" # Start the db container first and wait a moment for it to initialize # This isn't perfect, but if the health check catches PostgreSQL when it's # first being initialized, the agent can fail to connect. # A better solution would probably be to make the agent retry more. docker compose up -d db sleep 2 # Start the containers docker compose up --exit-code-from=agent agent rc=$? results["$version"]=$rc # Destroy the containers docker compose down done echo echo for v in "${versions[@]}" do case "${results["$v"]}" in 0) msg="OK" ;; 1) msg="Query failure detected" ;; 18) msg="Docker image error: 18" ;; *) msg="Unexpected error: ${results["$v"]}" ;; esac echo "$v -> $msg" done