#!/usr/bin/env bash set -euo pipefail # Usage: postgres-check.sh [--full|--sanitizer|--suite-only] # postgres-check.sh --life-reservations-only [] # postgres-check.sh --population-only # postgres-check.sh --migration-faults (private loopback TLS) # --full (default) is the complete qualification: the C++ suite, the backup, DR and # upgrade process checks, then the SQL-only migration, permission and checksum checks. # --sanitizer keeps everything that runs the binaries built beside the test binary # (the C++ suite and the backup/DR/upgrade checks, which spawn that evo-server and # evo-world-clone) and drops the SQL-only checks, which do not change with compiler # flags. --suite-only runs just the C++ suite (for the uninstrumented analysis build). root="$(cd "$(dirname "$0")/../.." && pwd)" mode=full case "${1:-}" in --migration-faults) mode=migration-faults; shift ;; --population-only) mode=population; shift ;; --full) shift ;; --sanitizer) mode=sanitizer; shift ;; --suite-only) mode=suite-only; shift ;; --life-reservations-only) mode=life-reservations ;; esac # Per-phase wall-clock timing; the summary is printed on success and on failure. phase_names=() phase_secs=() phase_name=setup phase_start=$SECONDS run_start=$SECONDS phase() { phase_names+=("$phase_name") phase_secs+=($((SECONDS - phase_start))) phase_name=$1 phase_start=$SECONDS echo "postgres-check[$mode]: phase $phase_name" } timing_summary() { local i phase_names+=("$phase_name") phase_secs+=($((SECONDS - phase_start))) echo "postgres-check[$mode] timing ($1):" for i in "${!phase_names[@]}"; do printf ' %-28s %5ds\n' "${phase_names[$i]}" "${phase_secs[$i]}" done printf ' %-28s %5ds\n' total $((SECONDS - run_start)) } prefix="$root/.cache/postgres/install" export PATH="$prefix/bin:$PATH" export LD_LIBRARY_PATH="$prefix/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" test_dir="$(mktemp -d /tmp/evo-pg-test.XXXXXXXX)" chmod 700 "$test_dir" export PGHOST="$test_dir" PGPORT=55432 PGDATABASE=postgres PGUSER="$(id -un)" unset PGHOSTADDR PGPASSWORD PGSERVICE PGSERVICEFILE unset EVO_MIGRATION_TCP_PORT EVO_MIGRATION_CA initdb -D "$test_dir/data" --no-locale --encoding=UTF8 --auth-local=trust --auth-host=reject > "$test_dir/init.log" trap 'rc=$?; timing_summary "exit $rc" >&2; pg_ctl -D "$test_dir/data" -m immediate stop > /dev/null || true' EXIT if [ "$mode" = migration-faults ]; then # One disposable cluster only; the owner remains Unix-socket-only. No production # credential or adapter TLS exception. The relay forwards encrypted bytes. openssl req -x509 -newkey rsa:2048 -nodes -days 1 -subj /CN=localhost \ -addext 'subjectAltName=DNS:localhost,IP:127.0.0.1' \ -keyout "$test_dir/server.key" -out "$test_dir/server.crt" > "$test_dir/tls.log" 2>&1 chmod 600 "$test_dir/server.key" PGPORT="$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1])')" export PGPORT EVO_MIGRATION_TCP_PORT="$PGPORT" EVO_MIGRATION_CA="$test_dir/server.crt" printf '%s\n' 'local all all trust' \ 'hostssl postgres evo_runtime_login 127.0.0.1/32 trust' \ 'host all all 127.0.0.1/32 reject' 'host all all ::1/128 reject' > "$test_dir/data/pg_hba.conf" pg_ctl -D "$test_dir/data" -l "$test_dir/server.log" \ -o "-k $test_dir -p $PGPORT -c listen_addresses=127.0.0.1 -c ssl=on -c ssl_cert_file=$test_dir/server.crt -c ssl_key_file=$test_dir/server.key" -w start else pg_ctl -D "$test_dir/data" -l "$test_dir/server.log" -o "-k $test_dir -p 55432 -c listen_addresses=''" -w start fi # Runtime group role receives grants; a separate login inherits only that role. psql -X -v ON_ERROR_STOP=1 -c 'CREATE ROLE evo_runtime_test NOLOGIN' \ -c 'CREATE ROLE evo_runtime_login LOGIN IN ROLE evo_runtime_test' export EVO_PG_RUNTIME_ROLE=evo_runtime_test EVO_PG_RUNTIME_USER=evo_runtime_login phase migrate bash "$root/tools/migrate-postgres.sh" bash "$root/tools/migrate-postgres.sh" # exact supported upgrade/restart is a no-op if [ "$mode" = life-reservations ]; then phase life-reservations if [ "$#" = 2 ]; then "$2" --life-reservations-only; fi psql -X -v ON_ERROR_STOP=1 -f "$root/tools/ci/life-reservations-check.sql" > /dev/null bash "$root/tools/ci/life-reservations-concurrency.sh" exit 0 fi if [ "$mode" = population ] || [ "$mode" = migration-faults ]; then phase population "$1" --population-only exit 0 fi # M7.9 clone target: a separate database with its own runtime group and login, # so a clone shares neither the source's database nor its runtime credentials. psql -X -v ON_ERROR_STOP=1 -c 'CREATE ROLE evo_clone_runtime NOLOGIN' -c 'CREATE ROLE evo_clone_login LOGIN IN ROLE evo_clone_runtime' createdb evo_clone (export PGDATABASE=evo_clone EVO_PG_RUNTIME_ROLE=evo_clone_runtime; bash "$root/tools/migrate-postgres.sh") export EVO_PG_CLONE_DATABASE=evo_clone EVO_PG_CLONE_RUNTIME_USER=evo_clone_login # The online migration test (M7.9b) runs the checked-in migrations from here. export EVO_SOURCE_ROOT="$root" # Process tests spawn the server and clone tool built beside the test binary. export EVO_SERVER_BIN EVO_WORLD_CLONE_BIN EVO_SERVER_BIN="$(dirname "${1:?path to evo-postgres-tests}")/evo-server" EVO_WORLD_CLONE_BIN="$(dirname "$1")/evo-world-clone" phase cxx-suite if ! "$1"; then echo 'PostgreSQL integration tests failed; recent disposable-cluster server log:' >&2 tail -n 80 "$test_dir/server.log" >&2 || true exit 1 fi if [ "$mode" = suite-only ]; then echo "postgres-check[suite-only]: $1 passed; process and SQL checks run in --full" exit 0 fi if [ "$mode" = full ] || [ "$mode" = sanitizer ]; then phase migration-partitions bash "$root/tools/ci/postgres-check.sh" --migration-faults "$1" fi if [ "$mode" = full ]; then phase life-reservations psql -X -v ON_ERROR_STOP=1 -f "$root/tools/ci/life-reservations-check.sql" > /dev/null bash "$root/tools/ci/life-reservations-concurrency.sh" fi phase backup-check # Schema 51: isolated database namespace adoption/forks and effective privileges. bash "$root/tools/ci/history-domain-check.sh" # M8.7: online backup under load, restore on a separate cluster, isolated rebuild. bash "$root/tools/ci/backup-check.sh" phase dr-check # M8.8: host-loss rehearsal: in-place restore, fenced old environment, measured rewind. bash "$root/tools/ci/dr-check.sh" phase upgrade-check # M8.9: failed migration under load and the version barrier with real hosts. bash "$root/tools/ci/upgrade-check.sh" if [ "$mode" = sanitizer ]; then echo "postgres-check[sanitizer]: suite and process checks passed; SQL-only checks run in --full" exit 0 fi phase migration-history v1_sha="$(sha256sum "$root/migrations/0001_region_bootstrap.sql")" v1_sha="${v1_sha%% *}" # Migration failure must not publish a partial schema. createdb migration_rollback if (export PGDATABASE=migration_rollback; psql -X -v ON_ERROR_STOP=1 -1 \ -v migration_sha=invalid -f "$root/migrations/0001_region_bootstrap.sql"); then echo 'Expected failed migration' >&2; exit 1 fi test "$(PGDATABASE=migration_rollback psql -XAtc "SELECT count(*) FROM pg_namespace WHERE nspname='evolution'")" = 0 # A privileged or owner runtime role is refused and leaves no schema behind. if (export PGDATABASE=migration_rollback EVO_PG_RUNTIME_ROLE="$PGUSER"; \ bash "$root/tools/migrate-postgres.sh"); then echo 'Expected privileged runtime role rejection' >&2; exit 1 fi if (export PGDATABASE=migration_rollback EVO_PG_RUNTIME_ROLE=no_such_evo_role; \ bash "$root/tools/migrate-postgres.sh"); then echo 'Expected missing runtime role rejection' >&2; exit 1 fi test "$(PGDATABASE=migration_rollback psql -XAtc "SELECT count(*) FROM pg_namespace WHERE nspname='evolution'")" = 0 # Supported upgrade path: an existing exact v1 database migrates to the latest. createdb upgrade_path PGDATABASE=upgrade_path psql -X -v ON_ERROR_STOP=1 -1 -v "migration_sha=$v1_sha" \ -f "$root/migrations/0001_region_bootstrap.sql" > /dev/null test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',') FROM evolution.schema_migrations")" = 1 PGDATABASE=upgrade_path bash "$root/tools/migrate-postgres.sh" test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 # v2 heads have no payload binding: v2->v3 fails closed and leaves history at v2. v2_sha="$(sha256sum "$root/migrations/0002_region_fencing.sql")" v2_sha="${v2_sha%% *}" createdb v2_heads PGDATABASE=v2_heads psql -X -v ON_ERROR_STOP=1 -1 -v "migration_sha=$v1_sha" -v "migration_sha_2=$v2_sha" -v runtime_role=evo_runtime_test -f "$root/migrations/0001_region_bootstrap.sql" -f "$root/migrations/0002_region_fencing.sql" > /dev/null PGDATABASE=v2_heads psql -X -v ON_ERROR_STOP=1 -c "SELECT evolution.provision_region(1, 1, 1, gen_random_uuid(), decode(repeat('00', 32), 'hex'))" > /dev/null if PGDATABASE=v2_heads bash "$root/tools/migrate-postgres.sh"; then echo 'Expected v2 heads to block v3' >&2; exit 1 fi v3_sha="$(sha256sum "$root/migrations/0003_region_checkpoints.sql")" v3_sha="${v3_sha%% *}" createdb v3_commits PGDATABASE=v3_commits psql -X -v ON_ERROR_STOP=1 -1 -v "migration_sha=$v1_sha" \ -v "migration_sha_2=$v2_sha" -v "migration_sha_3=$v3_sha" -v runtime_role=evo_runtime_test \ -f "$root/migrations/0001_region_bootstrap.sql" -f "$root/migrations/0002_region_fencing.sql" \ -f "$root/migrations/0003_region_checkpoints.sql" > /dev/null PGDATABASE=v3_commits psql -X -v ON_ERROR_STOP=1 \ -c "INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex'))" \ -c "SELECT evolution.provision_region_checkpoint(decode('4145564f52434d31' || '01000000' || '01000000' || '0100000000000000' || '0100000000000000' || '0900000000000000' || repeat('11', 16) || repeat('00', 8) || repeat('00', 16) || repeat('00', 32) || repeat('00', 16) || repeat('00', 16) || repeat('00', 8) || '50c3000000000000' || '020000000200000001000000010000000100000001000000010000000100000001000000' || repeat('b1', 32) || '00000000' || '00000000' || '01000000' || '6400000000000000' || repeat('a0', 32), 'hex'))" > /dev/null PGDATABASE=v3_commits bash "$root/tools/migrate-postgres.sh" test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 54:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) FROM evolution.region_commits")" = 1 # Review P1: a v4 database holding a published (possibly terminal) checkpoint has # no durable decisions for it. The v5 upgrade must refuse before changing anything. v4_sha="$(sha256sum "$root/migrations/0004_lineage_profile.sql")" v4_sha="${v4_sha%% *}" createdb v4_published PGDATABASE=v4_published psql -X -v ON_ERROR_STOP=1 -1 -v "migration_sha=$v1_sha" \ -v "migration_sha_2=$v2_sha" -v "migration_sha_3=$v3_sha" -v "migration_sha_4=$v4_sha" \ -v runtime_role=evo_runtime_test \ -f "$root/migrations/0001_region_bootstrap.sql" -f "$root/migrations/0002_region_fencing.sql" \ -f "$root/migrations/0003_region_checkpoints.sql" -f "$root/migrations/0004_lineage_profile.sql" > /dev/null PGDATABASE=v4_published psql -X -v ON_ERROR_STOP=1 > /dev/null <<'SQL' INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex')); SELECT evolution.provision_region_checkpoint(decode('4145564f52434d31' || '01000000' || '01000000' || '0100000000000000' || '0100000000000000' || '0900000000000000' || repeat('11', 16) || repeat('00', 8) || repeat('00', 16) || repeat('00', 32) || repeat('00', 16) || repeat('00', 16) || repeat('00', 8) || '50c3000000000000' || '020000000200000001000000010000000100000001000000010000000100000001000000' || repeat('b1', 32) || '00000000' || '00000000' || '01000000' || '6400000000000000' || repeat('a0', 32), 'hex')); SELECT lease_holder, lease_epoch FROM evolution.acquire_region_lease(1, 1, 20000) \gset -- A real v4 publication of ticks 0..20 through the v4 fenced function. SELECT p.* FROM evolution.region_commits c, LATERAL evolution.publish_region_checkpoint( overlay(overlay(overlay(overlay(overlay(overlay(overlay(c.manifest placing decode(repeat('22', 16), 'hex') from 41) placing decode('0100000000000000', 'hex') from 57) placing decode(repeat('11', 16), 'hex') from 65) placing c.commit_digest from 81) placing decode('1400000000000000', 'hex') from 121) placing decode(replace(:'lease_holder', '-', ''), 'hex') from 129) placing decode('0100000000000000', 'hex') from 145)) p WHERE c.commit_sequence = 0; SQL test "$(PGDATABASE=v4_published psql -XAtc "SELECT count(*) FROM evolution.region_commits")" = 2 if PGDATABASE=v4_published bash "$root/tools/migrate-postgres.sh" 2> "$test_dir/v4_published.err"; then echo 'Expected pre-v5 published checkpoints to block v5' >&2; exit 1 fi grep -q 'pre-v5 published checkpoints lack durable decisions' "$test_dir/v4_published.err" test "$(PGDATABASE=v4_published psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4 test "$(PGDATABASE=v4_published psql -XAtc "SELECT count(*) || ':' || max(end_tick) FROM evolution.region_commits")" = 2:20 test "$(PGDATABASE=v4_published psql -XAtc "SELECT count(*) FROM pg_tables WHERE schemaname = 'evolution' AND tablename = 'region_decisions'")" = 0 test "$(PGDATABASE=v2_heads psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2 # M7.9: a populated v6 database (genesis at sequence 0, tick 0) upgrades to v7 in # place; the replaced head constraint still admits it and the v7 parser reads it. v5_sha="$(sha256sum "$root/migrations/0005_batch_decisions.sql")" v5_sha="${v5_sha%% *}" v6_sha="$(sha256sum "$root/migrations/0006_commit_lookup.sql")" v6_sha="${v6_sha%% *}" createdb v6_populated PGDATABASE=v6_populated psql -X -v ON_ERROR_STOP=1 -1 -v "migration_sha=$v1_sha" \ -v "migration_sha_2=$v2_sha" -v "migration_sha_3=$v3_sha" -v "migration_sha_4=$v4_sha" \ -v "migration_sha_5=$v5_sha" -v "migration_sha_6=$v6_sha" -v runtime_role=evo_runtime_test \ -f "$root/migrations/0001_region_bootstrap.sql" -f "$root/migrations/0002_region_fencing.sql" \ -f "$root/migrations/0003_region_checkpoints.sql" -f "$root/migrations/0004_lineage_profile.sql" \ -f "$root/migrations/0005_batch_decisions.sql" -f "$root/migrations/0006_commit_lookup.sql" > /dev/null PGDATABASE=v6_populated psql -X -v ON_ERROR_STOP=1 \ -c "INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex'))" \ -c "SELECT evolution.provision_region_checkpoint(decode('4145564f52434d31' || '02000000' || '01000000' || '0100000000000000' || '0100000000000000' || '0900000000000000' || repeat('11', 16) || repeat('00', 8) || repeat('00', 16) || repeat('00', 32) || repeat('00', 16) || repeat('00', 16) || repeat('00', 8) || '50c3000000000000' || '020000000200000001000000010000000100000001000000010000000100000001000000' || repeat('b1', 32) || '00000000' || '00000000' || '01000000' || '6400000000000000' || repeat('a0', 32) || repeat('00', 80), 'hex'))" > /dev/null PGDATABASE=v6_populated bash "$root/tools/migrate-postgres.sh" test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54 test "$(PGDATABASE=v6_populated psql -XAtc "SELECT count(*) FROM evolution.region_commits c, LATERAL evolution.parse_checkpoint_manifest(c.manifest) m WHERE m.commit_sequence = 0 AND m.predecessor_commit IS NULL")" = 1 test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(conname, ',') FROM pg_constraint WHERE conrelid = 'evolution.region_heads'::regclass AND contype = 'c' AND pg_get_constraintdef(oid) LIKE '%end_tick%'")" = region_heads_published_tick phase permission-audit # Inherited privileges bypass fencing, so every migrate run audits effective rights. psql -X -v ON_ERROR_STOP=1 -c 'CREATE ROLE evo_bad_runtime NOLOGIN IN ROLE pg_write_all_data' if (export PGDATABASE=migration_rollback EVO_PG_RUNTIME_ROLE=evo_bad_runtime; \ bash "$root/tools/migrate-postgres.sh"); then echo 'Expected inherited-privilege runtime rejection' >&2; exit 1 fi test "$(PGDATABASE=migration_rollback psql -XAtc "SELECT count(*) FROM pg_namespace WHERE nspname='evolution'")" = 0 expect_audit_failure() { psql -X -v ON_ERROR_STOP=1 -c "$1" if bash "$root/tools/migrate-postgres.sh"; then echo "Expected runtime audit failure after: $1" >&2; exit 1 fi psql -X -v ON_ERROR_STOP=1 -c "$2" } # The reviewed scenario: the login inherits pg_write_all_data and can bypass the guard. psql -X -v ON_ERROR_STOP=1 -c 'GRANT pg_write_all_data TO evo_runtime_login' PGUSER=evo_runtime_login psql -X -v ON_ERROR_STOP=1 \ -c 'UPDATE evolution.region_leases SET epoch = 99 WHERE false' > /dev/null psql -X -v ON_ERROR_STOP=1 -c 'REVOKE pg_write_all_data FROM evo_runtime_login' expect_audit_failure 'GRANT pg_write_all_data TO evo_runtime_login' \ 'REVOKE pg_write_all_data FROM evo_runtime_login' expect_audit_failure 'GRANT pg_write_all_data TO evo_runtime_test WITH INHERIT FALSE' \ 'REVOKE pg_write_all_data FROM evo_runtime_test' expect_audit_failure 'GRANT UPDATE ON evolution.region_heads TO PUBLIC' \ 'REVOKE UPDATE ON evolution.region_heads FROM PUBLIC' expect_audit_failure 'GRANT EXECUTE ON FUNCTION evolution.check_region_lease(evolution.u64, evolution.u64, uuid, evolution.u64) TO evo_runtime_test' \ 'REVOKE EXECUTE ON FUNCTION evolution.check_region_lease(evolution.u64, evolution.u64, uuid, evolution.u64) FROM evo_runtime_test' expect_audit_failure 'ALTER ROLE evo_runtime_login CREATEDB' 'ALTER ROLE evo_runtime_login NOCREATEDB' expect_audit_failure 'GRANT EXECUTE ON FUNCTION evolution.provision_region_checkpoint(bytea) TO evo_runtime_test' 'REVOKE EXECUTE ON FUNCTION evolution.provision_region_checkpoint(bytea) FROM evo_runtime_test' expect_audit_failure 'GRANT SELECT ON evolution.region_commits TO evo_runtime_test' 'REVOKE SELECT ON evolution.region_commits FROM evo_runtime_test' # Schema v12: probe records and transfers are reachable only through the fenced functions. expect_audit_failure 'GRANT SELECT ON evolution.probe_records TO evo_runtime_test' 'REVOKE SELECT ON evolution.probe_records FROM evo_runtime_test' expect_audit_failure 'GRANT UPDATE ON evolution.probe_transfers TO evo_runtime_test' 'REVOKE UPDATE ON evolution.probe_transfers FROM evo_runtime_test' # Schema v11: action records are reachable only through the fenced functions. expect_audit_failure 'GRANT SELECT ON evolution.region_actions TO evo_runtime_test' 'REVOKE SELECT ON evolution.region_actions FROM evo_runtime_test' expect_audit_failure 'GRANT SELECT ON evolution.region_commit_actions TO evo_runtime_test' 'REVOKE SELECT ON evolution.region_commit_actions FROM evo_runtime_test' expect_audit_failure 'GRANT EXECUTE ON FUNCTION evolution.check_action_block(bytea, numeric, numeric) TO evo_runtime_test' 'REVOKE EXECUTE ON FUNCTION evolution.check_action_block(bytea, numeric, numeric) FROM evo_runtime_test' # Schema v19/v20: find_region_action_record is a granted fenced lookup; the cellular # action-block validator behind publication is not. expect_audit_failure 'GRANT EXECUTE ON FUNCTION evolution.check_cellular_action_block(bytea, numeric, numeric) TO evo_runtime_test' 'REVOKE EXECUTE ON FUNCTION evolution.check_cellular_action_block(bytea, numeric, numeric) FROM evo_runtime_test' # Schema v29 mutation reservations and their publication history are fenced. expect_audit_failure 'GRANT SELECT ON evolution.cellular_mutation_reservations TO evo_runtime_test' 'REVOKE SELECT ON evolution.cellular_mutation_reservations FROM evo_runtime_test' expect_audit_failure 'GRANT SELECT ON evolution.cellular_mutation_action_publications TO evo_runtime_test' 'REVOKE SELECT ON evolution.cellular_mutation_action_publications FROM evo_runtime_test' # Schema v10: account controls are reachable only through the three fenced functions. expect_audit_failure 'GRANT SELECT ON evolution.account_controls TO evo_runtime_test' 'REVOKE SELECT ON evolution.account_controls FROM evo_runtime_test' expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.claim_account_control(evolution.u64, evolution.u64, uuid, evolution.u64, uuid, evolution.u64, evolution.u64, integer) FROM evo_runtime_test' 'GRANT EXECUTE ON FUNCTION evolution.claim_account_control(evolution.u64, evolution.u64, uuid, evolution.u64, uuid, evolution.u64, evolution.u64, integer) TO evo_runtime_test' bash "$root/tools/migrate-postgres.sh" # Restored configuration passes the audit again. # Schema 50: registry access is granted only through the bounded read function. expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.load_world_region_catalog_v1(evolution.u64) FROM evo_runtime_test' 'GRANT EXECUTE ON FUNCTION evolution.load_world_region_catalog_v1(evolution.u64) TO evo_runtime_test' expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.load_history_domain_v1() FROM evo_runtime_test' 'GRANT EXECUTE ON FUNCTION evolution.load_history_domain_v1() TO evo_runtime_test' expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.load_world_cellular_migrations_v1(evolution.u64) FROM evo_runtime_test' 'GRANT EXECUTE ON FUNCTION evolution.load_world_cellular_migrations_v1(evolution.u64) TO evo_runtime_test' expect_audit_failure 'GRANT EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) TO evo_runtime_test' 'REVOKE EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) FROM evo_runtime_test' phase checksum-drift # Unknown future versions and checksum drift must not be repaired silently. psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=55 WHERE version=54' if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=54 WHERE version=55" psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=14" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=13" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=12" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=11" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=10" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=9" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=8" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=7" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=6" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=5" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=4" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=3" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=2" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64)" if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi echo 'postgres migrations, rollback, constraints, permissions, fencing, checkpoints and outcomes passed'