Using my new tests (those that pass!)
[idzebra-moved-to-github.git] / test / gils / test03.sh
1 # test03.sh - test start and stop of the threaded server (-T)
2 #
3 # FIXME - this test does not currently pass  (H 22-oct-2002)
4 # When the client exits, the process dies with a segfault
5
6 echo "initializing"
7 mkdir -p reg
8 rm -f idx.log srv.log servercrash
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 -T (threaded)..."
20 (
21   ../../index/zebrasrv -T -c zebra1.cfg -l srv.log tcp:@:9901 ||
22     echo "server failed with $?" > servercrash
23 )&
24 sleep 1
25
26 echo "  cheking that it runs... "
27 test -f zebrasrv.pid || exit 1
28 PID=`cat zebrasrv.pid`
29 ps -p $PID >/dev/null || exit 1
30
31 echo "  connecting to it..."
32 ../testclient localhost:9901 utah > log || exit 1
33 sleep 1
34
35 echo "  checking that it still runs..."
36 ps -p $PID >/dev/null || exit 1
37
38 echo "  connecting again, with a delay..."
39 ../testclient localhost:9901 utah 5 > log &
40 sleep 1 # let the client connect 
41
42 echo "  killing it..."
43 kill  $PID
44 sleep 1
45
46 echo "  checking that it still runs waiting for the client"
47 ps -p $PID >/dev/null || exit 1
48
49 echo "  waiting for the client to exit..."
50 sleep 3
51
52 echo "  checking that the server is dead..."
53 ps -p $PID >/dev/null && exit 1
54
55 echo "  checking that it exited normally..."
56 test -f servercrash && exit 1
57
58 echo ok
59 # clean up
60 rm -rf reg idx.log srv.log zebrasrv.pid servercrash