A new test case, h3.sh, and its config h2.cfg
[idzebra-moved-to-github.git] / test / gils / h3.sh
1 # h3.sh - studying the "timing" problem
2
3 # timing1.sh - tests that updates are reflected immediately
4 # in the registers. Repeatedly modifies a record and counts hits.
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 h2.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 h2.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 h2.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
39 echo "  1a: modifying a test record (xyz)..."
40 cat records/esdd0002.grs | 
41   sed 's/UTAH/XYZ/g' |
42   sed 's/ESDD0006/ESDD0002/g' |
43   sed 's/EARTHQUAKE/TESTRECORD/g'  >/tmp/esdd0002x.grs
44 cat /tmp/esdd0002x.grs >records/esdd0002.grs
45
46 echo "    indexing it..."
47 ../../index/zebraidx -l idx.log -c h2.cfg update records/esdd0002.grs || exit 1
48 #grep XYZ records/esdd0002.grs  # shows that indeed have XYZ in the data
49
50 echo "    search 3..."
51 ../testclient localhost:9901 "@attr 1=4 xyz" > log || exit 1
52 cat log
53 grep -q "^Result count: 1$" log || echo "ERROR ---> Result count should have been 1"
54
55 echo "stopping server..."
56 kill -9 `cat zebrasrv.pid` 
57 sleep 1
58
59 echo "  starting a new server..."
60 ../../index/zebrasrv -S -c h2.cfg -l srv2.log tcp:@:9901 &
61 sleep 1
62 test -f zebrasrv.pid || exit 1
63
64 echo "    search 4..."
65 ../testclient localhost:9901 "@attr 1=4 xyz" > log || exit 1
66 cat log
67 grep -q "^Result count: 1$" log || echo "ERROR ---> Result count should have been 1"
68
69
70 echo "stopping server..."
71 test -f zebrasrv.pid || exit 1
72 kill -9 `cat zebrasrv.pid` || exit 1
73 rm -f idx.log log
74 rm -f records/esdd000[12].grs 
75 rm -f zebrasrv.pid
76 rm -f srv.log
77 rm -f /tmp/esdd0002x.grs
78
79 echo ok