qa: update 660 to generate index.html, fixing pcp-testsuite runs
[pcp.git] / qa / 1068
blobf10e89cae4f225fbcabae8fb7a4d25ff60b6d837
1 #!/bin/sh
2 # PCP QA Test No. 1068
3 # Exercise pmrep Zabbix export reporting modes.
5 # Copyright (c) 2015 Red Hat.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 which socat >/dev/null 2>&1 || _notrun "socat binary not installed"
17 which pmrep >/dev/null 2>&1 || _notrun "pmrep not installed"
19 status=1 # failure is the default!
20 signal=$PCP_BINADM_DIR/pmsignal
21 $sudo rm -rf $tmp $tmp.* $seq.full
22 trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
24 _seq_store()
26 echo "--- pmrep stdout --" >>$seq.full
27 cat $tmp.pmrep.out >>$seq.full
28 echo "--- pmrep stderr --" >>$seq.full
29 cat $tmp.pmrep.err >>$seq.full
30 echo "--- socat stdout --" >>$seq.full
31 cat $tmp.socat.out >>$seq.full
32 echo "--- socat stderr --" >>$seq.full
33 cat $tmp.socat.err >>$seq.full
36 _zbx_header()
38 output=$1
40 # extract the (partially binary) header, preceding the JSON response
41 # and make it into a deterministic string
42 sed -n 1p $output | \
43 sed -e 's/{//g' | \
44 od -c | \
45 sed -n 1p | \
46 sed -e 's/ D 001.*/ D/g'
49 zabbix_port=`_find_free_port`
50 log="-z --archive $here/archives/sample-secs"
52 # real QA test starts here
53 cat <<EOF >$tmp.config
54 [options]
55 zabbix_port = $zabbix_port
56 zabbix_host = HOSTNAME
57 zabbix_server = localhost
58 [globals]
59 secs = sample.seconds
60 msecs = sample.milliseconds
61 EOF
63 cat $tmp.config >>$seq.full
65 socat tcp-listen:$zabbix_port,reuseaddr - >$tmp.socat.out 2>$tmp.socat.err &
66 pid=$!
67 sleep 2
68 pmrep -t 2 -s 3 $log -c $tmp.config -o zabbix sample >$tmp.pmrep.out 2>$tmp.pmrep.err & # will error out after socket cat dies
69 pmpid=$!
70 sleep 2
71 $signal $pid $pmpid 2>/dev/null
72 wait
73 _seq_store
75 echo "== Zabbix server input ==="
76 # check the first line has the initial ZBXD preamble (before JSON)
77 header=`_zbx_header $tmp.socat.out`
78 echo "header: $header"
79 echo "body:"
80 echo '{' # ate this from the header
81 sed -n '1!p' $tmp.socat.out
82 echo #}
84 # success, all done
85 status=0
86 exit