Merge branch 'master' of https://github.com/kmcdonell/pcp into kenj-merge
[pcp.git] / qa / 788
blob42bed26de1fe93c89b4f6ce6159a46ef0e8cbb95
1 #!/bin/sh
2 # PCP QA Test No. 788
3 # Exercise the Nginx PMDA Install/Remove.
5 # Copyright (c) 2015-2016 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 [ -f $PCP_PMDAS_DIR/nginx/pmdanginx.pl ] || _notrun "nginx pmda not installed"
18 perl -e "use PCP::PMDA" >/dev/null 2>&1
19 [ $? -eq 0 ] || _notrun "perl PCP::PMDA module not installed"
21 status=1 # failure is the default!
22 $sudo rm -rf $tmp.* $seq.full
23 trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
25 # real QA test starts here
26 _filter_nginx()
28 # cull message resulting from no running nginx daemon
29 grep -v 'Information not currently available'
32 pmdanginx_remove()
34 echo
35 echo "=== remove nginx agent ==="
36 $sudo ./Remove >$tmp.out 2>&1
37 _filter_pmda_remove <$tmp.out
40 pmdanginx_install()
42 # start from known starting points
43 cd $PCP_PMDAS_DIR/nginx
44 $sudo ./Remove >/dev/null 2>&1
46 echo
47 echo "=== nginx agent installation ==="
48 $sudo ./Install </dev/null >$tmp.out 2>&1
49 cat $tmp.out >>$here/$seq.full
50 # Check nginx metrics have appeared ... X metrics and Y values
51 _filter_pmda_install <$tmp.out \
52 | sed \
53 -e 's/[0-9][0-9]* warnings, //' \
54 | $PCP_AWK_PROG '
55 /Check nginx metrics have appeared/ { if ($7 >= 7) $7 = "X"
56 if ($10 >= 7 || $10 == 0) $10 = "Y"
58 { print }'
61 _prepare_pmda nginx
62 # note: _restore_auto_restart pmcd done in _cleanup_pmda()
63 trap "_cleanup_pmda nginx; exit \$status" 0 1 2 3 15
65 _stop_auto_restart pmcd
67 # real QA test starts here
68 pmdanginx_install
70 # there may be a race if the pmda has a bit of a slow start ... pause
71 pmsleep 0.25
73 # pmcd should have been started by the Install process - check
74 if pminfo -v nginx > $tmp.info 2> $tmp.err
75 then
77 else
78 echo "... failed! ... here is the Install log ..."
79 cat $tmp.out
81 cat $tmp.info $tmp.err | _filter_nginx
83 pmdanginx_remove
84 status=0
85 exit