Zebra now works with make distcheck
[idzebra-moved-to-github.git] / test / gils / timing2.sh
1 #!/bin/sh
2 # $Id: timing2.sh,v 1.9 2004-06-15 09:43:30 adam Exp $ 
3 # Demonstrated that updates depend on file timestamps
4
5 pp=${srcdir:-"."}
6
7 LOG=timing2.log
8
9 rm -f $LOG
10
11 echo "  init..." >>$LOG
12 rm -f log timeref[12]
13 rm -f $pp/records/esdd000[12].grs # these should not be here, will be created later
14 ../../index/zebraidx -c $pp/zebra2.cfg -l $LOG init || exit 1
15 touch timeref1  # make an early timestamp
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 $pp/zebra2.cfg -l $LOG tcp:@:9901 &
22 sleep 1
23 test -f zebrasrv.pid || exit 1
24 touch timeref2  # make a later timestamp
25
26 echo "  update 1..." >>$LOG
27 ../../index/zebraidx -l $LOG -c $pp/zebra2.cfg update $pp/records || exit 1
28
29 echo "  search 1..." >>$LOG
30 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
31 grep "^Result count: 9$" log >/dev/null || exit 1
32
33 echo "making a test record..." >>$LOG
34 cp $pp/records/esdd0006.grs $pp/records/esdd0002.grs
35 touch -r timeref1 $pp/records/esdd0002.grs
36
37 echo "  indexing it..." >>$LOG
38 ../../index/zebraidx -l $LOG -c $pp/zebra2.cfg update $pp/records || exit 1
39
40 echo "  search 2..." >>$LOG
41 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
42 grep "^Result count: 10$" log >/dev/null || exit 1
43
44 echo "  modifying a test record (xyz)..." >>$LOG
45 sed 's/UTAH/XYZ/g' <$pp/records/esdd0002.grs >$pp/records/esdd0002x.grs
46 mv $pp/records/esdd0002x.grs $pp/records/esdd0002.grs
47 touch -r timeref1 $pp/records/esdd0002.grs # reset timestamp to 'early'
48
49 echo "    not indexing it..." >>$LOG
50 ../../index/zebraidx -l $LOG -c $pp/zebra2.cfg update $pp/records || exit 1
51
52 echo "    search 3..." >>$LOG
53 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
54 echo "    checking..." >>$LOG
55 grep "^Result count: 10$" log >/dev/null || exit 1
56
57 echo "  touching its timestamp..." >>$LOG
58 touch -r timeref2 $pp/records/esdd0002.grs # set timestamp to 'late'
59
60 echo "    indexing it..." >>$LOG
61 ../../index/zebraidx -l $LOG -c $pp/zebra2.cfg update $pp/records || exit 1
62
63 echo "    search 4..." >>$LOG
64 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
65 echo "    checking..." >>$LOG
66 grep "^Result count: 9$" log >/dev/null || exit 1
67
68 echo "stopping server..." >>$LOG
69 test -f zebrasrv.pid || exit 1
70 kill `cat zebrasrv.pid` || exit 1
71 rm -f log timeref[12]
72 rm -f $pp/records/esdd000[12].grs 
73 rm -f zebrasrv.pid
74