Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/gils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ check_SCRIPTS = stop01.sh stop02.sh stop03.sh stop04.sh \

TESTS = $(check_SCRIPTS)

EXTRA_DIST = cleanrecords.sh zebra1.cfg zebra2.cfg $(check_SCRIPTS)
EXTRA_DIST = cleanrecords.sh cleanup.sh zebra1.cfg zebra2.cfg $(check_SCRIPTS)

clean-local:
-rm -rf *.LCK
Expand Down
53 changes: 53 additions & 0 deletions test/gils/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Source after the server has started and written z.pid.
# LOG and srcdir are supplied by the test; CLIENT_PID is optional.

PID=$(cat z.pid)

cleanup()
{
status=$?
trap - 0
trap '' INT TERM
set +e
echo "stopping server..." >>"$LOG"
kill "$PID" 2>/dev/null
attempts=0
stopped=1
while kill -0 "$PID" 2>/dev/null; do
if [ "$attempts" -ge 5 ]; then
echo "server $PID did not stop" >>"$LOG"
stopped=0
if [ "$status" -eq 0 ]; then
status=1
fi
break
fi
sleep 1
attempts=$((attempts + 1))
# A signal during request handling may need repeating to wake the loop.
kill "$PID" 2>/dev/null
done
if [ -n "${CLIENT_PID:-}" ]; then
# The delayed testclient is bounded; let it finish and check its result.
if wait "$CLIENT_PID"; then
:
else
client_status=$?
if [ "$status" -eq 0 ]; then
status=$client_status
fi
fi
fi
if [ "$stopped" -eq 1 ]; then
rm -f z.pid
fi
if ! "$srcdir/cleanrecords.sh"; then
if [ "$status" -eq 0 ]; then
status=1
fi
fi
exit "$status"
}
trap cleanup 0
trap 'exit 130' INT
trap 'exit 143' TERM
27 changes: 15 additions & 12 deletions test/gils/stop01.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
#!/bin/sh
# test start and stop of the server with -1
# test start and stop of the server with unix socket and one shot -1

set -e
srcdir=${srcdir:-"."}

if [ "$srcdir" != "." ]
then
echo "Jumping over test"
exit 0
fi

LOG=stop01.log

rm -f $LOG
echo "initializing" >>$LOG
test -d reg || mkdir reg
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init

#create a base to test on
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records || exit 1
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records

echo "Starting server with -1 (one shot)..." >>$LOG
../../index/zebrasrv -D -p z.pid -1 -c $srcdir/zebra1.cfg -l $LOG unix:socket
echo " checking that it runs... " >>$LOG
test -f z.pid || exit 1
PID=`cat z.pid`
kill -CHLD $PID >/dev/null 2>&1 || exit 1
test -f z.pid
. "$srcdir/cleanup.sh"
kill -CHLD $PID >/dev/null 2>&1

echo " connecting to it..." >>$LOG
../api/testclient unix:socket utah >>$LOG || exit 1
../api/testclient unix:socket utah >>$LOG

echo " checking that server does not run any more" >>$LOG
kill -CHLD $PID >/dev/null 2>&1 && sleep 1 && \
kill -CHLD $PID >/dev/null 2>&1 && exit 1
if kill -CHLD "$PID" >/dev/null 2>&1; then
sleep 1
if kill -CHLD "$PID" >/dev/null 2>&1; then
exit 1
fi
fi

# clean up
rm -rf reg z.pid
rm -rf reg
30 changes: 17 additions & 13 deletions test/gils/stop02.sh
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
#!/bin/sh
# test start and stop of the server with -S

set -e
srcdir=${srcdir:-"."}

if [ "$srcdir" != "." ]
then
echo "Jumping over test"
exit 0
fi

LOG=stop02.log

rm -f $LOG
echo "initializing" >>$LOG
test -d reg || mkdir reg
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init

#create a base to test on
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records || exit 1
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records

echo "Starting server with -S (static)..." >>$LOG
../../index/zebrasrv -D -p z.pid -S -c $srcdir/zebra1.cfg -l $LOG unix:socket
echo " checking that it runs... " >>$LOG
test -f z.pid || exit 1
PID=`cat z.pid`
kill -CHLD $PID >/dev/null 2>&1 || exit 1
test -f z.pid
. "$srcdir/cleanup.sh"
kill -CHLD $PID >/dev/null 2>&1

echo " connecting to it..." >>$LOG
../api/testclient unix:socket utah >>$LOG || exit 1
../api/testclient unix:socket utah >>$LOG
sleep 1

echo " checking that it still runs..." >>$LOG
kill -CHLD $PID >/dev/null 2>&1 || exit 1
kill -CHLD $PID >/dev/null 2>&1

echo " connecting again, with a delay..." >>$LOG
../api/testclient -d 5 unix:socket utah >>$LOG &
sleep 1 # let the client connect
CLIENT_PID=$!
sleep 1 # let the client connect

echo " killing it..." >>$LOG
kill $PID

echo " checking that it is dead..." >>$LOG
kill -CHLD $PID >/dev/null 2>&1 && sleep 1 && \
kill -CHLD $PID >/dev/null 2>&1 && exit 1
if kill -CHLD $PID >/dev/null 2>&1; then
sleep 1
if kill -CHLD $PID >/dev/null 2>&1; then
exit 1
fi
fi

# clean up
rm -rf reg z.pid
rm -rf reg
49 changes: 28 additions & 21 deletions test/gils/stop03.sh
Original file line number Diff line number Diff line change
@@ -1,60 +1,67 @@
#!/bin/sh
# test start and stop of the threaded server (-T)

set -e
srcdir=${srcdir:-"."}

if [ "$srcdir" != "." ]
then
echo "Jumping over test"
exit 0
fi

LOG=stop03.log

rm -f $LOG
echo "initializing" >>$LOG
mkdir -p reg
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init

#create a base to test on
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records || exit 1
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records

echo "Starting server with -T (threaded)..." >>$LOG
../../index/zebrasrv -D -p z.pid -T -c $srcdir/zebra1.cfg -l $LOG unix:socket 2>out

if grep 'not available' out >/dev/null; then
test -f z.pid && rm -f z.pid
exit 0
if ../../index/zebrasrv -D -p z.pid -T \
-c "$srcdir/zebra1.cfg" -l "$LOG" unix:socket 2>out; then
:
else
if grep 'not available' out >/dev/null; then
rm -f z.pid
exit 0
fi
exit 1
fi

echo " checking that it runs..." >>$LOG
test -f z.pid || exit 1
test -f z.pid

PID=`cat z.pid`
. "$srcdir/cleanup.sh"
echo " checking that it still runs..." >>$LOG
kill -CHLD $PID >/dev/null 2>&1 || exit 1
kill -CHLD $PID >/dev/null 2>&1

echo " connecting to it..." >>$LOG
../api/testclient unix:socket utah >>$LOG || exit 1
../api/testclient unix:socket utah >>$LOG
sleep 1

echo " checking that it still runs..." >>$LOG
kill -CHLD $PID >/dev/null 2>&1 || exit 1
kill -CHLD $PID >/dev/null 2>&1

echo " connecting again, with a delay..." >>$LOG
../api/testclient unix:socket utah 5 >>$LOG &
sleep 1 # let the client connect
../api/testclient -d 5 unix:socket utah >>$LOG &
CLIENT_PID=$!
sleep 1 # let the client connect

echo " checking that it still runs..." >>$LOG
kill -CHLD $PID >/dev/null 2>&1 || exit 1
kill -CHLD $PID >/dev/null 2>&1

echo " killing it..." >>$LOG
kill $PID
sleep 1

echo " checking that it is dead..." >>$LOG
kill -CHLD $PID >/dev/null 2>&1 && sleep 1 && \
kill -CHLD $PID >/dev/null 2>&1 && exit 1

if kill -CHLD $PID >/dev/null 2>&1; then
sleep 1
if kill -CHLD $PID >/dev/null 2>&1; then
exit 1
fi
fi
# clean up
rm -rf reg z.pid
rm -rf reg
33 changes: 18 additions & 15 deletions test/gils/stop04.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
#!/bin/sh
# test start and stop of the forked server
# test start and stop of the forked server

set -e
srcdir=${srcdir:-"."}

if [ "$srcdir" != "." ]
then
echo "Jumping over test"
exit 0
fi

LOG=stop04.log

rm -f $LOG
echo "initializing" >>$LOG
mkdir -p reg
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init

#create a base to test on
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records || exit 1
../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records

echo "Starting server with (forked)..." >>$LOG
../../index/zebrasrv -D -p z.pid -c $srcdir/zebra1.cfg -l $LOG unix:socket

echo " checking that it runs... " >>$LOG
test -f z.pid || exit 1
PID=`cat z.pid`
kill -CHLD $PID >/dev/null 2>&1 || exit 1
. "$srcdir/cleanup.sh"
kill -CHLD $PID >/dev/null 2>&1

echo " connecting to it..." >>$LOG
../api/testclient unix:socket utah >>$LOG || exit 1
../api/testclient unix:socket utah >>$LOG
sleep 1

echo " checking that it still runs..." >>$LOG
kill -CHLD $PID >/dev/null 2>&1 || exit 1
kill -CHLD $PID >/dev/null 2>&1

echo " connecting again, with a delay..." >>$LOG
../api/testclient unix:socket utah 5 >>$LOG
sleep 1 # let the client connect
../api/testclient -d 5 unix:socket utah >>$LOG &
CLIENT_PID=$!
sleep 1 # let the client connect

echo " killing it..." >>$LOG
kill $PID
sleep 1

echo " checking that it is dead..." >>$LOG
kill -CHLD $PID >/dev/null 2>&1 && sleep 1 && \
kill -CHLD $PID >/dev/null 2>&1 && exit 1

if kill -CHLD $PID >/dev/null 2>&1; then
sleep 1
if kill -CHLD $PID >/dev/null 2>&1; then
exit 1
fi
fi

# clean up
rm -rf reg z.pid
rm -rf reg
Loading
Loading