Add test for retries
This commit is contained in:
parent
8056c7fb62
commit
1cf48054c4
@ -109,8 +109,7 @@ function wait_for_services() {
|
||||
echo -n "."
|
||||
sleep 0.2
|
||||
OK=0
|
||||
# bank
|
||||
wget http://localhost:8082/ -o /dev/null -O /dev/null >/dev/null || continue
|
||||
wget "$BANK_URL" -o /dev/null -O /dev/null >/dev/null || continue
|
||||
OK=1
|
||||
break
|
||||
done
|
||||
@ -119,12 +118,9 @@ function wait_for_services() {
|
||||
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
|
||||
# Auditor
|
||||
wget http://localhost:8083/ -o /dev/null -O /dev/null >/dev/null || continue
|
||||
wget "$EXCHANGE_URL" -o /dev/null -O /dev/null >/dev/null || continue
|
||||
wget "$MERCHANT_URL" -o /dev/null -O /dev/null >/dev/null || continue
|
||||
wget "$AUDITOR_URL" -o /dev/null -O /dev/null >/dev/null || continue
|
||||
OK=1
|
||||
break
|
||||
done
|
||||
@ -142,6 +138,17 @@ function normal_start_and_wait() {
|
||||
wait_for_services
|
||||
}
|
||||
|
||||
# provide the service URL as first parameter
|
||||
function wait_for_service() {
|
||||
for _ in $(seq 1 50); do
|
||||
echo -n "."
|
||||
sleep 0.1
|
||||
wget "$1" -o /dev/null -O /dev/null >/dev/null || continue
|
||||
echo " DONE"
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
function shutdown_services() {
|
||||
echo "Shutting down services"
|
||||
jobs -p | xargs --no-run-if-empty kill || true
|
||||
@ -164,6 +171,11 @@ function exit_skip() {
|
||||
}
|
||||
|
||||
function exit_error() {
|
||||
echo "Error: $1"
|
||||
echo "\033[0;31mError: $1\033[0m"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function exit_success() {
|
||||
echo -e "\033[0;32mSUCCESS \o/\033[0m"
|
||||
exit 0
|
||||
}
|
||||
|
@ -10,5 +10,4 @@ normal_start_and_wait "base"
|
||||
echo "Running wallet"
|
||||
taler-wallet-cli testing integrationtest -e "$EXCHANGE_URL" -m "$MERCHANT_URL" -b "$BANK_URL"
|
||||
|
||||
echo "SUCCESS"
|
||||
exit 0
|
||||
exit_success
|
||||
|
@ -16,5 +16,4 @@ echo "Trying to pay what was paid already should throw error"
|
||||
taler-wallet-cli --wallet-db=$WALLET_DB --no-throttle handle-uri --yes "$PAY_URI" 2>&1 | grep -q "already paid" || exit_error "not reporting already paid"
|
||||
echo "Already paid properly detected"
|
||||
|
||||
echo "SUCCESS"
|
||||
exit 0
|
||||
exit_success
|
||||
|
@ -21,5 +21,4 @@ echo "Try to double-spend"
|
||||
# "exchange_reply: { hint: 'insufficient funds', code: 1200 }
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" testing test-pay -m "$MERCHANT_URL" -k sandbox -a "TESTKUDOS:9.5" -s "foo"
|
||||
|
||||
echo "SUCCESS"
|
||||
exit 0
|
||||
exit_success
|
||||
|
@ -20,5 +20,4 @@ echo -n "Balance after first refund: "
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
|
||||
# TODO how to test second refund for same purchase?
|
||||
|
||||
echo "SUCCESS"
|
||||
exit 0
|
||||
exit_success
|
||||
|
45
integrationtests/test-retries.sh
Executable file
45
integrationtests/test-retries.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# Script to check that the wallet retries operations when services are not reachable
|
||||
|
||||
source "common.sh"
|
||||
normal_start_and_wait "retries"
|
||||
|
||||
# TODO try withdrawal when bank is down
|
||||
|
||||
echo "Withdraw TESTKUDOS"
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle testing withdraw -e "$EXCHANGE_URL" -b "$BANK_URL" -a "TESTKUDOS:10" 2>>"$LOG" >>"$LOG"
|
||||
echo -n "Balance after withdrawal: "
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
|
||||
echo "Getting pay taler:// Uri"
|
||||
PAY_URI=$(taler-wallet-cli testing gen-pay-uri -m "$MERCHANT_URL" -k sandbox -a "TESTKUDOS:1" -s "foo" | grep -E -o 'taler://.*')
|
||||
echo "Trying to pay with exchange down, will fail"
|
||||
kill "$EXCHANGE_PID" && sleep 1
|
||||
ps -p "$EXCHANGE_PID" >"$LOG" && exit_error "exchange still alive"
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle handle-uri --yes "$PAY_URI" 2>>"$LOG" >>"$LOG" && exit_error "could pay with exchange down"
|
||||
echo "Re-launching exchange"
|
||||
taler-exchange-httpd -c "$CONF" 2>taler-exchange-httpd.log &
|
||||
EXCHANGE_PID=$!
|
||||
echo -n "Wait for exchange to start"
|
||||
wait_for_service "$EXCHANGE_URL"
|
||||
echo "Retrying operations with exchange up"
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" run-until-done 2>>"$LOG" >>"$LOG"
|
||||
echo -n "Balance after re-tried payment: "
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
|
||||
|
||||
echo "Getting pay taler:// Uri"
|
||||
PAY_URI=$(taler-wallet-cli testing gen-pay-uri -m "$MERCHANT_URL" -k sandbox -a "TESTKUDOS:1" -s "foo" | grep -E -o 'taler://.*')
|
||||
echo "Trying to pay with merchant down, will fail"
|
||||
kill "$MERCHANT_PID" && sleep 1
|
||||
ps -p "$MERCHANT_PID" >"$LOG" && exit_error "merchant still alive"
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle handle-uri --yes "$PAY_URI" 2>>"$LOG" >>"$LOG" && exit_error "could pay with merchant down"
|
||||
echo "Re-launching merchant"
|
||||
taler-merchant-httpd -c "$CONF" -L INFO 2>taler-merchant-httpd.log &
|
||||
MERCHANT_PID=$!
|
||||
echo -n "Wait for merchant to start"
|
||||
wait_for_service "$MERCHANT_URL"
|
||||
echo "Retrying payment with merchant up"
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle handle-uri --yes "$PAY_URI" 2>>"$LOG" >>"$LOG"
|
||||
echo -n "Balance after re-tried payment: "
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
|
||||
|
||||
exit_success
|
@ -15,5 +15,4 @@ taler-wallet-cli --wallet-db="$WALLET_DB" run-until-done 2>>"$LOG" >>"$LOG"
|
||||
echo -n "Balance after first tip: "
|
||||
taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
|
||||
|
||||
echo "SUCCESS"
|
||||
exit 0
|
||||
exit_success
|
||||
|
Loading…
Reference in New Issue
Block a user