Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 1033
blobc8ae842a5e5583ce98edbb22564ab3423ea6b35b
1 #!/bin/sh
2 # PCP QA Test No. 1033
3 # Exercise the named PMDA.
5 # Copyright (c) 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 [ -d "$PCP_PMDAS_DIR/named" ] || _notrun "named PMDA not installed"
17 perl -e "use PCP::PMDA" >/dev/null 2>&1
18 [ $? -eq 0 ] || _notrun "perl PCP::PMDA module not installed"
20 status=1 # failure is the default!
21 $sudo rm -rf $tmp $tmp.* $seq.full
23 _cleanup()
25 $sudo rm -f $here/named.log
26 rm -f $tmp.*
28 trap "_cleanup; exit \$status" 0 1 2 3 15
30 # PMNS order is non-deterministic
31 # Metric: named
32 # non-leaf nameserver <--- sort
33 # leaf interval <--- sort
34 # dbpmda> desc named.interval
36 _filter()
38 $PCP_AWK_PROG '
39 BEGIN { state = 0 }
40 state == 1 && $1 == "dbpmda>" { state = 2 }
41 { outname = "'$tmp'." state; print >outname }
42 $1 == "Metric:" { state = 1 }'
43 ( cat $tmp.0 ; LC_COLLATE=POSIX sort $tmp.1; cat $tmp.2 ) \
44 | sed \
45 -e "s;$PCP_PMDAS_DIR;\$PCP_PMDAS_DIR;" \
46 -e "s;$script;pmdanamed.pl;" \
47 -e '/Direct mapping for metrics disabled/d' \
48 | _filter_dumpresult
51 _filter_pmda_log()
53 sed \
54 -e 's/^\(Log for pmda[^ ]* on\) .*/\1 HOST .../' \
55 -e 's/^\(Log finished\) .*/\1 .../' \
56 -e '/^$/d' \
57 #end
61 # real QA test starts here
62 script=$PCP_PMDAS_DIR/named/pmdanamed.pl
64 # create a set of commands for dbpmda
65 cat >$tmp.cmds <<End-of-File
66 open pipe /usr/bin/env perl $script
67 children named
68 desc named.interval
69 fetch named.interval
70 End-of-File
72 export NAMED_STATS_USER=`id -u -n`
73 export NAMED_STATS_PROG=`which true`
75 # iterate over all of the pre-canned staticstics files
76 test="$here/named"
77 for file in $test/*.txt
79 export NAMED_STATS_FILE="$file"
80 PCP_PERL_PMNS=root /usr/bin/env perl $script > $tmp.root
82 echo === Test case: `basename $file`
83 $sudo rm -f named.log
84 dbpmda -n $tmp.root -ie < $tmp.cmds 2>&1 | _filter
85 _filter_pmda_log < named.log
86 done
88 # success, all done
89 status=0
90 exit