qa: update 660 to generate index.html, fixing pcp-testsuite runs
[pcp.git] / qa / 514
blob9d613cdd0536b8553317a0b36fad1f7191fffb18
1 #!/bin/sh
2 # PCP QA Test No. 514
4 # pmie - lots of expressions, checking pmie -d output and %v binding
5 # - see also QA 520
7 # Copyright (c) 2012 Ken McDonell. All Rights Reserved.
10 seq=`basename $0`
11 echo "QA output created by $seq"
13 # get standard filters
14 . ./common.product
15 . ./common.filter
16 . ./common.check
18 rm -f $seq.out
19 if [ $PCP_VER -lt 30702 ]
20 then
21 ln $seq.out.1 $seq.out || exit 1
22 else
23 if [ $PCP_VER -lt 30900 ]
24 then
25 ln $seq.out.2 $seq.out || exit 1
26 else
27 ln $seq.out.3 $seq.out || exit 1
31 status=1 # failure is the default!
32 $sudo rm -rf $tmp.* $seq.full
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
35 LOCALHOST=`hostname`
37 case $PCP_PLATFORM
39 irix|linux|solaris)
40 # same syslog options for Irix, Linux and OpenSolaris
41 SYSLOG_OPT='"-p daemon.info"'
43 darwin)
44 SYSLOG_OPT=''
47 echo "Arrgh ... need syslog option for $PCP_PLATFORM"
48 exit 1
50 esac
52 # may be using journalctl, and so no syslog in the file system
54 if `which journalctl >/dev/null 2>&1`
55 then
56 echo "Using journalctl ..." >>$seq.full
57 have_journalctl=true
58 else
59 have_journalctl=false
60 SYSLOG=''
61 for f in /var/adm/SYSLOG /var/log/daemon.log /var/log/messages /var/log/syslog /var/log/system.log
63 if [ -f $f ]
64 then
65 SYSLOG=$f
66 break
68 done
69 if [ -z "$SYSLOG" ]
70 then
71 echo "Arrgh! Cannot find your syslog file"
72 exit 1
76 _filter()
78 sed \
79 -e "s/\([:@ ]\)$LOCALHOST/\1LOCALHOST/g" \
80 -e "s/\([:@ ]\)local:/\1LOCALHOST/g" \
81 -e 's/[A-Z][a-z][a-z] [A-Z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/DATE/' \
82 -e 's/DATE [12][0-9][0-9][0-9]/DATE/' \
83 -e '/evaluator exiting/s/pmie([0-9][0-9]*)/pmie(PID)/' \
84 -e '/Performance Co-Pilot Inference Engine/s/Version .*/Version .../' \
85 -e 's/\[red] 1[0-9][0-9]/[red] >=100/' \
86 -e 's/\[green] 2[0-9][0-9]/[green] >=200/' \
87 -e 's/\[blue] 3[0-9][0-9]/[blue] >=300/'
90 _filter2()
92 $PCP_AWK_PROG '
93 $1 == "pmie:" { print; next }
94 /failed: / { print; next }
95 $1 == "initMetric:" { skip=1 }
96 skip == 1 { if ($1 == "Rule:") skip = 0 }
97 skip == 1 { next }
98 { print }' >$tmp.tmp
99 tr ' =' '\012' <$tmp.tmp \
100 | grep '0x' \
101 | $PCP_AWK_PROG >$tmp.sed '
102 BEGIN { n = 0 }
103 { if (seen[$1] == 1) next
104 printf "s/%s/ADDR%03d/\n",$1,n
106 seen[$1] = 1
108 sed -f $tmp.sed <$tmp.tmp
111 cat <<End-of-File >$tmp.pmie
112 some_inst sample.part_bin > 500 -> print "some > 500:" " [%i] %v";
113 all_inst sample.part_bin > 0 -> shell "echo 'all > 0:'" " [%i] %v";
114 some_sample hinv.ncpu @0..2 == hinv.ncpu -> syslog 10sec $SYSLOG_OPT "PCP QA $seq - please ignore: some sample ncpu equal" " [%i] %v";
115 ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "arith %v";
116 // true && true
117 sample.long.one != 2 && ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean1 %v";
118 // false && true
119 sample.long.one <= 0 && ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean2 %v";
120 // true && false
121 sample.long.one < 9 && ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean3 %v";
122 // false && false
123 sample.long.one < 1 && ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean4 %v";
124 // pmns error || true
125 min_inst no_such_metric == 100 || sample.long.million > 0 -> print "error1 %v";
126 // true || true
127 min_inst sample.part_bin == 100 || ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean5:" " [%i] %v";
128 // false || true
129 // NOTE instance bindings here will be for the _left_ subexpression
130 // (which is always false) ... this is odd but not unexpected
131 max_inst sample.part_bin == 100 || ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean6:" " [%i] %v";
132 // true || false
133 sum_inst sample.part_bin > 500 || ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean7:" " [%i] %v";
134 // false || false
135 avg_inst(sample.part_bin) == 0 || ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean8:" " [%i] %v";
136 count_inst(sample.part_bin > 0) > 0 -> print "count_inst:" "[%i] %v";
137 some_inst match_inst "bin-[12345]" sample.part_bin > 100 -> print "match_inst:" " [%i] %v";
138 some_inst nomatch_inst "bin-[12345]" sample.part_bin > 200 -> print "nomatch_inst:" " [%i] %v";
139 // rising, falling - see QA 515
140 all_inst rate sample.bin == 0 -> print "rate:" " [%i] %v";
141 66%_inst sample.colour >= 200 -> print "66%_inst:" " [%i] %v";
142 all_sample sample.long.ten @0..2 == 10 -> print "all_sample: " " [%i] %v";
143 60%_sample some_inst sample.part_bin #'bin-300' #'bin-500' #'bin-700' @0..1 >= 500 -> print "60%_sample: " " [%i] %v";
144 min_sample sample.long.hundred @0..1 == 100 -> print "min_sample: " " [%i] %v";
145 max_sample sample.long.hundred @0..1 == 100 -> print "max_sample: " " [%i] %v";
146 sum_sample sample.bin #'bin-100' @0..3 == 400 -> print "sum_sample: " " [%i] %v";
147 avg_sample sample.bin #'bin-200' @0..1 == 200 -> print "avg_sample: " " [%i] %v";
148 count_sample(some_inst sample.bin #'bin-200' #'bin-300' #'bin-400' @0..2 == 300) == 3 -> print "count_sample: " " [%i] %v";
149 min_inst sample.part_bin > 0 -> print "min_inst:" " @%h [%i] %v";
150 max_inst sample.part_bin > 0 -> print "max_inst:" " @%h [%i] %v";
151 sample.long.one == 1 -> shell "false" | print "false |: %v";
152 sample.long.ten == 10 -> shell "true" & print "true &: %v";
153 sample.long.hundred == 100 -> print "print |:" " %v" | print "bozo don't execute me!";
155 // TODO at some other time ... alarm and stomp actions
156 End-of-File
158 # real QA test starts here
159 cat <<End-of-File | pmie -t 250msec -d -Dappl1 >$tmp.out 2>$tmp.err &
160 f $tmp.pmie
162 r 1sec
164 End-of-File
166 wait
168 echo >>$seq.full
169 echo "pmie PID $!" >>$seq.full
170 echo >>$seq.full
171 echo "=== pmie output ===" >>$seq.full
172 cat $tmp.out >>$seq.full
173 echo >>$seq.full
174 echo "=== pmie errors ===" >>$seq.full
175 cat $tmp.err >>$seq.full
177 _filter2 <$tmp.err | _filter
178 _filter <$tmp.out
180 echo
181 echo "SYSLOG ..."
182 if $have_journalctl
183 then
184 # be careful ... --boot not supported in all versions, -l not
185 # supported in all versions
186 $sudo journalctl -b --full | tail -100 >$tmp.syslog
187 else
188 $sudo tail -100 $SYSLOG >$tmp.syslog
190 sed <$tmp.syslog -n \
191 -e 's/PCP QA '"$seq"'/PCP QA xxx/' \
192 -e '/ncpu equal/s/ [0-9][0-9]*/ N/g' \
193 -e 's/PCP QA xxx/PCP QA '"$seq"'/' \
194 -e '/\['$!']: PCP QA '"$seq"' - please ignore/{
195 s/.*please ignore/.../
197 }' \
198 | LC_COLLATE=POSIX sort -u
200 echo >>$seq.full
201 if $have_journalctl
202 then
203 echo "=== tail journalctl -b --full ===" >>$seq.full
204 else
205 echo "=== tail SYSLOG ($SYSLOG) ===" >>$seq.full
207 echo "`wc -l <$tmp.syslog | sed -e 's/ //g'` lines ... expect 100" >>$seq.full
208 cat $tmp.syslog >>$seq.full
210 # success, all done
211 status=0
212 exit