-work on auditor tests

This commit is contained in:
Christian Grothoff 2022-09-13 13:22:26 +02:00
parent bca7f21fdd
commit 1081f3edbf
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -61,18 +61,18 @@ function exit_fail() {
exit 1 exit 1
} }
# Cleanup to run whenever we exit # Cleanup exchange and libeufin between runs.
function cleanup() function cleanup()
{ {
if test ! -z ${POSTGRES_PATH:-} if test ! -z ${EPID:-}
then then
${POSTGRES_PATH}/pg_ctl -D $TMPDIR -l /dev/null stop &> /dev/null || true echo -n "Stopping exchange..."
kill -TERM $EPID
wait $EPID
echo " DONE"
unset EPID
fi fi
for n in `jobs -p`
do
kill $n 2> /dev/null || true
done
wait
echo "killing libeufin..." echo "killing libeufin..."
if test -f libeufin-sandbox.pid if test -f libeufin-sandbox.pid
then then
@ -87,8 +87,26 @@ function cleanup()
echo DONE echo DONE
} }
# Cleanup to run whenever we exit
function exit_cleanup()
{
echo "Running exit-cleanup"
if test ! -z ${POSTGRES_PATH:-}
then
echo "Stopping Postgres at ${POSTGRES_PATH}"
${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
cleanup
echo "DONE"
}
# Install cleanup handler (except for kill -9) # Install cleanup handler (except for kill -9)
trap cleanup EXIT trap exit_cleanup EXIT
function launch_libeufin () { function launch_libeufin () {
export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:$DB.sqlite3" export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:$DB.sqlite3"
@ -294,12 +312,12 @@ function run_audit () {
# Do a full reload of the (original) database # Do a full reload of the (original) database
function full_reload() function full_reload()
{ {
echo "Doing full reload of the database ($BASEDB)... " echo "Doing full reload of the database ($BASEDB - $DB)... "
dropdb $DB 2> /dev/null || true dropdb $DB 2> /dev/null || true
rm -f $DB.sqlite3 2> /dev/null || true # libeufin rm -f $DB.sqlite3 2> /dev/null || true # libeufin
createdb -T template0 $DB || exit_skip "could not create database $DB (at $PGHOST)" createdb -T template0 $DB || exit_skip "could not create database $DB (at $PGHOST)"
# Import pre-generated database, -q(ietly) using single (-1) transaction # Import pre-generated database, -q(ietly) using single (-1) transaction
psql -Aqt $DB -q -1 -f ${BASEDB}.sql > /dev/null || exit_skip "Failed to load database" psql -Aqt $DB -q -1 -f ${BASEDB}.sql > /dev/null || exit_skip "Failed to load database $DB from ${BASEDB}.sql"
echo "Loading libeufin basedb: ${BASEDB}-libeufin.sql" echo "Loading libeufin basedb: ${BASEDB}-libeufin.sql"
sqlite3 $DB.sqlite3 < ${BASEDB}-libeufin.sql || exit_skip "Failed to load libEufin database" sqlite3 $DB.sqlite3 < ${BASEDB}-libeufin.sql || exit_skip "Failed to load libEufin database"
echo "DONE" echo "DONE"