New tests for the forward function (simple ands and ors)
[idzebra-moved-to-github.git] / test / gils / test2.sh
1 #!/bin/sh
2 # $Id: test2.sh,v 1.7 2003-05-24 22:34:48 adam Exp $
3
4 LOG=test2.log
5
6 rm -f $LOG
7 echo "init..." >>$LOG
8 rm -f records/esdd000[12].grs # these should not be here, will be created later
9 ../../index/zebraidx -l $LOG -c zebra2.cfg init || exit 1
10
11 echo "update 1..." >>$LOG
12 ../../index/zebraidx -l $LOG -c zebra2.cfg update records || exit 1
13
14 echo "update 2..." >>$LOG
15 ../../index/zebraidx -l $LOG -c zebra2.cfg update records || exit 1
16
17 echo "killing old server (if any)..." >>$LOG
18 test -f zebrasrv.pid && kill -9 `cat zebrasrv.pid`
19
20 echo "starting server..." >>$LOG
21 ../../index/zebrasrv -S -c zebra2.cfg -l $LOG tcp:@:9901 &
22 sleep 1
23 test -f zebrasrv.pid || exit 1
24
25 echo "search 1..." >>$LOG
26 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
27 grep "^Result count: 9$" log >/dev/null || exit 1
28
29 echo "update 3..." >>$LOG
30 ../../index/zebraidx -l $LOG -c zebra2.cfg update records || exit 1
31
32 echo "search 2..." >>$LOG
33 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
34 grep "^Result count: 9$" log >/dev/null || exit 1
35
36 echo "making test records..." >>$LOG
37 cp records/esdd0006.grs records/esdd0001.grs
38
39 echo "indexing them..." >>$LOG
40 ../../index/zebraidx -l $LOG -c zebra2.cfg update records || exit 1
41
42 echo "search 3..." >>$LOG
43 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
44 grep "^Result count: 10$" log >/dev/null || exit 1
45 touch records/esdd0001.grs
46
47 echo "indexing again..." >>$LOG
48 ../../index/zebraidx -l $LOG -c zebra2.cfg update records || exit 1
49
50 echo "search 4..." >>$LOG
51 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
52 grep "^Result count: 10$" log >/dev/null || exit 1
53
54 echo "making another test record..." >>$LOG
55 mv records/esdd0001.grs records/esdd0002.grs
56
57 echo "indexing it too..." >>$LOG
58 ../../index/zebraidx -l $LOG -c zebra2.cfg update records || exit 1
59
60 echo "search 5..." >>$LOG
61 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
62 grep "^Result count: 10$" log >/dev/null || exit 1
63
64 sleep 1
65 echo "modifying a test record..." >>$LOG
66 sed 's/UTAH/XYZ/g' <records/esdd0002.grs >records/esdd0002x.grs
67 mv records/esdd0002x.grs records/esdd0002.grs
68
69 echo "indexing it..." >>$LOG
70 ../../index/zebraidx -l $LOG -c zebra2.cfg update records || exit 1
71 sleep 1
72
73 echo "search 6..." >>$LOG
74 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
75 grep "^Result count: 9$" log >/dev/null || exit 1
76
77 echo "search 7..." >>$LOG
78 ../api/testclient localhost:9901 "@attr 1=4 xyz" > log || exit 1
79 grep "^Result count: 1$" log >/dev/null || exit 1
80
81 echo "stopping server..." >>$LOG
82 test -f zebrasrv.pid || exit 1
83 kill `cat zebrasrv.pid` || exit 1
84 rm -f log
85 rm -f records/esdd000[12].grs 
86 rm -f zebrasrv.pid