Makefile updates for Automake 1.5+. Test script updates
[idzebra-moved-to-github.git] / test / gils / stop02.sh
1 #!/bin/sh
2 # $Id: stop02.sh,v 1.4 2003-05-21 14:39:22 adam Exp $
3 # test start and stop of the server with -S
4 #
5 # FIXME - this test does not currently pass  (H 22-oct-2002)
6 # Something rotten with signals and threads and mutexes...
7
8 echo "initializing"
9 mkdir -p reg
10 rm -f idx.log srv.log
11 ../../index/zebraidx -l idx.log -c zebra1.cfg init || exit 1
12
13 #create a base to test on
14 ../../index/zebraidx -l idx.log -c zebra1.cfg update records  || exit 1
15
16 #kill old server (if any)
17 test -f zebrasrv.pid && kill -9 `cat zebrasrv.pid`
18 rm -f zebrasrv.pid
19 rm -f srv.log
20
21 echo "Starting server with -S (static)..."
22 ../../index/zebrasrv -S -c zebra1.cfg -l srv.log tcp:@:9901 &
23 sleep 1
24
25 echo "  checking that it runs... "
26 test -f zebrasrv.pid || exit 1
27 PID=`cat zebrasrv.pid`
28 ps -p $PID |grep $PID >/dev/null || exit 1
29
30 echo "  connecting to it..."
31 ../api/testclient localhost:9901 utah > log || exit 1
32 sleep 1
33
34 echo "  checking that it still runs..."
35 ps -p $PID | grep $PID >/dev/null || exit 1
36
37 echo "  connecting again, with a delay..."
38 ../api/testclient -d 5 localhost:9901 utah > log &
39 sleep 1 # let the client connect 
40
41 echo "  killing it..."
42 kill  $PID
43
44 sleep 1
45 echo "  checking that it is dead..."
46 ps -p $PID | grep $PID >/dev/null && exit 1
47
48 # clean up
49 rm -rf reg idx.log srv.log zebrasrv.pid