3 # Regression test using pazpar2 against z3950.indexdata.com/marc or gils
4 # Reads Pazpar2 URLs from $1
5 # Outputs to $1_<no>.log
6 # Matches against results in $1_<no>.res
9 # srcdir might be set by make
12 # terminate pazpar2 if test takes more than this (in seconds)
17 if test -z "$SKIP_PAZPAR2" -a -n "$PP2PID"; then
22 if test -f ztest.pid; then
26 if test -n "$SLEEP_PID"; then
34 while test $# -gt 0; do
36 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
57 if test "x${PREFIX}" = "x"; then
58 echo Missing prefix for run_pazpar2.sh
63 if test ! -f ${srcdir}/${URLS}; then
64 echo "${srcdir}/${URLS} missing"
68 if test ! -f ${srcdir}/${CFG}; then
69 echo "${srcdir}/${CFG} missing"
73 # look for curl in PATH
78 if test -x $p/curl; then
85 if test -z $curl; then
86 echo "$PREFIX: curl not found"
90 if test "$icu" = "true"; then
91 if ../src/pazpar2 -V |grep icu:enabled >/dev/null; then
94 echo "Skipping ${PREFIX}: ICU support unavailable"
99 if test "$ztest" = "true" ; then
100 YAZ_ZTEST_XML_FETCH=${srcdir}/${PREFIX}.
101 export YAZ_ZTEST_XML_FETCH
107 if test -x $p/yaz-ztest -a -x $p/yaz-client; then
108 VERSION=`$p/yaz-client -V 2>/dev/null|awk '{print $3;}'|awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
109 if test -n "$VERSION"; then
110 if test $VERSION -ge 4002052; then
117 if test -z "$F"; then
118 for p in ${srcdir}/../../yaz ${srcdir}/../../yaz-*; do
119 if test -x $p/ztest/yaz-ztest; then
120 VERSION=`$p/ztest/yaz-ztest -V 2>/dev/null|awk '{print $3;}'|awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
121 if test -n "$VERSION"; then
122 if test "$VERSION" -ge 4002052; then
131 if test -z "$F"; then
132 echo "Skipping ${PREFIX}: recent yaz-ztest not found"
136 rm -f ${PREFIX}_ztest.log
137 $F -l ${PREFIX}_ztest.log -p ztest.pid -D tcp:localhost:9999
139 if test ! -f ztest.pid; then
140 echo "yaz-ztest could not be started"
145 # remove log if starting pazpar2
146 if [ -z "$SKIP_PAZPAR2" ] ; then
147 rm -f ${PREFIX}_pazpar2.log
150 VALGRINDLOG=${PREFIX}_valgrind.log
152 if test `uname` = "Linux"; then
159 LEVELS=loglevel,fatal,warn,log,debug,zoom,zoomdetails
160 if test "$PERF_PROG"; then
161 eval $PERF_PROG ../src/pazpar2 -p pazpar2.pid -X -l ${PREFIX}_pazpar2.log -f ${srcdir}/${CFG} >${PREFIX}_extra_pazpar2.log 2>&1 &
164 if test -f pazpar2.pid; then
165 PP2PID=`cat pazpar2.pid`
166 echo "Got PID $PP2PID"
168 elif test -n "$PAZPAR2_USE_VALGRIND"; then
169 valgrind --num-callers=30 --show-reachable=yes --leak-check=full --log-file=$VALGRINDLOG ../src/pazpar2 -v $LEVELS -X -l ${PREFIX}_pazpar2.log -f ${CFG} >${PREFIX}_extra_pazpar2.log 2>&1 &
173 elif test -n "$SKIP_PAZPAR2"; then
174 echo "${PREFIX}: not starting Pazpar2 (should be running already)"
176 ../src/pazpar2 -v $LEVELS -d -X -l ${PREFIX}_pazpar2.log -f ${srcdir}/${CFG} >${PREFIX}_extra_pazpar2.log 2>&1 &
180 if [ -z "$SKIP_PAZPAR2" -a -z "$WAIT_PAZPAR2" ] ; then
181 if ps -p $PP2PID >/dev/null 2>&1; then
182 (sleep $WAIT; kill_pazpar2 >/dev/null) &
184 trap kill_pazpar2 INT
185 trap kill_pazpar2 HUP
187 echo "${PREFIX}: pazpar2 failed to start"
188 if test -f ztest.pid; then
196 GET='$curl --silent --output $OUT2 "$f"'
197 POST='$curl --silent --header "Content-Type: text/xml" --data-binary "@$postfile" --output $OUT2 "$f"'
199 # Set to success by default.. Will be set to non-zero in case of failure
202 # We can start test for real
204 # set rounds to "wait" because pazpar2 might not be ready
206 for f in `cat ${srcdir}/${URLS}`; do
207 if echo $f | grep '^http' >/dev/null; then
208 OUT1=${srcdir}/${PREFIX}_${testno}.res
209 OUT2=${PREFIX}_${testno}.log
210 DIFF=${PREFIX}_${testno}.dif
212 if [ -n "$DEBUG" ] ; then
213 echo "test $testno: $f"
215 while test $rounds -gt 0; do
216 if test -n "${postfile}"; then
221 if test ! -f $OUT2; then
224 rounds=`expr $rounds - 1`
225 if test -f $OUT1 -a -z "$PAZPAR2_OVERRIDE_TEST"; then
226 if diff $OUT1 $OUT2 >$DIFF 2>/dev/null; then
231 if test $rounds -eq 0; then
232 echo "${PREFIX} $testno: Failed. See $OUT1, $OUT2 and $DIFF"
238 if test $testno -eq 1 -o $rounds -eq 0; then
239 echo "${PREFIX} $testno: Making for the first time"
245 if test $rounds -gt 0; then
249 testno=`expr $testno + 1`
252 elif echo $f | grep '^w' >/dev/null; then
254 elif echo $f | grep '^[0-9]' >/dev/null; then
258 if test -f $srcdir/$f; then
261 echo "File $f does not exist"
265 if [ -z "$SKIP_PAZPAR2" ] ; then
266 if ps -p $PP2PID >/dev/null 2>&1; then
270 if test -n "$SLEEP_PID"; then
271 echo "${PREFIX} $testno: pazpar2 terminated (timeout, probably)"
273 echo "${PREFIX} $testno: pazpar2 died"
282 if [ "$WAIT_PAZPAR2" ] ; then
284 while test $i -lt $WAIT_PAZPAR2; do
293 if test "$PERF_PROG"; then
294 tail -3 ${PREFIX}_extra_pazpar2.log