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.
-# $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
Doxyfile
Makefile
src/Makefile
+ test/Makefile
doc/Makefile
doc/local.ent
doc/common/Makefile
-# $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 \
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
-/* $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.
*/
/*
- * $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>
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)
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)
+++ /dev/null
-<?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 $ -->
-<!-- Used by test_http.sh -->
-<server>
- <listen port="9763"/>
- <proxy host="localhost"/>
- <settings src="../etc/settings"/>
-
- <service>
- <metadata name="url" merge="unique"/>
- <metadata name="title" brief="yes" sortkey="skiparticle" merge="longest" rank="6"/>
- <metadata name="isbn"/>
- <metadata name="date" brief="yes" sortkey="numeric" type="year" merge="range"
- termlist="yes"/>
- <metadata name="author" brief="yes" termlist="yes" merge="longest" rank="2"/>
- <metadata name="subject" merge="unique" termlist="yes" rank="3"/>
- <metadata name="id"/>
- <metadata name="lccn" merge="unique"/>
- <metadata name="description" merge="longest" rank="3"/>
- </service>
-</server>
-
-<targetprofiles type="local" src="../zeerex/records/"/>
-
-</pazpar2>
+++ /dev/null
-#!/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:
+++ /dev/null
-<settings target="localhost:9999/Default">
-
- <!-- Used by test test_http.sh -->
- <!-- $Id: test_http.xml,v 1.1 2007-05-15 08:56:03 adam Exp $ -->
-
- <set name="pz:name" value="Local Test"/>
-
- <!-- mapping for unqualified search -->
- <set name="pz:cclmap:term" value="u=1016 t=l,r s=al"/>
-
- <!-- field-specific mappings -->
- <set name="pz:cclmap:ti" value="u=4 s=al"/>
- <set name="pz:cclmap:su" value="u=21 s=al"/>
- <set name="pz:cclmap:isbn" value="u=7"/>
- <set name="pz:cclmap:issn" value="u=8"/>
- <set name="pz:cclmap:date" value="u=30 r=r"/>
-
- <!-- Retrieval settings -->
-
- <set name="pz:requestsyntax" value="marc21"/>
- <!-- <set name="pz:elements" value="F"/> NOT YET IMPLEMENTED -->
-
- <!-- Result normalization settings -->
-
- <set name="pz:nativesyntax" value="iso2709"/>
- <set name="pz:xslt" value="../etc/marc21.xsl"/>
-
-</settings>
--- /dev/null
+*.log
+*.dif
+Makefile
+Makefile.in
--- /dev/null
+# $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)
+
--- /dev/null
+<?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 15:50:48 adam Exp $ -->
+<!-- Used by test_http.sh -->
+<server>
+ <listen port="9763"/>
+ <proxy host="localhost"/>
+ <settings src="../etc/settings"/>
+
+ <service>
+ <metadata name="url" merge="unique"/>
+ <metadata name="title" brief="yes" sortkey="skiparticle" merge="longest" rank="6"/>
+ <metadata name="isbn"/>
+ <metadata name="date" brief="yes" sortkey="numeric" type="year" merge="range"
+ termlist="yes"/>
+ <metadata name="author" brief="yes" termlist="yes" merge="longest" rank="2"/>
+ <metadata name="subject" merge="unique" termlist="yes" rank="3"/>
+ <metadata name="id"/>
+ <metadata name="lccn" merge="unique"/>
+ <metadata name="description" merge="longest" rank="3"/>
+ </service>
+</server>
+
+<targetprofiles type="local" src="../zeerex/records/"/>
+
+</pazpar2>
--- /dev/null
+#!/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:
--- /dev/null
+<settings target="localhost:9764/Default">
+
+ <!-- Used by test test_http.sh -->
+ <!-- $Id: test_http.xml,v 1.1 2007-05-15 15:50:48 adam Exp $ -->
+
+ <set name="pz:name" value="Local Test"/>
+
+ <!-- mapping for unqualified search -->
+ <set name="pz:cclmap:term" value="u=1016 t=l,r s=al"/>
+
+ <!-- field-specific mappings -->
+ <set name="pz:cclmap:ti" value="u=4 s=al"/>
+ <set name="pz:cclmap:su" value="u=21 s=al"/>
+ <set name="pz:cclmap:isbn" value="u=7"/>
+ <set name="pz:cclmap:issn" value="u=8"/>
+ <set name="pz:cclmap:date" value="u=30 r=r"/>
+
+ <!-- Retrieval settings -->
+
+ <set name="pz:requestsyntax" value="marc21"/>
+ <!-- <set name="pz:elements" value="F"/> NOT YET IMPLEMENTED -->
+
+ <!-- Result normalization settings -->
+
+ <set name="pz:nativesyntax" value="iso2709"/>
+ <set name="pz:xslt" value="../etc/marc21.xsl"/>
+
+</settings>
--- /dev/null
+<init><status>OK</status><session>1</session><protocol>1</protocol></init>
\ No newline at end of file
--- /dev/null
+<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>
\ No newline at end of file
--- /dev/null
+<ping><status>OK</status></ping>
\ No newline at end of file
--- /dev/null
+<search><status>OK</status></search>
\ No newline at end of file
--- /dev/null
+<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 & 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>
--- /dev/null
+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