-
Notifications
You must be signed in to change notification settings - Fork 2
/
testhaproxy.sh
executable file
·113 lines (94 loc) · 2.28 KB
/
testhaproxy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
set -e
# Run a haproxy test
# to pick up correct .so's - maybe note
: ${CODETOP:="$HOME/code/openssl"}
# to pick up correct wrapper scripts
: ${EDTOP:="$HOME/code/ech-dev-utils"}
# to set where our cadir and ECH keys are
: ${RUNTOP:="$HOME/lt"}
# where backend web server can be found
: ${LIGHTY:="$HOME/code/lighttpd1.4"}
# where frontend haproxy can be found
: ${HAPPY:="$HOME/code/haproxy"}
if [[ "$PACKAGING" == "" ]]
then
HAPPYBIN=$HAPPY/haproxy
CMDPATH=$CODETOP/apps/openssl
else
CMDPATH=`which openssl`
HAPPYBIN=`which haproxy`
EDTOP="$(dirname "$(realpath "$0")")/.."
RUNTOP=`mktemp -d`
# VERBOSE=yes
fi
export RUNTOP=$RUNTOP
export LD_LIBRARY_PATH=$CODETOP
HLOGDIR="$RUNTOP/haproxy/logs"
SRVLOGFILE="$HLOGDIR/haproxy.log"
CLILOGFILE="$HLOGDIR/clienttest.log"
BE_PIDFILE="$RUNTOP/haproxy/logs/haproxy.pid"
KEEPLOG="no"
allgood="yes"
. $EDTOP/scripts/funcs.sh
prep_server_dirs lighttpd
mkdir -p $HLOGDIR
if [ ! -f $SRVLOGFILE ]
then
touch $SRVLOGFILE
chmod a+w $SRVLOGFILE
fi
lighty_stop
if [ -f $BE_PIDFILE ]
then
kill `cat $BE_PIDFILE`
rm -f $BE_PIDFILE
fi
lighty_start $EDTOP/configs/lighttpd4haproxymin.conf
# Now start up a haproxy
# run haproxy in background
cd $RUNTOP
HAPDEBUGSTR=" -DdV "
echo "Executing: $HAPPYBIN -f $EDTOP/configs/haproxymin.conf $HAPDEBUGSTR >$SRVLOGFILE 2>&1"
$HAPPYBIN -f $EDTOP/configs/haproxymin.conf $HAPDEBUGSTR >$SRVLOGFILE 2>&1 || true
if [[ "$VERBOSE" == "yes" ]]
then
cat $SRVLOGFILE
fi
cd -
# all things should appear the same to the client
# server log checks will tells us if stuff worked or not
echo "Doing shared-mode client calls..."
for type in grease public real hrr
do
for port in 7443 7444 7445
do
echo "Testing $type $port"
cli_test $port $type
if [[ "$VERBOSE" == "yes" ]]
then
cat $CLILOGFILE
rm -f $CLILOGFILE
fi
done
done
lighty_stop
if [ -f $BE_PIDFILE ]
then
kill `cat $BE_PIDFILE`
rm -f $BE_PIDFILE
fi
if [[ "$allgood" == "yes" ]]
then
echo "All good."
rm -f $CLILOGFILE $SRVLOGFILE
else
echo "Something failed."
if [[ "$KEEPLOG" != "no" ]]
then
echo "Client logs in $CLILOGFILE"
echo "Server logs in $SRVLOGFILE"
else
rm -f $CLILOGFILE $SRVLOGFILE
fi
fi