Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 512fb20566662ab58b3dcd9ab1ba12df101238d5 1 parent 6f08d24
@adamdickmeiss adamdickmeiss authored
View
4 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
View
1  configure.ac
@@ -31,6 +31,7 @@ AC_CONFIG_FILES([
Doxyfile
Makefile
src/Makefile
+ test/Makefile
doc/Makefile
doc/local.ent
doc/common/Makefile
View
8 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
View
10 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 <stdio.h>
@@ -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)
View
22 src/test_http.sh
@@ -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:
View
4 test/.cvsignore
@@ -0,0 +1,4 @@
+*.log
+*.dif
+Makefile
+Makefile.in
View
15 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)
+
View
2  src/test_http.cfg → test/test_http.cfg
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<pazpar2 xmlns="http://www.indexdata.com/pazpar2/1.0">
-<!-- $Id: test_http.cfg,v 1.1 2007-05-15 08:56:03 adam Exp $ -->
+<!-- $Id: test_http.cfg,v 1.1 2007-05-15 15:50:48 adam Exp $ -->
<!-- Used by test_http.sh -->
<server>
<listen port="9763"/>
View
96 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_<no>.log
+# Matches against results in test_htttp_<no>.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:
View
4 src/test_http.xml → test/test_http.xml
@@ -1,7 +1,7 @@
-<settings target="localhost:9999/Default">
+<settings target="localhost:9764/Default">
<!-- Used by test test_http.sh -->
- <!-- $Id: test_http.xml,v 1.1 2007-05-15 08:56:03 adam Exp $ -->
+ <!-- $Id: test_http.xml,v 1.1 2007-05-15 15:50:48 adam Exp $ -->
<set name="pz:name" value="Local Test"/>
View
1  test/test_http_1.res
@@ -0,0 +1 @@
+<init><status>OK</status><session>1</session><protocol>1</protocol></init>
View
13 test/test_http_2.res
@@ -0,0 +1,13 @@
+<stat><activeclients>0</activeclients>
+<hits>0</hits>
+<records>0</records>
+<clients>0</clients>
+<unconnected>0</unconnected>
+<connecting>0</connecting>
+<initializing>0</initializing>
+<searching>0</searching>
+<presenting>0</presenting>
+<idle>0</idle>
+<failed>0</failed>
+<error>0</error>
+</stat>
View
1  test/test_http_3.res
@@ -0,0 +1 @@
+<ping><status>OK</status></ping>
View
1  test/test_http_4.res
@@ -0,0 +1 @@
+<search><status>OK</status></search>
View
51 test/test_http_5.res
@@ -0,0 +1,51 @@
+<show>
+<status>OK</status>
+<activeclients>0</activeclients>
+<merged>6</merged>
+<total>7</total>
+<start>0</start>
+<num>6</num>
+<hit>
+
+<md-title>How to program a computer</md-title>
+<md-author>Jack Collins</md-author><location id="localhost:9764/Default" name="Local Test"></location>
+<location id="localhost:9764/Default" name="Local Test"></location>
+<count>2</count>
+<recid>0</recid>
+</hit>
+<hit>
+
+<md-title>The Computer Bible</md-title>
+<md-date>1973-1980</md-date>
+<md-author>Freedman, David Noel</md-author><location id="localhost:9764/Default" name="Local Test"></location>
+<recid>2</recid>
+</hit>
+<hit>
+
+<md-title>The Puget Sound Region : a portfolio of thematic computer maps</md-title>
+<md-date>1974</md-date>
+<md-author>Hoerauf, Eugene A</md-author><location id="localhost:9764/Default" name="Local Test"></location>
+<recid>3</recid>
+</hit>
+<hit>
+
+<md-title>Computer processing of dynamic images from an Anger scintillation camera : the proceedings of a workshop</md-title>
+<md-date>1974</md-date>
+<md-author>Larson, Kenneth B</md-author><location id="localhost:9764/Default" name="Local Test"></location>
+<recid>1</recid>
+</hit>
+<hit>
+
+<md-title>Computer science &amp; technology : proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title>
+<md-date>1977</md-date>
+<md-author>Evans, John Martin</md-author><location id="localhost:9764/Default" name="Local Test"></location>
+<recid>5</recid>
+</hit>
+<hit>
+
+<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine : proceedings of the workshop</md-title>
+<md-date>1977</md-date>
+<md-author>Ter-Pogossian, Michel M</md-author><location id="localhost:9764/Default" name="Local Test"></location>
+<recid>4</recid>
+</hit>
+</show>
View
5 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
Please sign in to comment.
Something went wrong with that request. Please try again.