From f724ff6f0129b06108c986c27be64c2b5cae73c9 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 9 Apr 2024 17:02:15 +0200 Subject: enable fast-restart of test-auditor --- src/auditor/generate-auditor-basedb.sh | 1 - src/auditor/test-auditor.sh | 45 ++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/auditor/generate-auditor-basedb.sh b/src/auditor/generate-auditor-basedb.sh index 65aae3134..bbce37cdc 100755 --- a/src/auditor/generate-auditor-basedb.sh +++ b/src/auditor/generate-auditor-basedb.sh @@ -119,7 +119,6 @@ taler-wallet-cli \ echo " DONE" taler-wallet-cli --wallet-db="$WALLET_DB" run-until-done -taler-wallet-cli --wallet-db="$WALLET_DB" advanced run-pending # Dump database mkdir -p "$(dirname "$BASEDB")" 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 -- cgit v1.2.3