[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 01/02: clean up integration test shell library
From: |
gnunet |
Subject: |
[taler-wallet-core] 01/02: clean up integration test shell library |
Date: |
Fri, 08 May 2020 15:14:30 +0200 |
This is an automated email from the git hooks/post-receive script.
torsten-grote pushed a commit to branch master
in repository wallet-core.
commit 06aa5abcc7b96236b42fdf33af347f09632b6560
Author: Torsten Grote <address@hidden>
AuthorDate: Fri May 8 09:58:47 2020 -0300
clean up integration test shell library
---
integrationtests/common.sh | 41 ++++++++++++++++++++---------------
integrationtests/test-base.sh | 5 +----
integrationtests/test-double-link.sh | 5 +----
integrationtests/test-double-spend.sh | 5 +----
4 files changed, 27 insertions(+), 29 deletions(-)
diff --git a/integrationtests/common.sh b/integrationtests/common.sh
index 4b42531b..8036b825 100644
--- a/integrationtests/common.sh
+++ b/integrationtests/common.sh
@@ -11,7 +11,7 @@ function setup_config() {
echo " FOUND"
echo -n "Testing for taler-merchant-httpd"
# TODO "taler-merchant-httpd -v" should not return an error
- [[ "$(taler-merchant-httpd -v)" =~ "taler-merchant-httpd v" ]] ||
exit_skip " MISSING"
+ [[ "$(taler-merchant-httpd -v)" =~ "taler-merchant-httpd v" ]] ||
exit_skip " MISSING"
echo " FOUND"
trap shutdown_services EXIT
@@ -31,8 +31,11 @@ function setup_config() {
export CONF=test-${SCRIPT_NAME}.conf
cp template.conf "$CONF"
+ export LOG=test-${SCRIPT_NAME}.log
+ rm "$LOG" 2>/dev/null || true
+
export WALLET_DB=wallet-${SCRIPT_NAME}.json
- rm "$WALLET_DB" 2> /dev/null || true
+ rm "$WALLET_DB" 2>/dev/null || true
# Clean up
DATA_DIR=$(taler-config -f -c "$CONF" -s PATHS -o TALER_HOME)
@@ -46,7 +49,7 @@ function setup_config() {
MASTER_PRIV_FILE=$(taler-config -f -c "$CONF" -s EXCHANGE -o
MASTER_PRIV_FILE)
MASTER_PRIV_DIR=$(dirname "$MASTER_PRIV_FILE")
mkdir -p "$MASTER_PRIV_DIR"
- gnunet-ecc -g1 "$MASTER_PRIV_FILE" > /dev/null
+ gnunet-ecc -g1 "$MASTER_PRIV_FILE" >/dev/null
MASTER_PUB=$(gnunet-ecc -p "$MASTER_PRIV_FILE")
EXCHANGE_URL=$(taler-config -c "$CONF" -s EXCHANGE -o BASE_URL)
MERCHANT_PORT=$(taler-config -c "$CONF" -s MERCHANT -o PORT)
@@ -70,8 +73,8 @@ function setup_services() {
# setup exchange
echo "Setting up exchange"
taler-exchange-dbinit -c "$CONF"
- taler-exchange-wire -c "$CONF" 2> taler-exchange-wire.log
- taler-exchange-keyup -L INFO -c "$CONF" -o e2a.dat 2>
taler-exchange-keyup.log
+ taler-exchange-wire -c "$CONF" 2>taler-exchange-wire.log
+ taler-exchange-keyup -L INFO -c "$CONF" -o e2a.dat
2>taler-exchange-keyup.log
# setup auditor
echo "Setting up auditor"
@@ -89,21 +92,20 @@ function setup_services() {
function launch_services() {
# Launch services
echo "Launching services"
- taler-bank-manage-testing "$CONF" "postgres:///$TARGET_DB" serve-http &>
bank-"$SCRIPT_NAME".log &
- taler-exchange-httpd -c "$CONF" 2> taler-exchange-httpd.log &
+ taler-bank-manage-testing "$CONF" "postgres:///$TARGET_DB" serve-http
&>bank-"$SCRIPT_NAME".log &
+ taler-exchange-httpd -c "$CONF" 2>taler-exchange-httpd.log &
# shellcheck disable=SC2034
EXCHANGE_PID=$!
- taler-merchant-httpd -c "$CONF" -L INFO 2> taler-merchant-httpd.log &
+ taler-merchant-httpd -c "$CONF" -L INFO 2>taler-merchant-httpd.log &
# shellcheck disable=SC2034
MERCHANT_PID=$!
- taler-exchange-wirewatch -c "$CONF" 2> taler-exchange-wirewatch.log &
- taler-auditor-httpd -c "$CONF" 2> taler-auditor-httpd.log &
+ taler-exchange-wirewatch -c "$CONF" 2>taler-exchange-wirewatch.log &
+ taler-auditor-httpd -c "$CONF" 2>taler-auditor-httpd.log &
}
function wait_for_services() {
# Wait for bank to be available (usually the slowest)
- for _ in $(seq 1 50)
- do
+ for _ in $(seq 1 50); do
echo -n "."
sleep 0.2
OK=0
@@ -113,8 +115,7 @@ function wait_for_services() {
break
done
# Wait for all other services to be available
- for _ in $(seq 1 50)
- do
+ for _ in $(seq 1 50); do
echo -n "."
sleep 0.1
OK=0
@@ -127,14 +128,20 @@ function wait_for_services() {
OK=1
break
done
- if [ 1 != $OK ]
- then
+ if [ 1 != $OK ]; then
shutdown_services
exit_skip "Failed to launch services"
fi
echo " DONE"
}
+function normal_start_and_wait() {
+ setup_config "$1"
+ setup_services
+ launch_services
+ wait_for_services
+}
+
function shutdown_services() {
echo "Shutting down services"
jobs -p | xargs --no-run-if-empty kill || true
@@ -144,7 +151,7 @@ function shutdown_services() {
echo "Final clean up"
dropdb "$TARGET_DB" >/dev/null 2>/dev/null || true
- rm "$WALLET_DB" 2> /dev/null || true
+ rm "$WALLET_DB" 2>/dev/null || true
rm -rf "$DATA_DIR" || true
rm "$CONF"
diff --git a/integrationtests/test-base.sh b/integrationtests/test-base.sh
index 80ac466f..32187dd2 100755
--- a/integrationtests/test-base.sh
+++ b/integrationtests/test-base.sh
@@ -4,10 +4,7 @@
# wallet and merchant.
source "common.sh"
-setup_config "base"
-setup_services
-launch_services
-wait_for_services
+normal_start_and_wait "base"
# run wallet CLI
echo "Running wallet"
diff --git a/integrationtests/test-double-link.sh
b/integrationtests/test-double-link.sh
index 5522b94e..62c15273 100755
--- a/integrationtests/test-double-link.sh
+++ b/integrationtests/test-double-link.sh
@@ -2,10 +2,7 @@
# Script to check that Uris are properly handled when used a second time
source "common.sh"
-setup_config "double-link"
-setup_services
-launch_services
-wait_for_services
+normal_start_and_wait "double-link"
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://.*')
diff --git a/integrationtests/test-double-spend.sh
b/integrationtests/test-double-spend.sh
index ee2a966f..6edf22a2 100755
--- a/integrationtests/test-double-spend.sh
+++ b/integrationtests/test-double-spend.sh
@@ -2,10 +2,7 @@
# Script to check that the wallet can not double spend coins and handles this
error well
source "common.sh"
-setup_config "double-spend"
-setup_services
-launch_services
-wait_for_services
+normal_start_and_wait "double-spend"
echo "Withdraw TESTKUDOS"
taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle testing withdraw -e
"$EXCHANGE_URL" -b "$BANK_URL" -a "TESTKUDOS:10" >/dev/null
--
To stop receiving notification emails like this one, please contact
address@hidden.