diff --git a/test/gils/Makefile.am b/test/gils/Makefile.am index 82bad95d..5da82ef6 100644 --- a/test/gils/Makefile.am +++ b/test/gils/Makefile.am @@ -9,7 +9,7 @@ check_SCRIPTS = stop01.sh stop02.sh stop03.sh stop04.sh \ TESTS = $(check_SCRIPTS) -EXTRA_DIST = cleanrecords.sh zebra1.cfg zebra2.cfg $(check_SCRIPTS) +EXTRA_DIST = cleanrecords.sh cleanup.sh zebra1.cfg zebra2.cfg $(check_SCRIPTS) clean-local: -rm -rf *.LCK diff --git a/test/gils/cleanup.sh b/test/gils/cleanup.sh new file mode 100644 index 00000000..51b44b96 --- /dev/null +++ b/test/gils/cleanup.sh @@ -0,0 +1,53 @@ +# Source after the server has started and written z.pid. +# LOG and srcdir are supplied by the test; CLIENT_PID is optional. + +PID=$(cat z.pid) + +cleanup() +{ + status=$? + trap - 0 + trap '' INT TERM + set +e + echo "stopping server..." >>"$LOG" + kill "$PID" 2>/dev/null + attempts=0 + stopped=1 + while kill -0 "$PID" 2>/dev/null; do + if [ "$attempts" -ge 5 ]; then + echo "server $PID did not stop" >>"$LOG" + stopped=0 + if [ "$status" -eq 0 ]; then + status=1 + fi + break + fi + sleep 1 + attempts=$((attempts + 1)) + # A signal during request handling may need repeating to wake the loop. + kill "$PID" 2>/dev/null + done + if [ -n "${CLIENT_PID:-}" ]; then + # The delayed testclient is bounded; let it finish and check its result. + if wait "$CLIENT_PID"; then + : + else + client_status=$? + if [ "$status" -eq 0 ]; then + status=$client_status + fi + fi + fi + if [ "$stopped" -eq 1 ]; then + rm -f z.pid + fi + if ! "$srcdir/cleanrecords.sh"; then + if [ "$status" -eq 0 ]; then + status=1 + fi + fi + exit "$status" +} +trap cleanup 0 +trap 'exit 130' INT +trap 'exit 143' TERM diff --git a/test/gils/stop01.sh b/test/gils/stop01.sh index 6c2b2a4e..6905651d 100755 --- a/test/gils/stop01.sh +++ b/test/gils/stop01.sh @@ -1,8 +1,8 @@ #!/bin/sh -# test start and stop of the server with -1 +# test start and stop of the server with unix socket and one shot -1 +set -e srcdir=${srcdir:-"."} - if [ "$srcdir" != "." ] then echo "Jumping over test" @@ -10,28 +10,31 @@ if [ "$srcdir" != "." ] fi LOG=stop01.log - rm -f $LOG echo "initializing" >>$LOG test -d reg || mkdir reg -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init #create a base to test on -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records echo "Starting server with -1 (one shot)..." >>$LOG ../../index/zebrasrv -D -p z.pid -1 -c $srcdir/zebra1.cfg -l $LOG unix:socket echo " checking that it runs... " >>$LOG -test -f z.pid || exit 1 -PID=`cat z.pid` -kill -CHLD $PID >/dev/null 2>&1 || exit 1 +test -f z.pid +. "$srcdir/cleanup.sh" +kill -CHLD $PID >/dev/null 2>&1 echo " connecting to it..." >>$LOG -../api/testclient unix:socket utah >>$LOG || exit 1 +../api/testclient unix:socket utah >>$LOG echo " checking that server does not run any more" >>$LOG -kill -CHLD $PID >/dev/null 2>&1 && sleep 1 && \ -kill -CHLD $PID >/dev/null 2>&1 && exit 1 +if kill -CHLD "$PID" >/dev/null 2>&1; then + sleep 1 + if kill -CHLD "$PID" >/dev/null 2>&1; then + exit 1 + fi +fi # clean up -rm -rf reg z.pid +rm -rf reg diff --git a/test/gils/stop02.sh b/test/gils/stop02.sh index e3052942..b5e41fb8 100755 --- a/test/gils/stop02.sh +++ b/test/gils/stop02.sh @@ -1,8 +1,8 @@ #!/bin/sh # test start and stop of the server with -S +set -e srcdir=${srcdir:-"."} - if [ "$srcdir" != "." ] then echo "Jumping over test" @@ -10,39 +10,43 @@ if [ "$srcdir" != "." ] fi LOG=stop02.log - rm -f $LOG echo "initializing" >>$LOG test -d reg || mkdir reg -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init #create a base to test on -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records echo "Starting server with -S (static)..." >>$LOG ../../index/zebrasrv -D -p z.pid -S -c $srcdir/zebra1.cfg -l $LOG unix:socket echo " checking that it runs... " >>$LOG -test -f z.pid || exit 1 -PID=`cat z.pid` -kill -CHLD $PID >/dev/null 2>&1 || exit 1 +test -f z.pid +. "$srcdir/cleanup.sh" +kill -CHLD $PID >/dev/null 2>&1 echo " connecting to it..." >>$LOG -../api/testclient unix:socket utah >>$LOG || exit 1 +../api/testclient unix:socket utah >>$LOG sleep 1 echo " checking that it still runs..." >>$LOG -kill -CHLD $PID >/dev/null 2>&1 || exit 1 +kill -CHLD $PID >/dev/null 2>&1 echo " connecting again, with a delay..." >>$LOG ../api/testclient -d 5 unix:socket utah >>$LOG & -sleep 1 # let the client connect +CLIENT_PID=$! +sleep 1 # let the client connect echo " killing it..." >>$LOG kill $PID echo " checking that it is dead..." >>$LOG -kill -CHLD $PID >/dev/null 2>&1 && sleep 1 && \ -kill -CHLD $PID >/dev/null 2>&1 && exit 1 +if kill -CHLD $PID >/dev/null 2>&1; then + sleep 1 + if kill -CHLD $PID >/dev/null 2>&1; then + exit 1 + fi +fi # clean up -rm -rf reg z.pid +rm -rf reg diff --git a/test/gils/stop03.sh b/test/gils/stop03.sh index e084c9ee..b5aeb950 100755 --- a/test/gils/stop03.sh +++ b/test/gils/stop03.sh @@ -1,8 +1,8 @@ #!/bin/sh # test start and stop of the threaded server (-T) +set -e srcdir=${srcdir:-"."} - if [ "$srcdir" != "." ] then echo "Jumping over test" @@ -10,51 +10,58 @@ if [ "$srcdir" != "." ] fi LOG=stop03.log - rm -f $LOG echo "initializing" >>$LOG mkdir -p reg -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init #create a base to test on -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records echo "Starting server with -T (threaded)..." >>$LOG -../../index/zebrasrv -D -p z.pid -T -c $srcdir/zebra1.cfg -l $LOG unix:socket 2>out -if grep 'not available' out >/dev/null; then - test -f z.pid && rm -f z.pid - exit 0 +if ../../index/zebrasrv -D -p z.pid -T \ + -c "$srcdir/zebra1.cfg" -l "$LOG" unix:socket 2>out; then + : +else + if grep 'not available' out >/dev/null; then + rm -f z.pid + exit 0 + fi + exit 1 fi - echo " checking that it runs..." >>$LOG -test -f z.pid || exit 1 +test -f z.pid -PID=`cat z.pid` +. "$srcdir/cleanup.sh" echo " checking that it still runs..." >>$LOG -kill -CHLD $PID >/dev/null 2>&1 || exit 1 +kill -CHLD $PID >/dev/null 2>&1 echo " connecting to it..." >>$LOG -../api/testclient unix:socket utah >>$LOG || exit 1 +../api/testclient unix:socket utah >>$LOG sleep 1 echo " checking that it still runs..." >>$LOG -kill -CHLD $PID >/dev/null 2>&1 || exit 1 +kill -CHLD $PID >/dev/null 2>&1 echo " connecting again, with a delay..." >>$LOG -../api/testclient unix:socket utah 5 >>$LOG & -sleep 1 # let the client connect +../api/testclient -d 5 unix:socket utah >>$LOG & +CLIENT_PID=$! +sleep 1 # let the client connect echo " checking that it still runs..." >>$LOG -kill -CHLD $PID >/dev/null 2>&1 || exit 1 +kill -CHLD $PID >/dev/null 2>&1 echo " killing it..." >>$LOG kill $PID sleep 1 echo " checking that it is dead..." >>$LOG -kill -CHLD $PID >/dev/null 2>&1 && sleep 1 && \ -kill -CHLD $PID >/dev/null 2>&1 && exit 1 - +if kill -CHLD $PID >/dev/null 2>&1; then + sleep 1 + if kill -CHLD $PID >/dev/null 2>&1; then + exit 1 + fi +fi # clean up -rm -rf reg z.pid +rm -rf reg diff --git a/test/gils/stop04.sh b/test/gils/stop04.sh index d5faf893..340a21ca 100755 --- a/test/gils/stop04.sh +++ b/test/gils/stop04.sh @@ -1,8 +1,8 @@ #!/bin/sh -# test start and stop of the forked server +# test start and stop of the forked server +set -e srcdir=${srcdir:-"."} - if [ "$srcdir" != "." ] then echo "Jumping over test" @@ -10,42 +10,45 @@ if [ "$srcdir" != "." ] fi LOG=stop04.log - rm -f $LOG echo "initializing" >>$LOG mkdir -p reg -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init #create a base to test on -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update records echo "Starting server with (forked)..." >>$LOG ../../index/zebrasrv -D -p z.pid -c $srcdir/zebra1.cfg -l $LOG unix:socket echo " checking that it runs... " >>$LOG test -f z.pid || exit 1 -PID=`cat z.pid` -kill -CHLD $PID >/dev/null 2>&1 || exit 1 +. "$srcdir/cleanup.sh" +kill -CHLD $PID >/dev/null 2>&1 echo " connecting to it..." >>$LOG -../api/testclient unix:socket utah >>$LOG || exit 1 +../api/testclient unix:socket utah >>$LOG sleep 1 echo " checking that it still runs..." >>$LOG -kill -CHLD $PID >/dev/null 2>&1 || exit 1 +kill -CHLD $PID >/dev/null 2>&1 echo " connecting again, with a delay..." >>$LOG -../api/testclient unix:socket utah 5 >>$LOG -sleep 1 # let the client connect +../api/testclient -d 5 unix:socket utah >>$LOG & +CLIENT_PID=$! +sleep 1 # let the client connect echo " killing it..." >>$LOG kill $PID sleep 1 echo " checking that it is dead..." >>$LOG -kill -CHLD $PID >/dev/null 2>&1 && sleep 1 && \ -kill -CHLD $PID >/dev/null 2>&1 && exit 1 - +if kill -CHLD $PID >/dev/null 2>&1; then + sleep 1 + if kill -CHLD $PID >/dev/null 2>&1; then + exit 1 + fi +fi # clean up -rm -rf reg z.pid +rm -rf reg diff --git a/test/gils/test1.sh b/test/gils/test1.sh index 0c7ad8d0..0bd1aa83 100755 --- a/test/gils/test1.sh +++ b/test/gils/test1.sh @@ -1,67 +1,48 @@ #!/bin/sh +set -e srcdir=${srcdir:-"."} - if [ "$srcdir" != "." ] then echo "Jumping over test" exit 0 fi - LOG=test1.log - rm -f $LOG echo "initializing..." >>$LOG test -d reg || mkdir reg # these should not be here, will be created later $srcdir/cleanrecords.sh -#if [ -f $srcdir/records/esdd0001.grs ] -# then -# rm -f $srcdir/records/esdd0001.grs -#fi -#if [ -f $srcdir/records/esdd0002.grs ] -# then -# rm -f $srcdir/records/esdd0002.grs -#fi -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init echo "updating..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update $srcdir/records echo "starting server..." >>$LOG ../../index/zebrasrv -D -p z.pid -S -c $srcdir/zebra1.cfg -l $LOG unix:socket echo "checking it runs..." >>$LOG -test -f z.pid || exit 1 +test -f z.pid +. "$srcdir/cleanup.sh" echo "search 1..." >>$LOG -../api/testclient unix:socket utah > log || exit 1 -grep "^Result count: 17$" log >/dev/null || exit 1 +../api/testclient -c 17 unix:socket utah >> $LOG echo "search 2..." >>$LOG -../api/testclient unix:socket "@or utah the" > log || exit 1 -grep "^Result count: 41$" log >/dev/null || exit 1 +../api/testclient -c 41 unix:socket "@or utah the" >> $LOG echo "search 3..." >>$LOG -../api/testclient unix:socket "@attr 1=4 the" > log || exit 1 -grep "^Result count: 1$" log >/dev/null || exit 1 +../api/testclient -c 1 unix:socket "@attr 1=4 the" >> $LOG echo "search 4..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 9$" log >/dev/null || exit 1 +../api/testclient -c 9 unix:socket "@attr 1=4 utah" >> $LOG echo "reindexing..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update $srcdir/records echo "search 5..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 18$" log >/dev/null || exit 1 - -echo "stopping server..." >>$LOG -test -f z.pid || exit 1 -kill `cat z.pid` || exit 1 -rm -f z.pid +../api/testclient -c 18 unix:socket "@attr 1=4 utah" >> $LOG diff --git a/test/gils/test2.sh b/test/gils/test2.sh index 2b57e2ea..607b7843 100755 --- a/test/gils/test2.sh +++ b/test/gils/test2.sh @@ -1,7 +1,7 @@ #!/bin/sh +set -e srcdir=${srcdir:-"."} - if [ "$srcdir" != "." ] then echo "Jumping over test" @@ -9,66 +9,58 @@ if [ "$srcdir" != "." ] fi LOG=test2.log - rm -f $LOG echo "init..." >>$LOG # these should not be here, will be created later $srcdir/cleanrecords.sh -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg init || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg init echo "update 1..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo "update 2..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 - -echo "killing old server (if any)..." >>$LOG -test -f z.pid && kill -9 `cat z.pid` +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo "starting server..." >>$LOG ../../index/zebrasrv -D -p z.pid -S -c $srcdir/zebra2.cfg -l $LOG unix:socket -test -f z.pid || exit 1 +test -f z.pid +. "$srcdir/cleanup.sh" echo "search 1..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 9$" log >/dev/null || exit 1 +../api/testclient -c 9 unix:socket "@attr 1=4 utah" >> $LOG echo "update 3..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo "search 2..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 9$" log >/dev/null || exit 1 +../api/testclient -c 9 unix:socket "@attr 1=4 utah" >> $LOG echo "making test records..." >>$LOG cp $srcdir/records/esdd0006.grs $srcdir/records/esdd0001.grs echo "indexing them..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo "search 3..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 10$" log >/dev/null || exit 1 +../api/testclient -c 10 unix:socket "@attr 1=4 utah" >> $LOG touch $srcdir/records/esdd0001.grs echo "indexing again..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo "search 4..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 10$" log >/dev/null || exit 1 +../api/testclient -c 10 unix:socket "@attr 1=4 utah" >> $LOG echo "making another test record..." >>$LOG mv $srcdir/records/esdd0001.grs $srcdir/records/esdd0002.grs echo "indexing it too..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo "search 5..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 10$" log >/dev/null || exit 1 +../api/testclient -c 10 unix:socket "@attr 1=4 utah" >> $LOG sleep 1 echo "modifying a test record..." >>$LOG @@ -76,20 +68,10 @@ sed 's/UTAH/XYZ/g' <$srcdir/records/esdd0002.grs >$srcdir/records/esdd0002x.grs mv $srcdir/records/esdd0002x.grs $srcdir/records/esdd0002.grs echo "indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 -sleep 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo "search 6..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 9$" log >/dev/null || exit 1 +../api/testclient -c 9 unix:socket "@attr 1=4 utah" >> $LOG echo "search 7..." >>$LOG -../api/testclient unix:socket "@attr 1=4 xyz" > log || exit 1 -grep "^Result count: 1$" log >/dev/null || exit 1 - -echo "stosrcdiring server..." >>$LOG -test -f z.pid || exit 1 -kill `cat z.pid` || exit 1 -rm -f log -$srcdir/cleanrecords.sh -rm -f z.pid +../api/testclient -c 1 unix:socket "@attr 1=4 xyz" >> $LOG diff --git a/test/gils/test3.sh b/test/gils/test3.sh index 7c555a20..2ab1b4f7 100755 --- a/test/gils/test3.sh +++ b/test/gils/test3.sh @@ -3,17 +3,16 @@ # Testing searches with lots of @and operators # in order to test the fast-forward operation of rsets +set -e srcdir=${srcdir:-"."} - if [ "$srcdir" != "." ] then echo "Jumping over test" exit 0 fi -LOG=test3.log DBG="-v 1647" - +LOG=test3.log rm -f $LOG # these should not be here, will be created later @@ -21,110 +20,99 @@ $srcdir/cleanrecords.sh echo "initializing..." >>$LOG mkdir -p reg -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg init echo "updating..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra1.cfg update $srcdir/records echo "starting server..." >>$LOG ../../index/zebrasrv -D -p z.pid -S -c $srcdir/zebra1.cfg $DBG -l $LOG unix:socket echo "checking it runs..." >>$LOG -test -f z.pid || exit 1 +test -f z.pid +. "$srcdir/cleanup.sh" echo "search A1..." >>$LOG -../api/testclient -c 17 unix:socket utah > log || exit 1 +../api/testclient -c 17 unix:socket utah >>$LOG echo "search A2..." >>$LOG -../api/testclient -c 31 unix:socket the > log || exit 1 +../api/testclient -c 31 unix:socket the >>$LOG echo "search A3..." >>$LOG -../api/testclient -c 4 unix:socket deposits > log || exit 1 - +../api/testclient -c 4 unix:socket deposits >>$LOG echo "search B1..." >>$LOG -../api/testclient -c 7 unix:socket "@and utah the" > log || exit 1 +../api/testclient -c 7 unix:socket "@and utah the" >>$LOG echo "search B2..." >>$LOG -../api/testclient -c 7 unix:socket "@and the utah" > log || exit 1 +../api/testclient -c 7 unix:socket "@and the utah" >>$LOG echo "search C1..." >>$LOG -../api/testclient -c 1 unix:socket "@and @and the utah epicenter" > log || exit 1 +../api/testclient -c 1 unix:socket "@and @and the utah epicenter" >>$LOG echo "search C2..." >>$LOG -../api/testclient -c 1 unix:socket "@and @and the epicenter utah" > log || exit 1 +../api/testclient -c 1 unix:socket "@and @and the epicenter utah" >>$LOG echo "search C3..." >>$LOG -../api/testclient -c 1 unix:socket "@and @and utah the epicenter" > log || exit 1 +../api/testclient -c 1 unix:socket "@and @and utah the epicenter" >>$LOG echo "search C4..." >>$LOG -../api/testclient -c 1 unix:socket "@and @and utah epicenter the" > log || exit 1 +../api/testclient -c 1 unix:socket "@and @and utah epicenter the" >>$LOG echo "search C5..." >>$LOG -../api/testclient -c 1 unix:socket "@and @and epicenter the utah" > log || exit 1 +../api/testclient -c 1 unix:socket "@and @and epicenter the utah" >>$LOG echo "search C6..." >>$LOG -../api/testclient -c 1 unix:socket "@and @and epicenter utah the" > log || exit 1 - +../api/testclient -c 1 unix:socket "@and @and epicenter utah the" >>$LOG echo "search D1..." >>$LOG -../api/testclient -c 30 unix:socket "@and the of " > log || exit 1 +../api/testclient -c 30 unix:socket "@and the of " >>$LOG echo "search D2..." >>$LOG -../api/testclient -c 30 unix:socket "@and of the" > log || exit 1 +../api/testclient -c 30 unix:socket "@and of the" >>$LOG echo "search D3..." >>$LOG -../api/testclient -c 30 unix:socket "@and @and the of of" > log || exit 1 +../api/testclient -c 30 unix:socket "@and @and the of of" >>$LOG echo "search D4..." >>$LOG -../api/testclient -c 30 unix:socket "@and @and of the the" > log || exit 1 +../api/testclient -c 30 unix:socket "@and @and of the the" >>$LOG echo "search D5..." >>$LOG -../api/testclient -c 30 unix:socket "@and @and @and the of of the" > log || exit 1 +../api/testclient -c 30 unix:socket "@and @and @and the of of the" >>$LOG echo "search D6..." >>$LOG -../api/testclient -c 15 unix:socket '@and @and in the data' > log || exit 1 +../api/testclient -c 15 unix:socket '@and @and in the data' >>$LOG echo "search D7..." >>$LOG -../api/testclient -c 15 unix:socket '@and @and in data the' > log || exit 1 +../api/testclient -c 15 unix:socket '@and @and in data the' >>$LOG echo "search D8..." >>$LOG -../api/testclient -c 2 unix:socket "@attr 1=4 @and UNPUBLISHED @and REPORTS AND" >log || exit 1 +../api/testclient -c 2 unix:socket "@attr 1=4 @and UNPUBLISHED @and REPORTS AND" >log # This one failed at early fast-forwards echo "search E1..." >>$LOG -../api/testclient -c 41 unix:socket "@or the utah" > log || exit 1 +../api/testclient -c 41 unix:socket "@or the utah" >>$LOG echo "search E2..." >>$LOG -../api/testclient -c 41 unix:socket "@or utah the" > log || exit 1 +../api/testclient -c 41 unix:socket "@or utah the" >>$LOG echo "search E3..." >>$LOG -../api/testclient -c 42 unix:socket "@or deposits @or the utah" > log || exit 1 +../api/testclient -c 42 unix:socket "@or deposits @or the utah" >>$LOG echo "search E4..." >>$LOG -../api/testclient -c 3 unix:socket "@and deposits @or the utah" > log || exit 1 +../api/testclient -c 3 unix:socket "@and deposits @or the utah" >>$LOG echo "search E5..." >>$LOG -../api/testclient -c 3 unix:socket "@and @or the utah deposits" > log || exit 1 +../api/testclient -c 3 unix:socket "@and @or the utah deposits" >>$LOG echo "search F1..." >>$LOG -../api/testclient -c 24 unix:socket "@not the utah " > log || exit 1 +../api/testclient -c 24 unix:socket "@not the utah " >>$LOG echo "search F2..." >>$LOG -../api/testclient -c 10 unix:socket "@not utah the " > log || exit 1 +../api/testclient -c 10 unix:socket "@not utah the " >>$LOG echo "search F3..." >>$LOG -../api/testclient -c 1 unix:socket "@and deposits @not utah the " > log || exit 1 +../api/testclient -c 1 unix:socket "@and deposits @not utah the " >>$LOG echo "search F4..." >>$LOG -../api/testclient -c 1 unix:socket "@and @not utah the deposits" > log || exit 1 - - -echo "stopping server..." >>$LOG -test -f z.pid || exit 1 -kill `cat z.pid` || exit 1 -rm -f z.pid -sleep 1 - -echo "Test successfully completed" >>$LOG - +../api/testclient -c 1 unix:socket "@and @not utah the deposits" >>$LOG diff --git a/test/gils/timing1.sh b/test/gils/timing1.sh index bb01bf19..3d0aa7a7 100755 --- a/test/gils/timing1.sh +++ b/test/gils/timing1.sh @@ -1,8 +1,10 @@ #!/bin/sh -# tests that updates are reflected immediately # in the registers. +# Tests that updates are reflected immediately in the registers. # Repeatedly modifies a record and counts hits. -# Test 1: with good sleeps in every between - should pass always +# Zebra stores file mtimes in whole seconds. Sleep before each modification +# so its mtime advances; indexing and searching need no intervening sleeps. +set -e srcdir=${srcdir:-"."} if [ "$srcdir" != "." ] @@ -20,33 +22,28 @@ echo " init..." >>$LOG # these should not be here, will be created later $srcdir/cleanrecords.sh - -../../index/zebraidx -c $srcdir/zebra2.cfg -l $LOG init || exit 1 +../../index/zebraidx -c $srcdir/zebra2.cfg -l $LOG init echo " starting server..." >>$LOG ../../index/zebrasrv -D -p z.pid -S -c $srcdir/zebra2.cfg -l $LOG unix:socket -test -f z.pid || exit 1 -sleep 1 + +test -f z.pid +. "$srcdir/cleanup.sh" echo " update 1..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 -sleep 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo " search 1..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 9$" log >/dev/null || exit 1 -sleep 1 +../api/testclient -c 9 unix:socket "@attr 1=4 utah" >>$LOG echo "making a test record..." >>$LOG cp $srcdir/records/esdd0006.grs $srcdir/records/esdd0002.grs echo " indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 -sleep 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo " search 2..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 10$" log >/dev/null || exit 1 +../api/testclient -c 10 unix:socket "@attr 1=4 utah" >>$LOG sleep 1 echo " 1a: modifying a test record (xyz)..." >>$LOG @@ -54,13 +51,10 @@ sed 's/UTAH/XYZ/g' <$srcdir/records/esdd0002.grs >$srcdir/records/esdd0002x.grs mv $srcdir/records/esdd0002x.grs $srcdir/records/esdd0002.grs echo " indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records -sleep 1 echo " search 3..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -echo " checking..." >>$LOG -grep "^Result count: 9$" log >/dev/null || exit 1 +../api/testclient -c 9 unix:socket "@attr 1=4 utah" >>$LOG sleep 1 echo " 1b: modifying the test record back (utah)..." >>$LOG @@ -68,77 +62,7 @@ sed 's/XYZ/UTAH/g' <$srcdir/records/esdd0002.grs >$srcdir/records/esdd0002x.grs mv $srcdir/records/esdd0002x.grs $srcdir/records/esdd0002.grs echo " indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records -sleep 1 echo " search 4..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -echo " checking..." >>$LOG -grep "^Result count: 10$" log >/dev/null || exit 1 - -sleep 1 -echo " 2a: modifying the test record (xyz)..." >>$LOG -sed 's/UTAH/XYZ/g' <$srcdir/records/esdd0002.grs >$srcdir/records/esdd0002x.grs -mv $srcdir/records/esdd0002x.grs $srcdir/records/esdd0002.grs - -echo " indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 - -sleep 1 -echo " search 5..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -echo " checking..." >>$LOG -grep "^Result count: 9$" log >/dev/null || exit 1 - -sleep 1 -echo " 2b: modifying the test record back (utah)..." >>$LOG -sed 's/XYZ/UTAH/g' <$srcdir/records/esdd0002.grs >$srcdir/records/esdd0002x.grs -mv $srcdir/records/esdd0002x.grs $srcdir/records/esdd0002.grs - -sleep 1 -echo " indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 - -sleep 1 -echo " search 6..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -echo " checking..." >>$LOG -grep "^Result count: 10$" log >/dev/null || exit 1 - -sleep 1 - -echo " 3a: modifying the test record (xyz)..." >>$LOG -sed 's/UTAH/XYZ/g' <$srcdir/records/esdd0002.grs >$srcdir/records/esdd0002x.grs -mv $srcdir/records/esdd0002x.grs $srcdir/records/esdd0002.grs - -sleep 1 -echo " indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 - -sleep 1 -echo " search 7..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -echo " checking..." >>$LOG -grep "^Result count: 9$" log >/dev/null || exit 1 - -sleep 1 -echo " 3b: modifying the test record back (utah)..." >>$LOG -sed 's/XYZ/UTAH/g' <$srcdir/records/esdd0002.grs >$srcdir/records/esdd0002x.grs -mv $srcdir/records/esdd0002x.grs $srcdir/records/esdd0002.grs - -echo " indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 - -sleep 1 -echo " search 8..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -echo " checking..." >>$LOG -grep "^Result count: 10$" log >/dev/null || exit 1 - -echo "stopping server..." >>$LOG -test -f z.pid || exit 1 -kill `cat z.pid` || exit 1 -rm -f log -$srcdir/cleanrecords.sh -rm -f z.pid - +../api/testclient -c 10 unix:socket "@attr 1=4 utah" >>$LOG diff --git a/test/gils/timing2.sh b/test/gils/timing2.sh index 56e4b327..7807336e 100755 --- a/test/gils/timing2.sh +++ b/test/gils/timing2.sh @@ -1,8 +1,9 @@ #!/bin/sh -# Demonstrated that updates depend on file timestamps +# Demonstrates that updates depend on file timestamps. -srcdir=${srcdir:-"."} +set -e +srcdir=${srcdir:-"."} if [ "$srcdir" != "." ] then echo "Jumping over test" @@ -10,40 +11,40 @@ if [ "$srcdir" != "." ] fi LOG=timing2.log - rm -f $LOG echo " init..." >>$LOG -rm -f log timeref[12] +rm -f timeref[12] # these should not be here, will be created later $srcdir/cleanrecords.sh -../../index/zebraidx -c $srcdir/zebra2.cfg -l $LOG init || exit 1 +../../index/zebraidx -c $srcdir/zebra2.cfg -l $LOG init touch timeref1 # make an early timestamp echo " starting server..." >>$LOG ../../index/zebrasrv -D -p z.pid -S -c $srcdir/zebra2.cfg -l $LOG unix:socket -test -f z.pid || exit 1 +test -f z.pid +. "$srcdir/cleanup.sh" + +# Zebra stores file mtimes in whole seconds; separate the reference timestamps. sleep 1 touch timeref2 # make a later timestamp echo " update 1..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo " search 1..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 9$" log >/dev/null || exit 1 +../api/testclient -c 9 unix:socket "@attr 1=4 utah" >>$LOG echo "making a test record..." >>$LOG cp $srcdir/records/esdd0006.grs $srcdir/records/esdd0002.grs touch -r timeref1 $srcdir/records/esdd0002.grs echo " indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo " search 2..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -grep "^Result count: 10$" log >/dev/null || exit 1 +../api/testclient -c 10 unix:socket "@attr 1=4 utah" >>$LOG echo " modifying a test record (xyz)..." >>$LOG sed 's/UTAH/XYZ/g' <$srcdir/records/esdd0002.grs >$srcdir/records/esdd0002x.grs @@ -51,28 +52,18 @@ mv $srcdir/records/esdd0002x.grs $srcdir/records/esdd0002.grs touch -r timeref1 $srcdir/records/esdd0002.grs # reset timestamp to 'early' echo " not indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo " search 3..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -echo " checking..." >>$LOG -grep "^Result count: 10$" log >/dev/null || exit 1 +../api/testclient -c 10 unix:socket "@attr 1=4 utah" >>$LOG echo " touching its timestamp..." >>$LOG touch -r timeref2 $srcdir/records/esdd0002.grs # set timestamp to 'late' echo " indexing it..." >>$LOG -../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records || exit 1 +../../index/zebraidx -l $LOG -c $srcdir/zebra2.cfg update $srcdir/records echo " search 4..." >>$LOG -../api/testclient unix:socket "@attr 1=4 utah" > log || exit 1 -echo " checking..." >>$LOG -grep "^Result count: 9$" log >/dev/null || exit 1 - -echo "stopping server..." >>$LOG -test -f z.pid || exit 1 -kill `cat z.pid` || exit 1 -rm -f log timeref[12] -$srcdir/cleanrecords.sh -rm -f z.pid +../api/testclient -c 9 unix:socket "@attr 1=4 utah" >>$LOG +rm -f timeref[12]