aboutsummaryrefslogtreecommitdiff
path: root/src/exchange/test_taler_exchange_httpd_restart.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange/test_taler_exchange_httpd_restart.sh')
-rwxr-xr-xsrc/exchange/test_taler_exchange_httpd_restart.sh107
1 files changed, 0 insertions, 107 deletions
diff --git a/src/exchange/test_taler_exchange_httpd_restart.sh b/src/exchange/test_taler_exchange_httpd_restart.sh
deleted file mode 100755
index 26a315bf8..000000000
--- a/src/exchange/test_taler_exchange_httpd_restart.sh
+++ /dev/null
@@ -1,107 +0,0 @@
1#!/bin/bash
2#
3# This file is part of TALER
4# Copyright (C) 2020 Taler Systems SA
5#
6# TALER is free software; you can redistribute it and/or modify it under the
7# terms of the GNU Affero General Public License as published by the Free Software
8# Foundation; either version 3, or (at your option) any later version.
9#
10# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
11# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
13#
14# You should have received a copy of the GNU Affero General Public License along with
15# TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
16#
17#
18# This script launches an exchange (binding to a UNIX domain socket) and then
19# restarts it in various ways (SIGHUP to re-read configuration, and SIGUSR1 to
20# re-spawn a new binary). Basically, the goal is to make sure that the HTTP
21# server survives these less common operations.
22#
23#
24set -eu
25
26# Exit, with status code "skip" (no 'real' failure)
27function exit_skip() {
28 echo $1
29 exit 77
30}
31
32# Exit, with error message (hard failure)
33function exit_fail() {
34 echo $1
35 kill `jobs -p` >/dev/null 2>/dev/null || true
36 wait
37 exit 1
38}
39
40echo -n "Testing for curl"
41curl --version >/dev/null </dev/null || exit_skip " MISSING"
42echo " FOUND"
43
44
45# Clear environment from variables that override config.
46unset XDG_DATA_HOME
47unset XDG_CONFIG_HOME
48#
49echo -n "Launching exchange ..."
50PREFIX=
51# Uncomment this line to run with valgrind...
52# PREFIX="valgrind --trace-children=yes --leak-check=yes --track-fds=yes --error-exitcode=1 --log-file=valgrind.%p"
53
54CONFIG=test_taler_exchange_unix.conf
55
56# Setup database
57taler-exchange-dbinit -c $CONFIG &> /dev/null
58# Run Exchange HTTPD (in background)
59$PREFIX taler-exchange-httpd -c $CONFIG 2> test-exchange.log &
60
61# Where should we be bound to?
62UNIXPATH=`taler-config -c $CONFIG -s exchange -f -o UNIXPATH`
63
64# Give HTTP time to start
65
66for n in `seq 1 100`
67do
68 echo -n "."
69 sleep 0.1
70 OK=1
71 curl --unix-socket "${UNIXPATH}" "http://ignored/" >/dev/null 2> /dev/null && break
72 OK=0
73done
74if [ 1 != $OK ]
75then
76 exit_fail "Failed to launch exchange"
77fi
78echo " DONE"
79
80# Finally run test...
81echo -n "Restarting program ..."
82kill -SIGHUP $!
83sleep 1
84curl --unix-socket "${UNIXPATH}" "http://ignored/" >/dev/null 2> /dev/null || exit_fail "SIGHUP killed HTTP service"
85echo " DONE"
86
87echo -n "Waiting for parent to die ..."
88wait $!
89echo " DONE"
90
91echo -n "Testing child still alive ..."
92curl --unix-socket "${UNIXPATH}" "http://ignored/" >/dev/null 2> /dev/null || exit_fail "SIGHUP killed HTTP service"
93echo " DONE"
94
95
96echo -n "Killing grandchild ..."
97CPID=`ps x | grep taler-exchange-httpd | grep -v grep | awk '{print $1}'`
98kill -TERM $CPID
99while true
100do
101 ps x | grep -v grep | grep taler-exchange-httpd > /dev/null || break
102 sleep 0.1
103done
104echo " DONE"
105
106# Return status code from exchange for this script
107exit 0