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