0814bf0013feb4da4994ea7d2380f23b74ccdd82
[pazpar2-moved-to-github.git] / heikki / test1.sh
1 #!/bin/bash
2 #
3 # Simple script (and config) to get pz2 to run against yaz-ztest, and 
4 # calculate rankings. See how they differ for different queries
5 #
6 # (uses curl and xml-twig-tools)
7
8 if [ "$1" == "clean" ]
9 then
10   echo "Cleaning up"
11   rm -f $PIDFILE $YAZPIDFILE *.out *.log *~ 
12   exit
13 fi
14
15 CFG="test1.cfg"
16
17 PZ="../src/pazpar2"
18
19 PIDFILE=pz2.pid
20 YAZPIDFILE=yaz-ztest.pid
21
22 yaz-ztest -p $YAZPIDFILE -l yaz-ztest.log &
23
24 rm -f *.out *.log
25
26 $PZ -f $CFG  -l pz2.log -p $PIDFILE &
27 sleep 0.2 # make sure it has time to start
28 echo "Init"
29 curl -s "http://localhost:9017/?command=init" > init.out
30 SESSION=`xml_grep --text_only "//session" init.out `
31 # cat init.out; echo
32 echo "Got session $SESSION"
33 SES="&session=$SESSION"
34
35
36 QRY="query=computer"
37 #SEARCH="command=search$SES&$QRY&rank=1&sort=relevance"
38 #SEARCH="command=search$SES&$QRY"
39 SEARCH="command=search$SES&$QRY&sort=relevance"
40 echo $SEARCH
41 curl -s "http://localhost:9017/?$SEARCH" > search.out
42 cat search.out | grep search
43 echo
44
45 SHOW="command=show$SES&sort=relevance"
46 echo $SHOW
47 curl -s "http://localhost:9017/?$SHOW" > show.out
48 grep "relevance" show.out | grep += | grep -v "(0)"
49 echo
50
51 echo "All done"
52 kill `cat $PIDFILE`
53 kill `cat $YAZPIDFILE`
54 rm -f $PIDFILE $YAZPIDFILE
55