test: add PostgreSQL migration integration coverage
CI / verify (pull_request) Successful in 19s
CI / infrastructure-smoke (pull_request) Successful in 21s
CI / migration-smoke (pull_request) Failing after 16s

This commit is contained in:
ekklesia
2026-07-21 09:37:15 -05:00
parent b38f85f438
commit 831a48187c
16 changed files with 1690 additions and 96 deletions
+13 -58
View File
@@ -5,6 +5,9 @@ set -Eeuo pipefail
repository_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repository_root"
# shellcheck source=scripts/lib/compose-job-network.sh
source "$repository_root/scripts/lib/compose-job-network.sh"
command -v docker >/dev/null || {
echo "Docker is required for the infrastructure smoke test." >&2
exit 1
@@ -50,17 +53,9 @@ compose=(
--env-file .env.example
--file infrastructure/compose.yaml
)
running_in_container=false
current_container=""
compose_network=""
connected_to_compose_network=false
if [[ -f /.dockerenv ]]; then
running_in_container=true
if [[ -z "${HOSTNAME:-}" ]]; then
echo "HOSTNAME is required when the smoke test runs inside a Docker container." >&2
exit 1
fi
current_container="$HOSTNAME"
if ! compose_job_network_initialize; then
echo "The current Docker job container could not be identified." >&2
exit 1
fi
cleanup() {
@@ -70,15 +65,10 @@ cleanup() {
if ((exit_status != 0)); then
"${compose[@]}" logs --no-color >&2 || true
fi
if [[ "$connected_to_compose_network" == "true" ]]; then
if ! cleanup_output="$(
docker network disconnect "$compose_network" "$current_container" 2>&1
)"; then
echo "Infrastructure smoke network cleanup failed:" >&2
echo "$cleanup_output" >&2
if ((exit_status == 0)); then
exit_status=1
fi
if ! compose_job_network_disconnect; then
echo "Infrastructure smoke network cleanup failed." >&2
if ((exit_status == 0)); then
exit_status=1
fi
fi
if ! cleanup_output="$(
@@ -133,46 +123,11 @@ if "${compose[@]}" exec -T \
exit 1
fi
if [[ "$running_in_container" == "true" ]]; then
object_storage_container="$("${compose[@]}" ps -q object-storage)"
if [[ -z "$object_storage_container" ]]; then
echo "Compose did not return the object-storage container ID." >&2
if [[ "$COMPOSE_JOB_NETWORK_RUNNING_IN_CONTAINER" == "true" ]]; then
if ! compose_job_network_connect object-storage "${compose[@]}"; then
echo "The infrastructure smoke job could not join the isolated storage network." >&2
exit 1
fi
network_output="$(
docker inspect \
--format '{{range $networkName, $_ := .NetworkSettings.Networks}}{{println $networkName}}{{end}}' \
"$object_storage_container"
)"
object_storage_networks=()
while IFS= read -r network_name; do
if [[ -n "$network_name" ]]; then
object_storage_networks+=("$network_name")
fi
done <<<"$network_output"
if ((${#object_storage_networks[@]} != 1)); then
echo "Expected object-storage to use exactly one Compose network." >&2
exit 1
fi
compose_network="${object_storage_networks[0]}"
current_network_output="$(
docker inspect \
--format '{{range $networkName, $_ := .NetworkSettings.Networks}}{{println $networkName}}{{end}}' \
"$current_container"
)"
already_connected=false
while IFS= read -r network_name; do
if [[ "$network_name" == "$compose_network" ]]; then
already_connected=true
break
fi
done <<<"$current_network_output"
if [[ "$already_connected" != "true" ]]; then
docker network connect "$compose_network" "$current_container"
connected_to_compose_network=true
fi
s3_endpoint="http://object-storage:8333"
else
s3_binding="$("${compose[@]}" port object-storage 8333)"