3 # Reproduce https://github.com/performancecopilot/pcp/issues/14
5 # Copyright (c) 2015 Ken McDonell. All Rights Reserved.
9 echo "QA output created by $seq"
11 # get webapi glue (includes standard environment, filters and checks)
14 which curl
>/dev
/null
2>&1 || _notrun
"No curl binary installed"
15 [ -f ${PCP_BINADM_DIR}/pmwebd
] || _notrun
"pmwebd package not installed"
20 $sudo $PCP_RC_DIR/pmwebd stop
>>$here/$seq.full
2>&1
21 $sudo $PCP_RC_DIR/pcp start
>>$here/$seq.full
2>&1
27 status
=1 # failure is the default!
28 $sudo rm -rf $tmp $tmp.
* $seq.full
29 trap "_cleanup; exit \$status" 0 1 2 3 15
33 echo "$1 curl ..." >>$here/$seq.full
34 echo "<stdout>" >>$here/$seq.full
35 ( cat $tmp.out
; echo ) >>$here/$seq.full
36 echo "<stderr>" >>$here/$seq.full
37 ( cat $tmp.err
; echo ) >>$here/$seq.full
42 # get a pmapi context reference from pmwebd
44 curl
-s http
://localhost
:44323/pmapi
/context?hostspec
=localhost
>$tmp.out
2>$tmp.err
46 # get context from a line like in $tmp.out
47 # { "context": 2062287553 }
48 ( cat $tmp.out
; echo ) |
$PCP_AWK_PROG '$2 == "\"context\":" { print $3 }'
53 # fetch metrics from context $1
55 curl
-s http
://localhost
:44323/pmapi
/"$1"/_metric?prefix
=sample.long
>$tmp.out
2>$tmp.err
57 # metrics are in lines like ...
58 # {"name":"sample.long.one","text-oneline":"1 as a 32-bit integer","text-help":"1 as a 32-bit integer","pmid":121634826,"sem":"instant","units":"","type":"32"},
59 ( cat $tmp.out
; echo ) \
60 |
grep '^{"name":' $tmp.out |
sed -e 's/"text-help".*/.../' >$tmp.metrics
61 if [ -s $tmp.metrics
]
63 echo "Got these metrics ..."
66 echo "Failed to get metrics ..."
71 $sudo $PCP_RC_DIR/pmwebd stop
>>$here/$seq.full
2>&1
72 $sudo $PCP_RC_DIR/pmwebd start
73 _wait_for_pmwebd
44323
75 # real QA test starts here
77 echo "ctx1=$ctx1" >>$here/$seq.full
80 echo "Arrg, failed to get context number from ..."
84 echo "Got first context number."
88 echo "Killing off pmcd ..."
89 $sudo $PCP_RC_DIR/pmcd stop
2>&1 | _filter_pcp_stop
91 echo "Retrying first context ..."
95 echo "ctx2=$ctx2" >>$here/$seq.full
98 echo "Warning: got second context number from ..."
100 # ok, even though this is wrong (although it used to be that way),
101 # let's try and get some metrics ...
105 echo "No context number, as expected."
109 echo "Restarting pmcd ..."
110 $sudo $PCP_RC_DIR/pmcd start
2>&1 | _filter_pcp_stop
114 echo "ctx3=$ctx3" >>$here/$seq.full
117 echo "Arrg, failed to get context number from ..."
121 echo "Got third context number."
124 echo "Retrying first context ..."