Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 662
blob08940fe96302f1404d12ec61be144675664426aa
1 #! /bin/sh
2 # PCP QA Test No. 662
3 # checks pmwebd functionality using python test script
5 # Copyright (c) 2013-2015 Red Hat, Inc. All Rights Reserved.
7 seq=`basename $0`
8 echo "QA output created by $seq"
10 . ./common.webapi
11 . ./common.python
13 _check_pmwebd
14 _check_requests_json
16 $sudo rm -f $tmp.* $seq.full
18 pyscript=src/test_webapi.py
19 signal=$PCP_BINADM_DIR/pmsignal
20 status=1 # failure is the default!
21 username=`id -u -n`
23 webargs="-U $username -P"
24 webport=`_find_free_port`
25 webpid=""
27 _cleanup()
29 if [ "X$webpid" != "X" ]; then
30 $signal -s TERM $webpid
31 webpid=""
33 $sudo rm -f $tmp.*
36 trap "_cleanup; exit \$status" 0 1 2 3 15
38 $PCP_BINADM_DIR/pmwebd $webargs -p $webport -l $tmp.out -v -t5 &
39 webpid=$!
40 echo "pid=$webpid" >>$seq.full
41 echo "webport=$webport" >>$seq.full
42 echo "webargs=$webargs" >>$seq.full
44 _wait_for_pmwebd_logfile $tmp.out $webport
46 # prepare the expected output file based on detected mode
47 rm -f $seq.out
48 if grep -q IPv6 $tmp.out; then
49 grep -q IPv4 $tmp.out || _notrun "QA host running in IPv6 mode only"
50 ln $seq.out.46 $seq.out # ipv6 + ipv4
51 else
52 ln $seq.out.4 $seq.out # ipv4 only
55 ipv6local=`_ipv6_localhost`
56 echo "ipv6local=$ipv6local" >>$seq.full
57 if grep -q IPv4 $tmp.out; then
58 echo && echo === IPv4 pmwebd testing via python ===
59 $python $pyscript --host localhost --port $webport | _webapi_response_filter
61 if grep -q IPv6 $tmp.out; then
62 echo && echo === IPv6 pmwebd testing via python ===
63 $python $pyscript --host $ipv6local --port $webport | _webapi_response_filter
66 echo >>$here/$seq.full
67 echo "=== pmwebd log ===" >>$here/$seq.full
68 cat $tmp.out >>$here/$seq.full
70 status=0
71 exit