|
1125 | 1125 |
|
1126 | 1126 | TMPDIR_BASE=$(mktemp -d) |
1127 | 1127 |
|
1128 | | - if [[ "$(uname)" == "Darwin" ]]; then |
1129 | | - KEY_DIR="/private/tmp/pgsodium" |
1130 | | - else |
1131 | | - KEY_DIR="''${PGSODIUM_KEY_DIR:-$TMPDIR_BASE/pgsodium}" |
1132 | | - fi |
| 1128 | + KEY_DIR="''${PGSODIUM_KEY_DIR:-$TMPDIR_BASE/pgsodium}" |
1133 | 1129 | KEY_FILE="$KEY_DIR/pgsodium.key" |
1134 | 1130 |
|
1135 | 1131 | if ! mkdir -p "$KEY_DIR" 2>/dev/null; then |
|
1165 | 1161 | name = "start-postgres-server-test"; |
1166 | 1162 | extraSubstitutions = { |
1167 | 1163 | PGSODIUM_GETKEY = "${getkey-script}/bin/pgsodium-getkey"; |
| 1164 | + PGSQL_DEFAULT_PORT = pgPort; |
1168 | 1165 | }; |
1169 | 1166 | }; |
1170 | 1167 |
|
|
1217 | 1214 | # Filter SQL test files |
1218 | 1215 | filteredSqlTests = filterTestFiles majorVersion ./nix/tests/sql; |
1219 | 1216 |
|
| 1217 | + pgPort = if (majorVersion == "17") then |
| 1218 | + "5535" |
| 1219 | + else if (majorVersion == "15") then |
| 1220 | + "5536" |
| 1221 | + else "5537"; |
| 1222 | + |
1220 | 1223 | # Convert filtered tests to a sorted list of basenames (without extension) |
1221 | 1224 | testList = pkgs.lib.mapAttrsToList |
1222 | 1225 | (name: _: |
|
1251 | 1254 | substitute ${./nix/tests/postgresql.conf.in} "$PGTAP_CLUSTER"/postgresql.conf \ |
1252 | 1255 | --subst-var-by PGSODIUM_GETKEY_SCRIPT "${getkey-script}/bin/pgsodium-getkey" |
1253 | 1256 | echo "listen_addresses = '*'" >> "$PGTAP_CLUSTER"/postgresql.conf |
1254 | | - echo "port = ${pgsqlDefaultPort}" >> "$PGTAP_CLUSTER"/postgresql.conf |
| 1257 | + echo "port = ${pgPort}" >> "$PGTAP_CLUSTER"/postgresql.conf |
1255 | 1258 | echo "host all all 127.0.0.1/32 trust" >> $PGTAP_CLUSTER/pg_hba.conf |
1256 | 1259 | echo "Checking shared_preload_libraries setting:" |
1257 | 1260 | grep -rn "shared_preload_libraries" "$PGTAP_CLUSTER"/postgresql.conf |
|
1272 | 1275 |
|
1273 | 1276 | # PostgreSQL startup |
1274 | 1277 | if [[ "$(uname)" == "Darwin" ]]; then |
1275 | | - pg_ctl -D "$PGTAP_CLUSTER" -l "$PGTAP_CLUSTER"/postgresql.log -o "-k "$PGTAP_CLUSTER" -p ${pgsqlDefaultPort} -d 5" start 2>&1 |
| 1278 | + pg_ctl -D "$PGTAP_CLUSTER" -l "$PGTAP_CLUSTER"/postgresql.log -o "-k "$PGTAP_CLUSTER" -p ${pgPort} -d 5" start 2>&1 |
1276 | 1279 | else |
1277 | 1280 | mkdir -p "$PGTAP_CLUSTER/sockets" |
1278 | | - pg_ctl -D "$PGTAP_CLUSTER" -l "$PGTAP_CLUSTER"/postgresql.log -o "-k $PGTAP_CLUSTER/sockets -p ${pgsqlDefaultPort} -d 5" start 2>&1 |
| 1281 | + pg_ctl -D "$PGTAP_CLUSTER" -l "$PGTAP_CLUSTER"/postgresql.log -o "-k $PGTAP_CLUSTER/sockets -p ${pgPort} -d 5" start 2>&1 |
1279 | 1282 | fi || { |
1280 | 1283 | echo "pg_ctl failed to start PostgreSQL" |
1281 | 1284 | echo "Contents of postgresql.log:" |
1282 | 1285 | cat "$PGTAP_CLUSTER"/postgresql.log |
1283 | 1286 | exit 1 |
1284 | 1287 | } |
1285 | 1288 | for i in {1..60}; do |
1286 | | - if pg_isready -h ${pgsqlDefaultHost} -p ${pgsqlDefaultPort}; then |
| 1289 | + if pg_isready -h ${pgsqlDefaultHost} -p ${pgPort}; then |
1287 | 1290 | echo "PostgreSQL is ready" |
1288 | 1291 | break |
1289 | 1292 | fi |
|
1297 | 1300 | exit 1 |
1298 | 1301 | fi |
1299 | 1302 | done |
1300 | | - createdb -p ${pgsqlDefaultPort} -h ${pgsqlDefaultHost} --username=supabase_admin testing |
1301 | | - if ! psql -p ${pgsqlDefaultPort} -h ${pgsqlDefaultHost} --username=supabase_admin -d testing -v ON_ERROR_STOP=1 -Xaf ${./nix/tests/prime.sql}; then |
| 1303 | + createdb -p ${pgPort} -h ${pgsqlDefaultHost} --username=supabase_admin testing |
| 1304 | + if ! psql -p ${pgPort} -h ${pgsqlDefaultHost} --username=supabase_admin -d testing -v ON_ERROR_STOP=1 -Xf ${./nix/tests/prime.sql}; then |
1302 | 1305 | echo "Error executing SQL file. PostgreSQL log content:" |
1303 | 1306 | cat "$PGTAP_CLUSTER"/postgresql.log |
1304 | 1307 | pg_ctl -D "$PGTAP_CLUSTER" stop |
1305 | 1308 | exit 1 |
1306 | 1309 | fi |
1307 | 1310 | SORTED_DIR=$(mktemp -d) |
1308 | 1311 | for t in $(printf "%s\n" ${builtins.concatStringsSep " " sortedTestList}); do |
1309 | | - psql -p ${pgsqlDefaultPort} -h ${pgsqlDefaultHost} --username=supabase_admin -d testing -f "${./nix/tests/sql}/$t.sql" || true |
| 1312 | + psql -p ${pgPort} -h ${pgsqlDefaultHost} --username=supabase_admin -d testing -f "${./nix/tests/sql}/$t.sql" || true |
1310 | 1313 | done |
1311 | 1314 | rm -rf "$SORTED_DIR" |
1312 | 1315 | pg_ctl -D "$PGTAP_CLUSTER" stop |
|
1317 | 1320 | # which is start by the start-postgres-server-bin script |
1318 | 1321 | # start-postgres-server-bin script closely matches our AMI setup, configurations and migrations |
1319 | 1322 |
|
1320 | | - # Ensure pgsodium key directory exists with proper permissions |
1321 | | - if [[ "$(uname)" == "Darwin" ]]; then |
1322 | | - mkdir -p /private/tmp/pgsodium |
1323 | | - chmod 1777 /private/tmp/pgsodium |
1324 | | - fi |
1325 | 1323 | unset GRN_PLUGINS_DIR |
1326 | 1324 | ${start-postgres-server-bin}/bin/start-postgres-server ${getVersionArg pgpkg} --daemonize |
1327 | 1325 |
|
1328 | 1326 | for i in {1..60}; do |
1329 | | - if pg_isready -h ${pgsqlDefaultHost} -p ${pgsqlDefaultPort} -U supabase_admin -q; then |
| 1327 | + if pg_isready -h ${pgsqlDefaultHost} -p ${pgPort} -U supabase_admin -q; then |
1330 | 1328 | echo "PostgreSQL is ready" |
1331 | 1329 | break |
1332 | 1330 | fi |
|
1337 | 1335 | fi |
1338 | 1336 | done |
1339 | 1337 |
|
1340 | | - if ! psql -p ${pgsqlDefaultPort} -h ${pgsqlDefaultHost} --no-password --username=supabase_admin -d postgres -v ON_ERROR_STOP=1 -Xaf ${./nix/tests/prime.sql}; then |
| 1338 | + if ! psql -p ${pgPort} -h ${pgsqlDefaultHost} --no-password --username=supabase_admin -d postgres -v ON_ERROR_STOP=1 -Xf ${./nix/tests/prime.sql}; then |
1341 | 1339 | echo "Error executing SQL file" |
1342 | 1340 | exit 1 |
1343 | 1341 | fi |
|
1349 | 1347 | --inputdir=${./nix/tests} \ |
1350 | 1348 | --outputdir=$out/regression_output \ |
1351 | 1349 | --host=${pgsqlDefaultHost} \ |
1352 | | - --port=${pgsqlDefaultPort} \ |
| 1350 | + --port=${pgPort} \ |
1353 | 1351 | --user=supabase_admin \ |
1354 | 1352 | ${builtins.concatStringsSep " " sortedTestList}; then |
1355 | 1353 | echo "pg_regress tests failed" |
|
1358 | 1356 | fi |
1359 | 1357 |
|
1360 | 1358 | echo "Running migrations tests" |
1361 | | - pg_prove -p ${pgsqlDefaultPort} -U supabase_admin -h ${pgsqlDefaultHost} -d postgres -v ${./migrations/tests}/test.sql |
| 1359 | + pg_prove -p ${pgPort} -U supabase_admin -h ${pgsqlDefaultHost} -d postgres -v ${./migrations/tests}/test.sql |
1362 | 1360 |
|
1363 | 1361 | # Copy logs to output |
1364 | 1362 | for logfile in $(find /tmp -name postgresql.log -type f); do |
|
1382 | 1380 | psql_15 = makeCheckHarness basePackages.psql_15.bin; |
1383 | 1381 | psql_17 = makeCheckHarness basePackages.psql_17.bin; |
1384 | 1382 | psql_orioledb-17 = makeCheckHarness basePackages.psql_orioledb-17.bin; |
| 1383 | + inherit (basePackages) wal-g-2 wal-g-3; |
| 1384 | + } // pkgs.lib.optionalAttrs (system == "aarch64-linux") { |
| 1385 | + inherit (basePackages) postgresql_15_debug postgresql_15_src postgresql_orioledb-17_debug postgresql_orioledb-17_src postgresql_17_debug postgresql_17_src; |
1385 | 1386 | }; |
1386 | 1387 |
|
1387 | 1388 | # Apps is a list of names of things that can be executed with 'nix run'; |
|
0 commit comments