diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-04-09 17:02:15 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-04-09 17:02:24 +0200 |
commit | f724ff6f0129b06108c986c27be64c2b5cae73c9 (patch) | |
tree | d9780a18104a6955023d65f6be4e6f979d78d025 /src/auditor/test-auditor.sh | |
parent | a1270cdc3659986eb6a478f4bb23e53d5001d2ce (diff) |
enable fast-restart of test-auditor
Diffstat (limited to 'src/auditor/test-auditor.sh')
-rwxr-xr-x | src/auditor/test-auditor.sh | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh index ea8637cfa..67bc54e5a 100755 --- a/src/auditor/test-auditor.sh +++ b/src/auditor/test-auditor.sh @@ -2211,32 +2211,45 @@ grep -v host \ > "$TMPDIR/pg_hba.conf.new" mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf" "${POSTGRES_PATH}/pg_ctl" \ - -D "$TMPDIR" \ - -l "${MY_TMP_DIR}/postgres.log" \ - start \ - > "${MY_TMP_DIR}/postgres-start.log" \ - 2> "${MY_TMP_DIR}/postgres-start.err" + -D "$TMPDIR" \ + -l "${MY_TMP_DIR}/postgres.log" \ + start \ + > "${MY_TMP_DIR}/postgres-start.log" \ + 2> "${MY_TMP_DIR}/postgres-start.err" echo " DONE" PGHOST="$TMPDIR/sockets" export PGHOST MYDIR="${MY_TMP_DIR}/basedb" mkdir -p "${MYDIR}" -echo "Generating fresh database at $MYDIR" -if faketime -f '-1 d' ./generate-auditor-basedb.sh -d "$MYDIR/$DB" +if [ -z $REUSE_BASEDB_DIR ] then - echo -n "Reset 'auditor-basedb' database at $PGHOST ..." - dropdb "auditor-basedb" >/dev/null 2>/dev/null || true - createdb "auditor-basedb" || exit_skip "Could not create database '$BASEDB' at $PGHOST" - echo " DONE" - check_with_database "$MYDIR/$DB" - if [ "$fail" != "0" ] + echo "Generating fresh database at $MYDIR" + + if faketime -f '-1 d' ./generate-auditor-basedb.sh -d "$MYDIR/$DB" then - exit "$fail" + echo -n "Reset 'auditor-basedb' database at $PGHOST ..." + dropdb "auditor-basedb" >/dev/null 2>/dev/null || true + createdb "auditor-basedb" || exit_skip "Could not create database '$BASEDB' at $PGHOST" + echo " DONE" + else + echo "Generation failed" + exit 1 fi else - echo "Generation failed" - exit 1 + echo "Reusing existing database from ${REUSE_BASEDB_DIR}" + cp -r "${REUSE_BASEDB_DIR}/basedb"/* "${MYDIR}/" +fi + +check_with_database "$MYDIR/$DB" +if [ "$fail" != "0" ] +then + exit "$fail" +fi + +if [ -z $REUSE_BASEDB_DIR ] +then + echo "Run 'export REUSE_BASEDB_DIR=${MY_TMP_DIR}' to re-run tests against the same database" fi exit 0 |