more comprehensive test-auditor.sh, including generate-auditor-basedb now
This commit is contained in:
parent
bde4c742de
commit
0d5a3d7b6f
@ -26,4 +26,4 @@ UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
|
||||
UNIXPATH_MODE = 660
|
||||
|
||||
# HTTP port the auditor listens to
|
||||
PORT = 8082
|
||||
PORT = 8083
|
||||
|
@ -41,7 +41,7 @@ cp generate-auditor-basedb-template.conf $CONF
|
||||
echo -n "Testing for taler-bank-manage"
|
||||
taler-bank-manage -h >/dev/null </dev/null || exit_skip " MISSING"
|
||||
echo " FOUND"
|
||||
echo "Testing for taler-wallet-cli"
|
||||
echo -n "Testing for taler-wallet-cli"
|
||||
taler-wallet-cli -h >/dev/null </dev/null || exit_skip " MISSING"
|
||||
echo " FOUND"
|
||||
|
||||
@ -94,12 +94,32 @@ taler-bank-manage -c $CONF serve-http &
|
||||
taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
|
||||
taler-merchant-httpd -c $CONF 2> taler-merchant-httpd.log &
|
||||
taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
|
||||
taler-auditor-httpd -c $CONF 2> taler-auditor-httpd.log &
|
||||
|
||||
# Wait for all services to be available
|
||||
for n in `seq 1 20`
|
||||
do
|
||||
echo -n "."
|
||||
sleep 0.1
|
||||
OK=0
|
||||
# exchange
|
||||
wget http://localhost:8081/ -o /dev/null -O /dev/null >/dev/null || continue
|
||||
# merchant
|
||||
wget http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue
|
||||
# bank
|
||||
wget http://localhost:8082/ -o /dev/null -O /dev/null >/dev/null || continue
|
||||
# Auditor
|
||||
wget http://localhost:8083/ -o /dev/null -O /dev/null >/dev/null || continue
|
||||
OK=1
|
||||
break
|
||||
done
|
||||
|
||||
# FIXME: also launch taler-auditor-httpd!
|
||||
|
||||
# FIXME: interactive test here instead of waiting!
|
||||
sleep 10
|
||||
if [ 1 != $OK ]
|
||||
then
|
||||
kill `jobs -p`
|
||||
exit_skip "Failed to launch services"
|
||||
fi
|
||||
echo " DONE"
|
||||
|
||||
# run wallet CLI
|
||||
echo "Running wallet"
|
||||
@ -123,3 +143,9 @@ dropdb $TARGET_DB
|
||||
rm -f e2a.dat a2e.dat
|
||||
rm -rf $DATA_DIR || true
|
||||
rm $CONF
|
||||
|
||||
echo "====================================="
|
||||
echo " Finished generation of $BASEDB"
|
||||
echo "====================================="
|
||||
|
||||
exit 0
|
||||
|
@ -802,6 +802,13 @@ function test_14() {
|
||||
|
||||
echo "===========14: wire-fee disagreement==========="
|
||||
|
||||
# Check wire transfer lag reported (no aggregator!)
|
||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||
# re-generating the test database as we do not
|
||||
# report lag of less than 1h (see GRACE_PERIOD in
|
||||
# taler-wire-auditor.c)
|
||||
if [ $DATABASE_AGE -gt 3600 ]
|
||||
then
|
||||
|
||||
# Wire fees are only checked/generated once there are
|
||||
# actual outgoing wire transfers, so we need to run the
|
||||
@ -811,14 +818,6 @@ echo "UPDATE wire_fee SET wire_fee_frac=100;" | psql -Aqt $DB
|
||||
audit_only
|
||||
post_audit
|
||||
|
||||
|
||||
# Check wire transfer lag reported (no aggregator!)
|
||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||
# re-generating the test database as we do not
|
||||
# report lag of less than 1h (see GRACE_PERIOD in
|
||||
# taler-wire-auditor.c)
|
||||
if [ $DATABASE_AGE -gt 3600 ]
|
||||
then
|
||||
echo -n "Testing inconsistency detection... "
|
||||
TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
|
||||
if test "x$TABLE" != "xwire-fee"
|
||||
@ -831,15 +830,16 @@ then
|
||||
exit_fail "Reported diagnostic wrong: $DIAG"
|
||||
fi
|
||||
echo PASS
|
||||
else
|
||||
echo "Inconsistency detection: SKIP (database too new)"
|
||||
fi
|
||||
|
||||
# cannot easily undo aggregator, hence full reload
|
||||
echo -n "Reloading database ..."
|
||||
full_reload
|
||||
echo "DONE"
|
||||
|
||||
else
|
||||
echo "Test skipped (database too new)"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -847,6 +847,16 @@ echo "DONE"
|
||||
# Test where h_wire in the deposit table is wrong
|
||||
function test_15() {
|
||||
echo "===========15: deposit wire hash wrong================="
|
||||
|
||||
# Check wire transfer lag reported (no aggregator!)
|
||||
|
||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||
# re-generating the test database as we do not
|
||||
# report lag of less than 1h (see GRACE_PERIOD in
|
||||
# taler-wire-auditor.c)
|
||||
if [ $DATABASE_AGE -gt 3600 ]
|
||||
then
|
||||
|
||||
# Modify h_wire hash, so it is inconsistent with 'wire'
|
||||
echo "UPDATE deposits SET h_wire='\x973e52d193a357940be9ef2939c19b0575ee1101f52188c3c01d9005b7d755c397e92624f09cfa709104b3b65605fe5130c90d7e1b7ee30f8fc570f39c16b853' WHERE deposit_serial_id=1" | psql -Aqt $DB
|
||||
|
||||
@ -855,13 +865,6 @@ echo "UPDATE deposits SET h_wire='\x973e52d193a357940be9ef2939c19b0575ee1101f521
|
||||
# run aggregator first to get this test to work.
|
||||
run_audit aggregator
|
||||
|
||||
# Check wire transfer lag reported (no aggregator!)
|
||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||
# re-generating the test database as we do not
|
||||
# report lag of less than 1h (see GRACE_PERIOD in
|
||||
# taler-wire-auditor.c)
|
||||
if [ $DATABASE_AGE -gt 3600 ]
|
||||
then
|
||||
echo -n "Testing inconsistency detection... "
|
||||
TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
|
||||
if test "x$TABLE" != "xaggregation" -a "x$TABLE" != "xdeposits"
|
||||
@ -869,14 +872,15 @@ then
|
||||
exit_fail "Reported table wrong: $TABLE"
|
||||
fi
|
||||
echo PASS
|
||||
else
|
||||
echo "Inconsistency detection: SKIP (database too new)"
|
||||
fi
|
||||
|
||||
# cannot easily undo aggregator, hence full reload
|
||||
echo -n "Reloading database ..."
|
||||
full_reload
|
||||
echo "DONE"
|
||||
|
||||
else
|
||||
echo "Test skipped (database too new)"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -884,6 +888,14 @@ echo "DONE"
|
||||
function test_16() {
|
||||
echo "===========16: incorrect wire_out amount================="
|
||||
|
||||
# Check wire transfer lag reported (no aggregator!)
|
||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||
# re-generating the test database as we do not
|
||||
# report lag of less than 1h (see GRACE_PERIOD in
|
||||
# taler-wire-auditor.c)
|
||||
if [ $DATABASE_AGE -gt 3600 ]
|
||||
then
|
||||
|
||||
# First, we need to run the aggregator so we even
|
||||
# have a wire_out to modify.
|
||||
pre_audit aggregator
|
||||
@ -898,13 +910,6 @@ echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}'
|
||||
|
||||
audit_only
|
||||
|
||||
# Check wire transfer lag reported (no aggregator!)
|
||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||
# re-generating the test database as we do not
|
||||
# report lag of less than 1h (see GRACE_PERIOD in
|
||||
# taler-wire-auditor.c)
|
||||
if [ $DATABASE_AGE -gt 3600 ]
|
||||
then
|
||||
echo -n "Testing inconsistency detection... "
|
||||
|
||||
AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-wire-audit.json`
|
||||
@ -928,10 +933,6 @@ then
|
||||
exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
|
||||
fi
|
||||
echo PASS
|
||||
else
|
||||
echo "Inconsistency detection: SKIP (database too new)"
|
||||
fi
|
||||
|
||||
|
||||
echo "Second modification: wire nothing"
|
||||
NEW_AMOUNT="TESTKUDOS:0"
|
||||
@ -965,9 +966,14 @@ echo PASS
|
||||
|
||||
post_audit
|
||||
|
||||
# cannot easily undo aggregator, hence full reload
|
||||
echo -n "Reloading database ..."
|
||||
full_reload
|
||||
echo "DONE"
|
||||
else
|
||||
echo "Test skipped (database too new)"
|
||||
fi
|
||||
|
||||
# Undo
|
||||
echo "UPDATE app_banktransaction SET amount='${OLD_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
||||
}
|
||||
|
||||
|
||||
@ -977,6 +983,14 @@ echo "UPDATE app_banktransaction SET amount='${OLD_AMOUNT}' WHERE id='${OLD_ID}'
|
||||
function test_17() {
|
||||
echo "===========17: incorrect wire_out timestamp================="
|
||||
|
||||
# Check wire transfer lag reported (no aggregator!)
|
||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||
# re-generating the test database as we do not
|
||||
# report lag of less than 1h (see GRACE_PERIOD in
|
||||
# taler-wire-auditor.c)
|
||||
if [ $DATABASE_AGE -gt 3600 ]
|
||||
then
|
||||
|
||||
# First, we need to run the aggregator so we even
|
||||
# have a wire_out to modify.
|
||||
pre_audit aggregator
|
||||
@ -1007,8 +1021,15 @@ then
|
||||
fi
|
||||
echo PASS
|
||||
|
||||
# Undo
|
||||
echo "UPDATE app_banktransaction SET date='${OLD_DATE}' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
||||
# cannot easily undo aggregator, hence full reload
|
||||
echo -n "Reloading database ..."
|
||||
full_reload
|
||||
echo "DONE"
|
||||
|
||||
else
|
||||
echo "Test skipped (database too new)"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1069,6 +1090,14 @@ echo "DONE"
|
||||
function test_19() {
|
||||
echo "===========19: outgoing wire subject malformed================="
|
||||
|
||||
# Check wire transfer lag reported (no aggregator!)
|
||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||
# re-generating the test database as we do not
|
||||
# report lag of less than 1h (see GRACE_PERIOD in
|
||||
# taler-wire-auditor.c)
|
||||
if [ $DATABASE_AGE -gt 3600 ]
|
||||
then
|
||||
|
||||
# Need to first run the aggregator so the outgoing transfer exists
|
||||
pre_audit aggregator
|
||||
|
||||
@ -1105,8 +1134,13 @@ fi
|
||||
|
||||
echo "PASS"
|
||||
|
||||
# Undo
|
||||
echo "UPDATE app_banktransaction SET subject='${OLD_SUBJECT}' WHERE debit_account_id=2;" | psql -Aqt $DB
|
||||
# cannot easily undo aggregator, hence full reload
|
||||
echo -n "Reloading database ..."
|
||||
full_reload
|
||||
echo "DONE"
|
||||
else
|
||||
echo "Test skipped (database too new)"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -1114,6 +1148,13 @@ echo "UPDATE app_banktransaction SET subject='${OLD_SUBJECT}' WHERE debit_accoun
|
||||
function test_20() {
|
||||
echo "===========20: reserve closure done properly ================="
|
||||
|
||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||
# re-generating the test database as we do not
|
||||
# report lag of less than 1h (see GRACE_PERIOD in
|
||||
# taler-wire-auditor.c)
|
||||
if [ $DATABASE_AGE -gt 3600 ]
|
||||
then
|
||||
|
||||
OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
||||
OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
||||
RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
||||
@ -1139,9 +1180,14 @@ jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null &&
|
||||
|
||||
echo "PASS"
|
||||
|
||||
# Undo
|
||||
echo "UPDATE reserves_in SET execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
|
||||
echo "UPDATE reserves SET expiration_date='${OLD_EXP}',current_balance_val=current_balance_val-${VAL_DELTA} WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
|
||||
# cannot easily undo aggregator, hence full reload
|
||||
echo -n "Reloading database ..."
|
||||
full_reload
|
||||
echo "DONE"
|
||||
|
||||
else
|
||||
echo "Test skipped (database too new)"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -1225,9 +1271,10 @@ then
|
||||
|
||||
echo "PASS"
|
||||
|
||||
# Undo
|
||||
echo "UPDATE reserves_in SET execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
|
||||
echo "UPDATE reserves SET expiration_date='${OLD_EXP}',current_balance_val=current_balance_val-${VAL_DELTA} WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
|
||||
# cannot easily undo aggregator, hence full reload
|
||||
echo -n "Reloading database ..."
|
||||
full_reload
|
||||
echo "DONE"
|
||||
else
|
||||
echo "Test skipped (database too new)"
|
||||
fi
|
||||
@ -1249,6 +1296,8 @@ fi
|
||||
# *************** Main test loop starts here **************
|
||||
|
||||
|
||||
# Run all the tests against the database given in $1.
|
||||
# Sets $fail to 0 on success, non-zero on failure.
|
||||
check_with_database()
|
||||
{
|
||||
BASEDB=$1
|
||||
@ -1283,18 +1332,11 @@ check_with_database()
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
echo "Cleanup (disabled)"
|
||||
# dropdb $DB
|
||||
# rm -r $WIRE_FEE_DIR
|
||||
# rm -f test-audit.log test-wire-audit.log
|
||||
|
||||
# if test -n "${MYDIR:-}"
|
||||
# then
|
||||
# rm -rf $MYDIR
|
||||
# fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1320,21 +1362,26 @@ if test -n "${1:-}"
|
||||
then
|
||||
echo "Custom run, will only run on existing DB."
|
||||
else
|
||||
echo "Testing for taler-wallet-cli"
|
||||
echo -n "Testing for taler-wallet-cli"
|
||||
if taler-wallet-cli -h >/dev/null </dev/null 2>/dev/null
|
||||
then
|
||||
MYDIR=`mktemp -d /tmp/taler-auditor-basedbXXXXXX`
|
||||
echo " FOUND. Generating fresh database at $MYDIR"
|
||||
if ./generate-auditor-basedb.sh $MYDIR/basedb
|
||||
then
|
||||
check_with_database $MYDIR
|
||||
check_with_database $MYDIR/basedb
|
||||
if test x$fail != x0
|
||||
then
|
||||
exit $fail
|
||||
else
|
||||
echo "Cleaning up $MYDIR..."
|
||||
rm -rf $MYDIR || echo "Removing $MYDIR failed"
|
||||
fi
|
||||
else
|
||||
echo "Generation failed, running only on existing DB"
|
||||
fi
|
||||
else
|
||||
echo " NOT FOUND, running only on existing DB"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user