aboutsummaryrefslogtreecommitdiff
path: root/integrationtests/test-retries.sh
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-05-08 11:53:17 -0300
committerTorsten Grote <t@grobox.de>2020-05-08 11:53:58 -0300
commit1cf48054c47d9562876b5f021dc398b050b959fd (patch)
tree237a7380d55eb9532bf069f2179098d6f40c8e92 /integrationtests/test-retries.sh
parent8056c7fb62ceb8de3171d13fd48d44bbdc43645c (diff)
Add test for retries
Diffstat (limited to 'integrationtests/test-retries.sh')
-rwxr-xr-xintegrationtests/test-retries.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/integrationtests/test-retries.sh b/integrationtests/test-retries.sh
new file mode 100755
index 000000000..01bfa5774
--- /dev/null
+++ b/integrationtests/test-retries.sh
@@ -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