table of contents
YAZ-ZTEST(8) | System management commands | YAZ-ZTEST(8) |
NAME¶
yaz-ztest - Z39.50/SRU Test Server
SYNOPSIS¶
application [-install] [-installa] [-remove] [-a file] [-v level] [-l file] [-u uid] [-c config] [-f vconfig] [-C fname] [-t minutes] [-k kilobytes] [-K] [-d daemon] [-w dir] [-p pidfile] [-r kilobytes] [-ziDSTV1] [listener-spec...]
DESCRIPTION¶
yaz-ztest is a Z39.50/SRU test server that uses the YAZ generic front-end server (GFS) API. The server acts as a real Z39.50/SRU server but does not use a database. It returns a random hit count and returns a subset of a few built-in records.
The listener-spec consists of a transport mode followed by a colon, followed by a listener address. The transport mode is either tcp, unix, or ssl.
For TCP and SSL, an address has the form:
hostname | IP-number [ : portnumber ]
For UNIX local socket, the address is the filename of the local socket.
OPTIONS¶
-a file
-S
-1
-T
-s
-z
-l file
-c config
-f vconfig
-C fname
-v level
-u uid
-w dir
-p pidfile
-i
-D
-install
-installa
-remove
-t minutes
-k size
-K
-r size
-d daemon
-m time-format
-V
TESTING¶
yaz-ztest normally returns a random hit count between 0 and 24. However, if a query term includes leading digits, then the integer value of that term is used as hit count. This allows testers to return any number of hits. yaz-ztest includes 24 MARC records for testing. Hit counts exceeding 24 will make yaz-ztest return the same record batch over and over. So record at position 1, 25, 49, etc. are equivalent.
For XML, if no element set is given or element has value "marcxml", MARCXML is returned (each of the 24 dummy records converted from ISO2709 to XML). For element set OP, then OPAC XML is returned.
yaz-ztest may also return predefined XML records (for testing). This is enabled if YAZ_ZTEST_XML_FETCH environment variable is defined. A record is fetched from a file (one record per file). The path for the filename is FE.d.xml where F is the YAZ_ZTEST_XML_FETCH value (possibly empty), E is element-set, d is record position (starting from 1).
The following databases are honored by yaz-ztest: Default, slow and db.* (all databases with prefix "db"). Any other database will make yaz-ztest return diagnostic 109: "Database unavailable".
Options for search may be included in the form or URL get arguments included as part of the Z39.50 database name. The following database options are present: search-delay, present-delay, fetch-delay and seed.
The former, delay type options, specify a fake delay (sleep) that yaz-ztest will perform when searching, presenting, fetching records respectively. The value of the delay may either be a fixed floating point value which specifies the delay in seconds. Alternatively the value may be given as two floating point numbers separated by colon, which will make yaz-ztest perform a random sleep between the first and second number.
The database parameter seed takes an integer as value. This will call srand with this integer to ensure that the random behavior can be re-played.
Suppose we want searches to take between 0.1 and 0.5 seconds and a fetch to take 0.2 second. To access test database Default we'd use: Default?search-delay=0.1:0.5&fetch-delay=0.2.
GFS CONFIGURATION AND VIRTUAL HOSTS¶
The Virtual hosts mechanism allows a YAZ front-end server to support multiple back-ends. A back-end is selected on the basis of the TCP/IP binding (port+listening address) and/or the virtual host.
A back-end can be configured to execute in a particular working directory. Or the YAZ front-end may perform CQL to RPN conversion, thus allowing traditional Z39.50 back-ends to be offered as a SRW/SRU service. SRW/SRU Explain information for a particular back-end may also be specified.
For the HTTP protocol, the virtual host is specified in the Host header. For the Z39.50 protocol, the virtual host is specified as in the Initialize Request in the OtherInfo, OID 1.2.840.10003.10.1000.81.1.
Note
Not all Z39.50 clients allow the VHOST information to be set. For those, the selection of the back-end must rely on the TCP/IP information alone (port and address).
The YAZ front-end server uses XML to describe the back-end configurations. Command-line option -f specifies filename of the XML configuration.
The configuration uses the root element yazgfs. This element includes a list of listen elements, followed by one or more server elements.
The listen describes listener (transport end point), such as TCP/IP, Unix file socket or SSL server. Content for a listener:
CDATA (required)
attribute id (optional)
Note
We expect more information to be added for the listen section in a future version, such as CERT file for SSL servers.
The server describes a server and the parameters for this server type. Content for a server:
attribute id (optional)
attribute listenref (optional)
element config (optional)
element directory (optional)
element host (optional)
element cql2rpn (optional)
element ccl2rpn (optional)
element stylesheet (optional)
element client_query_charset (optional)
element docpath (optional)
element explain (optional)
element maximumrecordsize (optional)
element retrievalinfo (optional)
The XML below configures a server that accepts connections from two ports, TCP/IP port 9900 and a local UNIX file socket. We name the TCP/IP server public and the other server internal.
<yazgfs>
<listen id="public">tcp:@:9900</listen>
<listen id="internal">unix:/var/tmp/socket</listen>
<server id="server1">
<host>server1.mydomain</host>
<directory>/var/www/s1</directory>
<config>config.cfg</config>
</server>
<server id="server2" listenref="public,internal">
<host>server2.mydomain</host>
<directory>/var/www/s2</directory>
<config>config.cfg</config>
<cql2rpn>../etc/pqf.properties</cql2rpn>
<explain xmlns="http://explain.z3950.org/dtd/2.0/">
<serverInfo>
<host>server2.mydomain</host>
<port>9900</port>
<database>a</database>
</serverInfo>
</explain>
</server>
<server id="server3" listenref="internal">
<directory>/var/www/s3</directory>
<config>config.cfg</config>
</server>
</yazgfs>
There are three configured backend servers. The first two servers, "server1" and "server2", can be reached by both listener addresses. "server1" is reached by all (two) since no listenref attribute is specified. "server2" is reached by the two listeners specified. In order to distinguish between the two, a virtual host has been specified for each server in the host elements.
For "server2" elements for CQL to RPN conversion is supported and explain information has been added (a short one here to keep the example small).
The third server, "server3" can only be reached via listener "internal".
FILES¶
yaz-<version>/ztest/yaz-ztest.c
yaz-<version>/include/yaz/backend.h
SEE ALSO¶
AUTHORS¶
Index Data
09/22/2024 | YAZ 5.34.2 |