Assume PID file has been created just after server has started
[idzebra-moved-to-github.git] / test / gils / timing2.sh
1 #!/bin/sh
2 # $Id: timing2.sh,v 1.11 2005-01-03 09:19:26 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 "  starting server..." >>$LOG
18 ../../index/zebrasrv -D -p z.pid -S -c $pp/zebra2.cfg -l $LOG tcp:@:9901
19 test -f z.pid || exit 1
20 sleep 1
21 touch timeref2  # make a later timestamp
22
23 echo "  update 1..." >>$LOG
24 ../../index/zebraidx -l $LOG -c $pp/zebra2.cfg update $pp/records || exit 1
25
26 echo "  search 1..." >>$LOG
27 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
28 grep "^Result count: 9$" log >/dev/null || exit 1
29
30 echo "making a test record..." >>$LOG
31 cp $pp/records/esdd0006.grs $pp/records/esdd0002.grs
32 touch -r timeref1 $pp/records/esdd0002.grs
33
34 echo "  indexing it..." >>$LOG
35 ../../index/zebraidx -l $LOG -c $pp/zebra2.cfg update $pp/records || exit 1
36
37 echo "  search 2..." >>$LOG
38 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
39 grep "^Result count: 10$" log >/dev/null || exit 1
40
41 echo "  modifying a test record (xyz)..." >>$LOG
42 sed 's/UTAH/XYZ/g' <$pp/records/esdd0002.grs >$pp/records/esdd0002x.grs
43 mv $pp/records/esdd0002x.grs $pp/records/esdd0002.grs
44 touch -r timeref1 $pp/records/esdd0002.grs # reset timestamp to 'early'
45
46 echo "    not indexing it..." >>$LOG
47 ../../index/zebraidx -l $LOG -c $pp/zebra2.cfg update $pp/records || exit 1
48
49 echo "    search 3..." >>$LOG
50 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
51 echo "    checking..." >>$LOG
52 grep "^Result count: 10$" log >/dev/null || exit 1
53
54 echo "  touching its timestamp..." >>$LOG
55 touch -r timeref2 $pp/records/esdd0002.grs # set timestamp to 'late'
56
57 echo "    indexing it..." >>$LOG
58 ../../index/zebraidx -l $LOG -c $pp/zebra2.cfg update $pp/records || exit 1
59
60 echo "    search 4..." >>$LOG
61 ../api/testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
62 echo "    checking..." >>$LOG
63 grep "^Result count: 9$" log >/dev/null || exit 1
64
65 echo "stopping server..." >>$LOG
66 test -f z.pid || exit 1
67 kill `cat z.pid` || exit 1
68 rm -f log timeref[12]
69 rm -f $pp/records/esdd000[12].grs 
70 rm -f z.pid
71