From 512fb20566662ab58b3dcd9ab1ba12df101238d5 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 15 May 2007 15:50:47 +0000 Subject: [PATCH] Regression test, test_http.sh, moved to sub directory test. The test makes a session, tries stat, search and show on a local yaz-ztest. Route make_sessionid modified to return deterministic session ID. If that is considered a problem an option or configuration must be added to Pazpar2 so this can be tuned. --- Makefile.am | 4 +-- configure.ac | 1 + src/Makefile.am | 8 ++--- src/http_command.c | 10 ++++-- src/test_http.cfg | 26 -------------- src/test_http.sh | 22 ------------ src/test_http.xml | 28 --------------- test/.cvsignore | 4 +++ test/Makefile.am | 15 ++++++++ test/test_http.cfg | 26 ++++++++++++++ test/test_http.sh | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_http.xml | 28 +++++++++++++++ test/test_http_1.res | 1 + test/test_http_2.res | 13 +++++++ test/test_http_3.res | 1 + test/test_http_4.res | 1 + test/test_http_5.res | 51 +++++++++++++++++++++++++++ test/test_http_urls | 5 +++ 18 files changed, 253 insertions(+), 87 deletions(-) delete mode 100644 src/test_http.cfg delete mode 100755 src/test_http.sh delete mode 100644 src/test_http.xml create mode 100644 test/.cvsignore create mode 100644 test/Makefile.am create mode 100644 test/test_http.cfg create mode 100755 test/test_http.sh create mode 100644 test/test_http.xml create mode 100644 test/test_http_1.res create mode 100644 test/test_http_2.res create mode 100644 test/test_http_3.res create mode 100644 test/test_http_4.res create mode 100644 test/test_http_5.res create mode 100644 test/test_http_urls diff --git a/Makefile.am b/Makefile.am index b183ff1..14c1e6c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,9 @@ -# $Id: Makefile.am,v 1.7 2007-04-10 08:48:55 adam Exp $ +# $Id: Makefile.am,v 1.8 2007-05-15 15:50:47 adam Exp $ AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = src doc +SUBDIRS = src test doc EXTRA_DIST = README NEWS LICENSE buildconf.sh Doxyfile.in m4/yaz.m4 diff --git a/configure.ac b/configure.ac index 2ba5b4a..57554c5 100644 --- a/configure.ac +++ b/configure.ac @@ -31,6 +31,7 @@ AC_CONFIG_FILES([ Doxyfile Makefile src/Makefile + test/Makefile doc/Makefile doc/local.ent doc/common/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 21f2e53..26867af 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.21 2007-05-15 08:56:03 adam Exp $ +# $Id: Makefile.am,v 1.22 2007-05-15 15:50:48 adam Exp $ bin_PROGRAMS = pazpar2 check_PROGRAMS = test_config \ @@ -8,11 +8,7 @@ check_PROGRAMS = test_config \ test_relevance \ test_sel_thread -check_SCRIPTS = test_http.sh - -EXTRA_DIST = test_http.xml test_http.cfg $(check_SCRIPTS) - -TESTS = $(check_PROGRAMS) $(check_SCRIPTS) +TESTS = $(check_PROGRAMS) noinst_LIBRARIES = libpazpar2.a diff --git a/src/http_command.c b/src/http_command.c index 35bed6b..879159d 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,4 +1,4 @@ -/* $Id: http_command.c,v 1.41 2007-04-23 21:05:23 adam Exp $ +/* $Id: http_command.c,v 1.42 2007-05-15 15:50:48 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -20,7 +20,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ /* - * $Id: http_command.c,v 1.41 2007-04-23 21:05:23 adam Exp $ + * $Id: http_command.c,v 1.42 2007-05-15 15:50:48 adam Exp $ */ #include @@ -119,9 +119,12 @@ static void error(struct http_response *rs, char *code, char *msg, char *txt) unsigned int make_sessionid() { + static int seq = 0; +#if 1 + return ++seq; +#else struct timeval t; unsigned int res; - static int seq = 0; seq++; if (gettimeofday(&t, 0) < 0) @@ -129,6 +132,7 @@ unsigned int make_sessionid() res = t.tv_sec; res = ((res << 8) | (seq & 0xff)) & ((1U << 31) - 1); return res; +#endif } static struct http_session *locate_session(struct http_request *rq, struct http_response *rs) diff --git a/src/test_http.cfg b/src/test_http.cfg deleted file mode 100644 index ec07815..0000000 --- a/src/test_http.cfg +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test_http.sh b/src/test_http.sh deleted file mode 100755 index ed76cc6..0000000 --- a/src/test_http.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# $Id: test_http.sh,v 1.1 2007-05-15 08:56:03 adam Exp $ -srcdir=${srcdir:-"."} -./pazpar2 -f ${srcdir}/test_http.cfg -t ${srcdir}/test_http.xml >test_http.log 2>&1 & -PP2PID=$! -sleep 1 -if ps -p $PP2PID >/dev/null 2>&1; then - : - # echo "Started OK PID=$PP2PID" -else - echo "pazpar2 failed to start" - exit 1 -fi - -kill $PP2PID -exit 0 - -# Local Variables: -# mode:shell-script -# sh-indentation: 2 -# sh-basic-offset: 4 -# End: diff --git a/src/test_http.xml b/src/test_http.xml deleted file mode 100644 index 5f5a905..0000000 --- a/src/test_http.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/.cvsignore b/test/.cvsignore new file mode 100644 index 0000000..cb6a995 --- /dev/null +++ b/test/.cvsignore @@ -0,0 +1,4 @@ +*.log +*.dif +Makefile +Makefile.in diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..abf372a --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,15 @@ +# $Id: Makefile.am,v 1.1 2007-05-15 15:50:48 adam Exp $ + +check_SCRIPTS = test_http.sh + +EXTRA_DIST = test_http.xml test_http.cfg test_http_urls $(check_SCRIPTS) + +TESTS = $(check_SCRIPTS) + +MAINTAINERCLEANFILES = Makefile.in + +CONFIG_CLEAN_FILES=*.log + +dist-hook: + cp test_http_*.res $(distdir) + diff --git a/test/test_http.cfg b/test/test_http.cfg new file mode 100644 index 0000000..483eb70 --- /dev/null +++ b/test/test_http.cfg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/test_http.sh b/test/test_http.sh new file mode 100755 index 0000000..b99971f --- /dev/null +++ b/test/test_http.sh @@ -0,0 +1,96 @@ +#!/bin/sh +# $Id: test_http.sh,v 1.1 2007-05-15 15:50:48 adam Exp $ +# +# Regression test using pazpar2 against yaz-ztest +# Reads Pazpar2 URLs from test_http_urls +# Outputs to test_http_.log +# Matches against results in test_htttp_.res +# + + +# srcdir might be set by make +srcdir=${srcdir:-"."} + +# Find a suitable yaz-ztest +yt="" +for d in /usr/bin /usr/local/bin ../../yaz/ztest; do + yt=${d}/yaz-ztest + if test -x ${yt}; then + break + fi +done +if test -z "${yt}"; then + echo "No yaz-ztest found. Skipping" + exit 0 +fi + +# Fire up yaz-ztest (should match port in test_http.xml) +$yt -l test_http_ztest.log tcp:@:9764 & +YTPID=$! + +# Fire yp pazpar2 +../src/pazpar2 -f ${srcdir}/test_http.cfg -t ${srcdir}/test_http.xml >test_http_pp2.log 2>&1 & +PP2PID=$! + +# Give both programs room to start properly.. +sleep 1 + +# Set to success by default.. Will be set to non-zero in case of failure +code=0 + +if ps -p $PP2PID >/dev/null 2>&1; then + : +else + code=1 + PP2PID="" + echo "pazpar2 failed to start" +fi + +if ps -p $YTPID >/dev/null 2>&1; then + : +else + code=1 + YTPID="" + echo "yaz-ztest failed to start" +fi +# We can start test for real + +testno=1 +for f in `cat ${srcdir}/test_http_urls`; do + OUT1=${srcdir}/test_http_${testno}.res + OUT2=${srcdir}/test_http_${testno}.log + DIFF=${srcdir}/test_http_${testno}.dif + if test -f $OUT1; then + rm -f $OUT2 + wget -q -O $OUT2 $f + if diff $OUT1 $OUT2 >$DIFF; then + echo "Test $testno: OK" + else + echo "Test $testno: Failed. See $OUT1, $OUT2 and $DIFF" + code=1 + fi + else + echo "Test $testno: Making for the first time" + wget -q -O $OUT1 $f + code=1 + fi + testno=`expr $testno + 1` +done + +sleep 1 +# Kill programs +if test -n "$YTPID"; then + kill $YTPID +fi + +if test -n "$PP2PID"; then + kill $PP2PID +fi + +exit $code + +# Local Variables: +# mode:shell-script +# sh-indentation: 2 +# sh-basic-offset: 4 +# End: diff --git a/test/test_http.xml b/test/test_http.xml new file mode 100644 index 0000000..a0f1089 --- /dev/null +++ b/test/test_http.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/test_http_1.res b/test/test_http_1.res new file mode 100644 index 0000000..ae5db74 --- /dev/null +++ b/test/test_http_1.res @@ -0,0 +1 @@ +OK11 \ No newline at end of file diff --git a/test/test_http_2.res b/test/test_http_2.res new file mode 100644 index 0000000..48f18ee --- /dev/null +++ b/test/test_http_2.res @@ -0,0 +1,13 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 + \ No newline at end of file diff --git a/test/test_http_3.res b/test/test_http_3.res new file mode 100644 index 0000000..792c56c --- /dev/null +++ b/test/test_http_3.res @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/test/test_http_4.res b/test/test_http_4.res new file mode 100644 index 0000000..d2e0e58 --- /dev/null +++ b/test/test_http_4.res @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/test/test_http_5.res b/test/test_http_5.res new file mode 100644 index 0000000..e9f1ea8 --- /dev/null +++ b/test/test_http_5.res @@ -0,0 +1,51 @@ + +OK +0 +6 +7 +0 +6 + + +How to program a computer +Jack Collins + +2 +0 + + + +The Computer Bible +1973-1980 +Freedman, David Noel +2 + + + +The Puget Sound Region : a portfolio of thematic computer maps +1974 +Hoerauf, Eugene A +3 + + + +Computer processing of dynamic images from an Anger scintillation camera : the proceedings of a workshop +1974 +Larson, Kenneth B +1 + + + +Computer science & technology : proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976 +1977 +Evans, John Martin +5 + + + +Reconstruction tomography in diagnostic radiology and nuclear medicine : proceedings of the workshop +1977 +Ter-Pogossian, Michel M +4 + + diff --git a/test/test_http_urls b/test/test_http_urls new file mode 100644 index 0000000..90eceae --- /dev/null +++ b/test/test_http_urls @@ -0,0 +1,5 @@ +http://localhost:9763/search.pz2?command=init +http://localhost:9763/search.pz2?session=1&command=stat +http://localhost:9763/search.pz2?session=1&command=ping +http://localhost:9763/search.pz2?session=1&command=search&query=computer +http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1 -- 1.7.10.4