diff options
Diffstat (limited to 'src/exchange/test_taler_exchange_httpd_restart.sh')
-rwxr-xr-x | src/exchange/test_taler_exchange_httpd_restart.sh | 107 |
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 | # | ||
24 | set -eu | ||
25 | |||
26 | # Exit, with status code "skip" (no 'real' failure) | ||
27 | function exit_skip() { | ||
28 | echo $1 | ||
29 | exit 77 | ||
30 | } | ||
31 | |||
32 | # Exit, with error message (hard failure) | ||
33 | function exit_fail() { | ||
34 | echo $1 | ||
35 | kill `jobs -p` >/dev/null 2>/dev/null || true | ||
36 | wait | ||
37 | exit 1 | ||
38 | } | ||
39 | |||
40 | echo -n "Testing for curl" | ||
41 | curl --version >/dev/null </dev/null || exit_skip " MISSING" | ||
42 | echo " FOUND" | ||
43 | |||
44 | |||
45 | # Clear environment from variables that override config. | ||
46 | unset XDG_DATA_HOME | ||
47 | unset XDG_CONFIG_HOME | ||
48 | # | ||
49 | echo -n "Launching exchange ..." | ||
50 | PREFIX= | ||
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 | |||
54 | CONFIG=test_taler_exchange_unix.conf | ||
55 | |||
56 | # Setup database | ||
57 | taler-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? | ||
62 | UNIXPATH=`taler-config -c $CONFIG -s exchange -f -o UNIXPATH` | ||
63 | |||
64 | # Give HTTP time to start | ||
65 | |||
66 | for n in `seq 1 100` | ||
67 | do | ||
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 | ||
73 | done | ||
74 | if [ 1 != $OK ] | ||
75 | then | ||
76 | exit_fail "Failed to launch exchange" | ||
77 | fi | ||
78 | echo " DONE" | ||
79 | |||
80 | # Finally run test... | ||
81 | echo -n "Restarting program ..." | ||
82 | kill -SIGHUP $! | ||
83 | sleep 1 | ||
84 | curl --unix-socket "${UNIXPATH}" "http://ignored/" >/dev/null 2> /dev/null || exit_fail "SIGHUP killed HTTP service" | ||
85 | echo " DONE" | ||
86 | |||
87 | echo -n "Waiting for parent to die ..." | ||
88 | wait $! | ||
89 | echo " DONE" | ||
90 | |||
91 | echo -n "Testing child still alive ..." | ||
92 | curl --unix-socket "${UNIXPATH}" "http://ignored/" >/dev/null 2> /dev/null || exit_fail "SIGHUP killed HTTP service" | ||
93 | echo " DONE" | ||
94 | |||
95 | |||
96 | echo -n "Killing grandchild ..." | ||
97 | CPID=`ps x | grep taler-exchange-httpd | grep -v grep | awk '{print $1}'` | ||
98 | kill -TERM $CPID | ||
99 | while true | ||
100 | do | ||
101 | ps x | grep -v grep | grep taler-exchange-httpd > /dev/null || break | ||
102 | sleep 0.1 | ||
103 | done | ||
104 | echo " DONE" | ||
105 | |||
106 | # Return status code from exchange for this script | ||
107 | exit 0 | ||