summaryrefslogtreecommitdiff
path: root/src/auditor/test-auditor.sh
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-09-12 11:33:56 +0200
committerChristian Grothoff <christian@grothoff.org>2022-09-12 11:33:56 +0200
commit05cf62b3973236c8646005e27a50cc27be559408 (patch)
treec0c1cbe9441d2d55e1f4f861efe1acd4d3633b3f /src/auditor/test-auditor.sh
parent27ee193e340d8a92964dcd4e359f7cdd9b6738be (diff)
downloadexchange-05cf62b3973236c8646005e27a50cc27be559408.tar.gz
exchange-05cf62b3973236c8646005e27a50cc27be559408.tar.bz2
exchange-05cf62b3973236c8646005e27a50cc27be559408.zip
-use private DB for tests
Diffstat (limited to 'src/auditor/test-auditor.sh')
-rwxr-xr-xsrc/auditor/test-auditor.sh55
1 files changed, 47 insertions, 8 deletions
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index 352ba5938..297225fec 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -35,28 +35,39 @@ LIBEUFIN_SETTLE_TIME=1
# Exit, with status code "skip" (no 'real' failure)
function exit_skip() {
- echo $1
+ echo "SKIPPING test: $1"
exit 77
}
# Exit, with error message (hard failure)
function exit_fail() {
- echo $1
+ echo "FAILING test: $1"
exit 1
}
# Cleanup to run whenever we exit
function cleanup()
{
+ if test ! -z ${POSTGRES_PATH:-}
+ then
+ ${POSTGRES_PATH}/pg_ctl -D $TMPDIR -l /dev/null stop &> /dev/null || true
+ fi
for n in `jobs -p`
do
kill $n 2> /dev/null || true
done
wait
# kill euFin
- echo -n "Killing euFin.."
- kill `cat libeufin-sandbox.pid 2> /dev/null` &> /dev/null || true
- kill `cat libeufin-nexus.pid 2> /dev/null` &> /dev/null || true
+ if test -f libeufin-sandbox.pid
+ then
+ echo "Killing libeufin sandbox"
+ kill `cat libeufin-sandbox.pid 2> /dev/null` &> /dev/null || true
+ fi
+ if test -f libeufin-nexus.pid
+ then
+ echo "Killing libeufin nexus"
+ kill `cat libeufin-nexus.pid 2> /dev/null` &> /dev/null || true
+ fi
echo DONE
}
@@ -1978,14 +1989,41 @@ echo "Testing for faketime"
faketime -h > /dev/null || exit_skip "faketime required"
# NOTE: really check for all three libeufin commands?
echo "Testing for libeufin"
-libeufin-cli --help >/dev/null </dev/null || exit_skip "libeufin required"
+libeufin-cli --help >/dev/null 2> /dev/null </dev/null || exit_skip "libeufin required"
echo "Testing for pdflatex"
which pdflatex > /dev/null </dev/null || exit_skip "pdflatex required"
-
-# check if we should regenerate the database
echo "Testing for taler-wallet-cli"
taler-wallet-cli -h >/dev/null </dev/null 2>/dev/null || exit_skip "taler-wallet-cli required"
MYDIR=`mktemp -d /tmp/taler-auditor-basedbXXXXXX`
+
+
+echo -n "Testing for Postgres"
+HAVE_INITDB=`find /usr -name "initdb" | grep postgres` || exit_skip " MISSING"
+echo " FOUND"
+echo -n "Setting up Postgres DB"
+INITDB_BIN=`find /usr -name "initdb" | grep bin/initdb | grep postgres | sort -n | tail -n1`
+POSTGRES_PATH=`basename $INITDB_BIN`
+TMPDIR=`mktemp -d /tmp/taler-test-postgresXXXXXX`
+$INITDB_BIN --no-sync --auth=trust -D ${TMPDIR} > postgres-dbinit.log 2> postgres-dbinit.err
+echo " DONE"
+mkdir ${TMPDIR}/sockets
+echo -n "Launching Postgres service"
+cat - >> $TMPDIR/postgresql.conf <<EOF
+unix_socket_directories='${TMPDIR}/sockets'
+fsync=off
+max_wal_senders=0
+synchronous_commit=off
+wal_level=minimal
+listen_addresses=''
+EOF
+cat $TMPDIR/pg_hba.conf | 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 /dev/null start > postgres-start.log 2> postgres-start.err
+echo " DONE"
+PGHOST="$TMPDIR/sockets"
+EXPORT PGHOST="@POSTGRES_SOCKET"
+
+
echo "Generating fresh database at $MYDIR"
if faketime -f '-1 d' ./generate-auditor-basedb.sh $MYDIR/basedb
then
@@ -1996,6 +2034,7 @@ then
else
echo "Cleaning up $MYDIR..."
rm -rf $MYDIR || echo "Removing $MYDIR failed"
+ rm -rf $TMPDIR || echo "Removing $TMPDIR failed"
fi
else
echo "Generation failed"