Prepare for srcdir != builddir in tests
[idzebra-moved-to-github.git] / test / gils / stop02.sh
1 #!/bin/sh
2 # $Id: stop02.sh,v 1.6 2004-06-14 23:45:11 adam Exp $
3 # test start and stop of the server with -S
4
5 pp=${srcdir:-"."}
6
7 LOG=stop02.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 -S (static)..." >>$LOG
21 ../../index/zebrasrv -S -c $pp/zebra1.cfg -l $LOG tcp:@:9901 &
22 sleep 1
23
24 echo "  checking that it runs... " >>$LOG
25 test -f zebrasrv.pid || exit 1
26 PID=`cat zebrasrv.pid`
27 ps -p $PID |grep $PID >/dev/null || exit 1
28
29 echo "  connecting to it..." >>$LOG
30 ../api/testclient localhost:9901 utah >>$LOG || exit 1
31 sleep 1
32
33 echo "  checking that it still runs..." >>$LOG
34 ps -p $PID | grep $PID >/dev/null || exit 1
35
36 echo "  connecting again, with a delay..." >>$LOG
37 ../api/testclient -d 5 localhost:9901 utah >>$LOG &
38 sleep 1 # let the client connect 
39
40 echo "  killing it..." >>$LOG
41 kill $PID
42
43 sleep 1
44 echo "  checking that it is dead..." >>$LOG
45 ps -p $PID | grep $PID >/dev/null && exit 1
46
47 # clean up
48 rm -rf reg zebrasrv.pid