a057327f23e9c0c3dfdeff124a324e82df545891
[idzebra-moved-to-github.git] / test / gils / stop03.sh
1 #!/bin/sh
2 # $Id: stop03.sh,v 1.5 2003-05-24 22:34:48 adam Exp $
3 # test start and stop of the threaded server (-T)
4
5 LOG=stop03.log
6
7 rm -f $LOG
8 echo "initializing" >>$LOG
9 mkdir -p reg
10 ../../index/zebraidx -l $LOG -c zebra1.cfg init || exit 1
11
12 #create a base to test on
13 ../../index/zebraidx -l $LOG -c zebra1.cfg update records  || exit 1
14
15 #kill old server (if any)
16 test -f zebrasrv.pid && kill -9 `cat zebrasrv.pid`
17
18 echo "Starting server with -T (threaded)..." >>$LOG
19 (
20   ../../index/zebrasrv -T -c zebra1.cfg -l $LOG tcp:@:9901 ||
21     echo "server failed with $?" > $LOG
22 )&
23 sleep 1
24
25 echo "  checking that it runs... " >>$LOG
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..." >>$LOG
31 ../api/testclient localhost:9901 utah >>$LOG || exit 1
32 sleep 1
33
34 echo "  checking that it still runs..." >>$LOG
35 ps -p $PID >/dev/null || exit 1
36
37 echo "  connecting again, with a delay..." >>$LOG
38 ../api/testclient localhost:9901 utah 5 >>$LOG &
39 sleep 1 # let the client connect 
40
41 echo "  killing it..." >>$LOG
42 kill $PID
43 sleep 1
44
45 echo "  checking that it is dead" >>$LOG
46 ps -p $PID | grep $PID >/dev/null && exit 1
47
48 # clean up
49 rm -rf reg zebrasrv.pid