Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 661
blobf3cf5a183b13f56feb152da557faa3fe9c7f4196
1 #! /bin/sh
2 # PCP QA Test No. 661
3 # checks pmwebd graphite (web application) functionality
5 # Copyright (c) 2014-2016 Red Hat.
7 seq=`basename $0`
8 echo "QA output created by $seq"
10 . ./common.webapi
11 . ./common.python
13 test -d "$PCP_SHARE_DIR/webapps/graphite" || \
14 _notrun "graphite webapp is not installed"
15 test -d "$PCP_SHARE_DIR/webapps/blinkenlights" || \
16 _notrun "blinkenlights webapp is not installed"
17 which curl >/dev/null 2>&1 || _notrun "No curl binary installed"
18 $python -c "import json.tool" >/dev/null 2>&1
19 [ $? -eq 0 ] || _notrun "python import json.tool not installed"
21 $sudo rm -fr $tmp.dir
22 $sudo rm -f $tmp.*
23 rm -f $seq.full
25 signal=$PCP_BINADM_DIR/pmsignal
26 status=1 # failure is the default!
27 username=`id -u -n`
29 _cleanup()
31 $sudo rm -fr $tmp.dir
32 $sudo rm -f $tmp.*
33 [ -z "$pid" ] || kill $pid
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 webport=44339 # not 44323, so system pmwebd is unaffected by test case
38 webargs="-U $username -p $webport"
40 echo
41 echo "=== pmwebd graphite capabilities ===" | tee -a $seq.full
43 $PCP_BINADM_DIR/pmwebd $webargs -GX -R $PCP_SHARE_DIR/webapps -i 15 -A `pwd` -N -M8 -x/dev/tty -d1 -vvvvv -l $tmp.out &
44 pid=$!
45 _wait_for_pmwebd_logfile $tmp.out $webport
47 echo "crashers"
48 # TODO: telnet-probe hanging in read(2) here:
49 #echo "GET HTTP/1.0
50 # | $PCP_BINADM_DIR/telnet-probe localhost $webport
51 #echo "GET HTTP/1.0
52 # | $PCP_BINADM_DIR/telnet-probe localhost $webport
54 _filter_curl_i()
56 tr -d '\r' | # drop ^M from httpd results
57 sed -e 's,^Date:.*$,Date: XXX,' |
58 grep -v 'Connection:.*Alive' # some microhttpd versions add this
61 echo "the catalog"
62 curl -s -i "http://localhost:$webport/?zoo=goo&phantasm" | _filter_curl_i
63 curl -s -i "http://localhost:$webport/blinkenlights" | _filter_curl_i
64 curl -s -i "http://localhost:$webport/blinkenlights/" | _filter_curl_i
65 curl -s -S "http://localhost:$webport/graphite/index.html?foo=bar&ectoplasm=egon"
67 echo
68 echo "metric name breakage"
69 curl -s -S "http://localhost:$webport/graphite/render?format=json&target=.." | _webapi_json_pretty
70 curl --compressed -s -S "http://localhost:$webport/graphite/render?format=json&target=foo-XX-bar" | _webapi_json_pretty
72 echo
73 echo "metric tree iteration"
74 curl -s -S "http://localhost:$webport/graphite/metrics/find?query=archives*naslog*.*" | _webapi_json_pretty
75 curl --compressed -s -S "http://localhost:$webport/graphite/metrics/find?format=completer&query=archives*naslog*.*" | _webapi_json_pretty
76 curl -s -S "http://localhost:$webport/graphite/metrics/find?format=completer&query=archives*naslog*.k*." | _webapi_json_pretty
77 curl --compressed -s -S "http://localhost:$webport/graphite/metrics/find?format=completer&query=archives*naslog*.k*.all" | _webapi_json_pretty
78 curl -s -S "http://localhost:$webport/graphite/metrics/find?format=completer&query=archives*naslog*.k*.all." | _webapi_json_pretty
80 echo
81 echo "metric regex grep 1"
82 curl --compressed -s -S "http://localhost:$webport/graphite/graphlot/findmetric?q=.*960624.*disk.*dks131.*"
83 echo
84 echo "metric regex grep 2"
85 curl -s -S "http://localhost:$webport/graphite/browser/search?query=2014+hinv+n.*"
86 echo # not \n terminated
88 echo
89 echo "metric value dump 1"
90 curl -s -S "http://localhost:$webport/graphite/render?format=json&target=*/node_archive.proc.psinfo.pid.*&from=15:50_20131127&until=1385585880&maxDataPoints=100" | _webapi_json_pretty
91 echo
92 echo "metric value dump 2"
93 curl --compressed -s -S "http://localhost:$webport/graphite/rawdata?target=*/node_archive.proc.psinfo.pid.*&from=00:00_20131127&until=00:00_20131129&maxDataPoints=300" | _webapi_json_pretty
95 echo
96 echo compressed archive, expect non-empty result
97 curl -s -S "http://localhost:$webport/graphite/rawdata?target=*20130706.kernel.all.nprocs&from=00:00_20130705&until=23:59_20130705" | _webapi_json_pretty
99 echo
100 echo "metric gfx rendering"
101 curl -s -S "http://localhost:$webport/graphite/render?width=999&height=999&hideLegend=false&bgcolor=%23FF0&title=hello&format=png&target=*-chartqa1-2E-meta.sample.*byte*&target=*-chartqa1-2E-meta.*NOSUCH*&target=*-chartqa1-2E-meta.sample.dodgey.value.NOSUCH&from=22:31_20071010&until=22:36_20071010" > $tmp.png
102 _webapi_img_pretty $tmp.png
103 curl -s -S "http://localhost:$webport/graphite/render?width=999&height=999&target=*archive*20150417*.proc.nprocs&from=09:30_20150417&until=23:00_20150417" > $tmp.png
104 _webapi_img_pretty $tmp.png
105 # until=now should trigger redirect
106 curl --compressed -s -S "http://localhost:$webport/graphite/render?width=999&height=999&target=*archive*20150417*.proc.nprocs&from=09:30_20150417&until=now" > $tmp.png
107 if [ -s $tmp.png ]; then
108 echo unexpected png
109 _webapi_img_pretty $tmp.png
110 else
111 echo expected empty/absent png
113 curl -L -s -S "http://localhost:$webport/graphite/render?width=999&height=999&target=*archive*20150417*.proc.nprocs&from=09:30_20150417&until=now" > $tmp.png
114 _webapi_img_pretty $tmp.png
116 # tidy up
117 cat $tmp.out >> $seq.full
119 # Run one more test but without -X mode
121 kill $pid
122 sleep 3
123 $PCP_BINADM_DIR/pmwebd $webargs -G -R $PCP_SHARE_DIR/webapps -I -i 15 -A `pwd` -N -M8 -x/dev/tty -d1 -vvvvv -l $tmp.out &
124 pid=$!
125 _wait_for_pmwebd_logfile $tmp.out $webport
127 echo
128 echo "metric value dump 1 without -X"
129 curl -s -S "http://localhost:$webport/graphite/render?format=json&target=*node_archive*.proc.psinfo.pid.*&from=15:50_20131127&until=1385585880&maxDataPoints=100" | _webapi_json_pretty
131 status=0
132 exit