4eff51762ece47e1db258143bcc1e5598b68988f
[idzebra-moved-to-github.git] / test / gils / test1.sh
1 #!/bin/sh
2 # $Id: test1.sh,v 1.14 2006-04-27 10:52:26 marc Exp $
3
4 srcdir=${srcdir:-"."}
5
6 if [ "$srcdir" != "." ]
7     then
8     echo "Jumping over test"
9     exit 0
10 fi
11
12
13 LOG=test1.log
14
15 rm -f $LOG
16 echo  "initializing..." >>$LOG
17 test -d reg || mkdir reg
18
19 # these should not be here, will be created later
20 $srcdir/cleanrecords.sh
21 #if [ -f $srcdir/records/esdd0001.grs ] 
22 #    then
23 #    rm -f $srcdir/records/esdd0001.grs
24 #fi
25 #if [ -f $srcdir/records/esdd0002.grs ] 
26 #    then
27 #    rm -f $srcdir/records/esdd0002.grs
28 #fi
29
30 ../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1
31
32 echo "updating..." >>$LOG
33 ../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update $srcdir/records  || exit 1
34
35 echo "starting server..." >>$LOG
36 ../../index/zebrasrv -D -p z.pid -S -c $srcdir/zebra1.cfg -l $LOG unix:socket
37
38 echo "checking it runs..." >>$LOG
39 test -f z.pid || exit 1
40
41 echo "search 1..." >>$LOG
42 ../api/testclient unix:socket utah > log || exit 1
43 grep "^Result count: 17$" log >/dev/null || exit 1
44
45 echo "search 2..." >>$LOG
46 ../api/testclient unix:socket "@or utah the" > log || exit 1
47 grep "^Result count: 40$" log >/dev/null || exit 1
48
49 echo "search 3..." >>$LOG
50 ../api/testclient unix:socket "@attr 1=4 the" > log || exit 1
51 grep "^Result count: 1$" log >/dev/null || exit 1
52
53 echo "search 4..." >>$LOG
54 ../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1
55 grep "^Result count: 9$" log >/dev/null || exit 1
56
57 echo "reindexing..." >>$LOG
58 ../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update $srcdir/records || exit 1
59
60 echo "search 5..." >>$LOG
61 ../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1
62 grep "^Result count: 18$" log >/dev/null || exit 1
63
64 echo "stopping server..." >>$LOG
65 test -f z.pid || exit 1
66 kill `cat z.pid` || exit 1
67 rm -f z.pid
68