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