Added a timing test, minor modifications in 02
[idzebra-moved-to-github.git] / test / gils / timing1.sh
1 # timing1.sh - tests that updates are reflected immediately
2 # in the registers. Repeatedly modifies a record and counts hits.
3 # Because of the timing aspect of this, if may fail at any time
4 # or not at all. 
5
6 echo "Testing timings of updates"
7 echo "  init..."
8 rm -f idx.log log
9 rm -f records/esdd000[12].grs # these should not be here, will be created later
10 ../../index/zebraidx -l idx.log init || exit 1
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
22 echo "  update 1..."
23 ../../index/zebraidx -l idx.log -c zebra2.cfg update records || exit 1
24
25 echo "  search 1..."
26 ../testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
27 grep "^Result count: 9$" log || exit 1
28
29 echo "making a test record..."
30 cp records/esdd0006.grs records/esdd0002.grs
31
32 echo "  indexing it..."
33 ../../index/zebraidx -l idx.log -c zebra2.cfg update records || exit 1
34
35 echo "  search 2..."
36 ../testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
37 grep "^Result count: 10$" log || exit 1
38 echo "  1a: modifying a test record (xyz)..."
39 sed 's/UTAH/XYZ/g' <records/esdd0002.grs >records/esdd0002x.grs
40 mv records/esdd0002x.grs records/esdd0002.grs
41
42 echo "    indexing it..."
43 ../../index/zebraidx -l idx.log -c zebra2.cfg update records || exit 1
44
45 echo "    search 3..."
46 ../testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
47 echo "    checking..."
48 grep "^Result count: 9$" log || exit 1
49
50 echo "  1b: modifying the test record back (utah)..."
51 sed 's/XYZ/UTAH/g' <records/esdd0002.grs >records/esdd0002x.grs
52 mv records/esdd0002x.grs records/esdd0002.grs
53
54 echo "    indexing it..."
55 ../../index/zebraidx -l idx.log -c zebra2.cfg update records || exit 1
56
57 echo "    search 4..."
58 ../testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
59 echo "    checking..."
60 grep "^Result count: 10$" log || exit 1
61
62 echo "  2a: modifying the test record (xyz)..."
63 sed 's/UTAH/XYZ/g' <records/esdd0002.grs >records/esdd0002x.grs
64 mv records/esdd0002x.grs records/esdd0002.grs
65
66 echo "    indexing it..."
67 ../../index/zebraidx -l idx.log -c zebra2.cfg update records || exit 1
68
69 echo "    search 5..."
70 ../testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
71 echo "    checking..."
72 grep "^Result count: 9$" log || exit 1
73
74 echo "  2b: modifying the test record back (utah)..."
75 sed 's/XYZ/UTAH/g' <records/esdd0002.grs >records/esdd0002x.grs
76 mv records/esdd0002x.grs records/esdd0002.grs
77
78 echo "    indexing it..."
79 ../../index/zebraidx -l idx.log -c zebra2.cfg update records || exit 1
80
81 echo "    search 6..."
82 ../testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
83 echo "    checking..."
84 grep "^Result count: 10$" log || exit 1
85
86
87 echo "  3a: modifying the test record (xyz)..."
88 sed 's/UTAH/XYZ/g' <records/esdd0002.grs >records/esdd0002x.grs
89 mv records/esdd0002x.grs records/esdd0002.grs
90
91 echo "    indexing it..."
92 ../../index/zebraidx -l idx.log -c zebra2.cfg update records || exit 1
93
94 echo "    search 7..."
95 ../testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
96 echo "    checking..."
97 grep "^Result count: 9$" log || exit 1
98
99 echo "  3b: modifying the test record back (utah)..."
100 sed 's/XYZ/UTAH/g' <records/esdd0002.grs >records/esdd0002x.grs
101 mv records/esdd0002x.grs records/esdd0002.grs
102
103 echo "    indexing it..."
104 ../../index/zebraidx -l idx.log -c zebra2.cfg update records || exit 1
105
106 echo "    search 8..."
107 ../testclient localhost:9901 "@attr 1=4 utah" > log || exit 1
108 echo "    checking..."
109 grep "^Result count: 10$" log || exit 1
110
111
112 echo "stopping server..."
113 test -f zebrasrv.pid || exit 1
114 kill -9 `cat zebrasrv.pid` || exit 1
115 rm -f idx.log log
116 rm -f records/esdd000[12].grs 
117 rm -f zebrasrv.pid
118 rm -f srv.log
119
120 echo ok