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