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