diff options
Diffstat (limited to 'src/auditor/test-revocation.sh')
-rwxr-xr-x | src/auditor/test-revocation.sh | 107 |
1 files changed, 17 insertions, 90 deletions
diff --git a/src/auditor/test-revocation.sh b/src/auditor/test-revocation.sh index a1970e100..06e2b5ae0 100755 --- a/src/auditor/test-revocation.sh +++ b/src/auditor/test-revocation.sh @@ -46,45 +46,12 @@ TESTS=${1:-$ALL_TESTS} VALGRIND="" LOGLEVEL="INFO" -# Exit, with status code "skip" (no 'real' failure) -function exit_skip() { - echo "SKIPPING test: $1" - exit 77 -} - -# Exit, with error message (hard failure) -function exit_fail() { - echo "FAILING test: $1" - exit 1 -} - -function stop_libeufin() -{ - echo "killing libeufin..." - if test -f "${MYDIR:-/}/libeufin-sandbox.pid" - then - echo "Killing libeufin sandbox" - PID=$(cat "${MYDIR}/libeufin-sandbox.pid" 2> /dev/null) - rm "${MYDIR}/libeufin-sandbox.pid" - kill "$PID" 2> /dev/null || true - wait "$PID" || true - fi - if test -f "${MYDIR:-/}/libeufin-nexus.pid" - then - echo "Killing libeufin nexus" - PID=$(cat "${MYDIR}/libeufin-nexus.pid" 2> /dev/null) - rm "${MYDIR}/libeufin-nexus.pid" - kill "$PID" 2> /dev/null || true - wait "$PID" || true - fi - echo "killing libeufin DONE" -} - +. setup.sh # Cleanup to run whenever we exit function cleanup() { - if test ! -z "${EPID:-}" + if [ ! -z "${EPID:-}" ] then echo -n "Stopping exchange $EPID..." kill -TERM "$EPID" @@ -99,7 +66,7 @@ function cleanup() function exit_cleanup() { echo "Running exit-cleanup" - if test ! -z "${POSTGRES_PATH:-}" + if [ ! -z "${POSTGRES_PATH:-}" ] then echo "Stopping Postgres at ${POSTGRES_PATH}" "${POSTGRES_PATH}/pg_ctl" \ @@ -121,31 +88,6 @@ function exit_cleanup() # Install cleanup handler (except for kill -9) trap exit_cleanup EXIT -# Downloads new transactions from the bank. -function nexus_fetch_transactions () { - export LIBEUFIN_NEXUS_USERNAME=exchange - export LIBEUFIN_NEXUS_PASSWORD=x - export LIBEUFIN_NEXUS_URL=http://localhost:8082/ - libeufin-cli accounts fetch-transactions \ - --range-type since-last \ - --level report \ - exchange-nexus > /dev/null - unset LIBEUFIN_NEXUS_USERNAME - unset LIBEUFIN_NEXUS_PASSWORD - unset LIBEUFIN_NEXUS_URL -} - -# Instruct Nexus to all the prepared payments (= those -# POSTed to /transfer by the exchange). -function nexus_submit_to_sandbox () { - export LIBEUFIN_NEXUS_USERNAME=exchange - export LIBEUFIN_NEXUS_PASSWORD=x - export LIBEUFIN_NEXUS_URL=http://localhost:8082/ - libeufin-cli accounts submit-payments exchange-nexus - unset LIBEUFIN_NEXUS_USERNAME - unset LIBEUFIN_NEXUS_PASSWORD - unset LIBEUFIN_NEXUS_URL -} function get_payto_uri() { export LIBEUFIN_SANDBOX_USERNAME=$1 @@ -156,21 +98,6 @@ function get_payto_uri() { | jq --raw-output '.paytoUri' } -function launch_libeufin () { - export LIBEUFIN_SANDBOX_DB_CONNECTION='jdbc:postgresql://localhost/'"${DB}"'?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg='"$SOCKETDIR"'/.s.PGSQL.5432' - libeufin-nexus serve \ - --port 8082 \ - 2> "${MYDIR}/libeufin-nexus-stderr.log" \ - > "${MYDIR}/libeufin-nexus-stdout.log" & - echo $! > "${MYDIR}/libeufin-nexus.pid" - export LIBEUFIN_NEXUS_DB_CONNECTION='jdbc:postgresql://localhost/'"${DB}"'?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg='"$SOCKETDIR"'/.s.PGSQL.5432' - libeufin-sandbox serve \ - --no-auth \ - --port 18082 \ - > "${MYDIR}/libeufin-sandbox-stdout.log" \ - 2> "${MYDIR}/libeufin-sandbox-stderr.log" & - echo $! > "${MYDIR}/libeufin-sandbox.pid" -} # Operations to run before the actual audit function pre_audit () { @@ -217,7 +144,7 @@ function pre_audit () { -t \ -c "$CONF" \ -y \ - 2> "${MYDIR}/aggregator.log" \ + 2> "${MY_TMP_DIR}/aggregator.log" \ || exit_fail "FAIL" echo " DONE" echo -n "Running exchange closer ..." @@ -225,7 +152,7 @@ function pre_audit () { -L "$LOGLEVEL" \ -t \ -c "$CONF" \ - 2> "${MYDIR}/closer.log" \ + 2> "${MY_TMP_DIR}/closer.log" \ || exit_fail "FAIL" echo " DONE" echo -n "Running exchange transfer ..." @@ -233,7 +160,7 @@ function pre_audit () { -L "$LOGLEVEL" \ -t \ -c "$CONF" \ - 2> "${MYDIR}/transfer.log" \ + 2> "${MY_TMP_DIR}/transfer.log" \ || exit_fail "FAIL" echo " DONE" echo -n "Running Nexus payment submitter ..." @@ -789,16 +716,16 @@ else fi echo -n "Setting up Postgres DB" POSTGRES_PATH=$(dirname "$INITDB_BIN") -MYDIR=$(mktemp -d /tmp/taler-auditor-basedbXXXXXX) -TMPDIR="${MYDIR}/postgres/" +MY_TMP_DIR=$(mktemp -d /tmp/taler-auditor-basedbXXXXXX) +TMPDIR="${MY_TMP_DIR}/postgres/" mkdir -p "$TMPDIR" echo -n "Setting up Postgres DB at $TMPDIR ..." "$INITDB_BIN" \ --no-sync \ --auth=trust \ -D "${TMPDIR}" \ - > "${MYDIR}/postgres-dbinit.log" \ - 2> "${MYDIR}/postgres-dbinit.err" + > "${MY_TMP_DIR}/postgres-dbinit.log" \ + 2> "${MY_TMP_DIR}/postgres-dbinit.err" echo " DONE" mkdir "${TMPDIR}/sockets" echo -n "Launching Postgres service at $POSTGRES_PATH" @@ -818,22 +745,22 @@ mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf" -D "$TMPDIR" \ -l /dev/null \ start \ - > "${MYDIR}/postgres-start.log" \ - 2> "${MYDIR}/postgres-start.err" + > "${MY_TMP_DIR}/postgres-start.log" \ + 2> "${MY_TMP_DIR}/postgres-start.err" echo " DONE" PGHOST="$TMPDIR/sockets" export PGHOST -echo "Generating fresh database at $MYDIR" -if faketime -f '-1 d' ./generate-revoke-basedb.sh "$MYDIR/$DB" +echo "Generating fresh database at $MY_TMP_DIR" +if faketime -f '-1 d' ./generate-revoke-basedb.sh "$MY_TMP_DIR/$DB" then - check_with_database "$MYDIR/$DB" + check_with_database "$MY_TMP_DIR/$DB" if [ "x$fail" != "x0" ] then exit "$fail" else - echo "Cleaning up $MYDIR..." - rm -rf "$MYDIR" || echo "Removing $MYDIR failed" + echo "Cleaning up $MY_TMP_DIR..." + rm -rf "$MY_TMP_DIR" || echo "Removing $MY_TMP_DIR failed" fi else echo "Generation failed" |