Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 256
blobe9b87916c6373ac1fbfa7a48b4ec9044495e3764
1 #!/bin/sh
2 # PCP QA Test No. 256
4 # Derived metrics and PMNS operations
6 # Copyright (c) 2009 Ken McDonell. All Rights Reserved.
9 seq=`basename $0`
10 echo "QA output created by $seq"
12 # get standard environment, filters and checks
13 . ./common.product
14 . ./common.filter
15 . ./common.check
17 # For this test, don't load any global derived metric configs by default.
18 # So the PCP_DERIVED_CONFIG environment variable is set to an empty string.
19 export PCP_DERIVED_CONFIG=""
21 status=0 # success is the default!
22 $sudo rm -rf $tmp.* $seq.full
23 trap "$sudo rm -f $tmp.*; exit \$status" 0 1 2 3 15
25 # Derived metric expr dump from 0x8513a48...
26 # expr node 0x867eb68 type=PLUS left=0x867eb98 right=0x867ed28
27 _filter()
29 cat $tmp.out >>$seq.full
30 awk <$tmp.out >$tmp.sed '
31 BEGIN { n = 0 }
32 $1 == "expr" && $2 == "node" && $3 ~ /^0x/ { print "s/" $3 "/<addr-" n ">/"; n++ }
33 { next }'
34 echo "=== sed ===" >>$seq.full
35 cat $tmp.sed >>$seq.full
36 echo "=== end sed ===" >>$seq.full
37 sed -f $tmp.sed <$tmp.out \
38 | sed \
39 -e '/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/s/[^ ]*.*numpmid/TIMESTAMP ... numpmid/' \
40 -e 's/=0x0 /=(nil) /g' \
41 -e "s;$tmp;TMP;"
42 # -e 's/ val=[0-9][0-9]*/ val=<number>/g'
45 # expr node <addr-6> type=NAME left=(nil) right=(nil) save_last=1 [sample.pdu] master=0
46 # ...
47 # [0] inst=-1, val=49794
48 _filter2()
50 sed <$tmp.out -e 's/val=/val /' \
51 | awk >$tmp.sed2 '
52 BEGIN { n = 0 }
53 /expr.*sample\./ { want=1; next }
54 want == 1 && $3 == "val" { if (seen[$4] != "y") {
55 print "s/ val=" $4 "$/ val=<value-" n ">/"
56 n++
57 seen[$4] = "y"
60 $1 == "expr" { want = 0 }'
61 echo "=== sed2 ===" >>$seq.full
62 cat $tmp.sed2 >>$seq.full
63 echo "=== end sed2 ===" >>$seq.full
64 sed -f $tmp.sed2 \
65 | sed \
66 -e '/pmGetChildren(name="")/s/ [0-9][0-9]* regular/ N regular/' \
67 -e '/pmGetChildren/s/returns [0-9][0-9]/returns N/'
70 # real QA test starts here
72 echo "HOST context ..." | tee -a $seq.full
73 cat <<End-of-File >$tmp.config
74 myname.one = sample.long.one
75 myname.suba.two = 2*sample.long.one
76 myname.suba.three = 3*sample.long.one
77 myname.suba.subb.four = 4*sample.long.one
78 myname.suba.subb.subc.subd.five = 5*sample.long.one
79 myname.suba.subb.subc.subd.six = 6*sample.long.one
80 End-of-File
81 echo | tee -a $seq.full
82 cat $tmp.config | tee -a $seq.full
84 for args in myname.suba.subb.subc.subd.six myname.suba.subb myname \
85 myname.one.bad myname.suba.subb.subc.bad
87 echo | tee -a $seq.full
88 echo "=== -h localhost $args ===" | tee -a $seq.full
89 pminfo -h localhost -c $tmp.config $args >$tmp.out 2>&1
90 _filter
91 echo "=== -h localhost -f $args ===" | tee -a $seq.full
92 pminfo -h localhost -c $tmp.config -f $args >$tmp.out 2>&1
93 _filter
94 done
96 echo | tee -a $seq.full
97 echo "ARCHIVE context ..." | tee -a $seq.full
98 cat <<End-of-File >$tmp.config
99 sample.one = sample.longlong.one
100 sample.suba.two = 2*sample.longlong.one
101 sample.suba.three = 3*sample.longlong.one
102 sample.suba.subb.four = 4*sample.longlong.one
103 sample.suba.subb.subc.subd.five = 5*sample.longlong.one
104 sample.suba.subb.subc.subd.six = 6*sample.longlong.one
105 End-of-File
106 echo | tee -a $seq.full
107 cat $tmp.config | tee -a $seq.full
109 for args in sample.suba.subb.subc.subd.six sample.suba.subb sample \
110 sample.one.bad sample.suba.subb.subc.bad
112 echo | tee -a $seq.full
113 echo "=== -a archives/reduce-1 $args ===" | tee -a $seq.full
114 pminfo -a archives/reduce-1 -c $tmp.config $args >$tmp.out 2>&1
115 _filter
116 echo "=== -a archives/reduce-1 -f $args ===" | tee -a $seq.full
117 pminfo -a archives/reduce-1 -c $tmp.config -f $args >$tmp.out 2>&1
118 _filter
119 done
121 echo | tee -a $seq.full
122 echo "LOCAL context ..." | tee -a $seq.full
123 cat <<End-of-File >$tmp.config
124 sampledso.one = sampledso.longlong.one
125 sampledso.suba.two = 2*sampledso.longlong.one
126 sampledso.suba.three = 3*sampledso.longlong.one
127 sampledso.suba.subb.four = 4*sampledso.longlong.one
128 sampledso.suba.subb.subc.subd.five = 5*sampledso.longlong.one
129 sampledso.suba.subb.subc.subd.six = 6*sampledso.longlong.one
130 End-of-File
131 echo | tee -a $seq.full
132 cat $tmp.config | tee -a $seq.full
133 export PMDA_LOCAL_SAMPLE=yes
135 for args in sampledso.suba.subb.subc.subd.six sampledso.suba.subb sampledso \
136 sampledso.one.bad sampledso.suba.subb.subc.bad
138 echo | tee -a $seq.full
139 echo "=== -L $args ===" | tee -a $seq.full
140 $sudo_local_ctx pminfo -L -c $tmp.config $args >$tmp.out 2>&1
141 _filter
142 echo "=== -L -f $args ===" | tee -a $seq.full
143 $sudo_local_ctx pminfo -L -c $tmp.config -f $args >$tmp.out 2>&1
144 _filter \
145 | $PCP_AWK_PROG '
146 NF == 0 { want = 0; next }
147 $1 == "sampledso.one" { print ""; want = 1 }
148 $1 ~ /^sampledso\.suba\./ { print ""; want = 1 }
149 want == 1 { print }'
150 echo "=== -n .../root -L ===" | tee -a $seq.full
151 $sudo_local_ctx pminfo -L -c $tmp.config -n $PCP_VAR_DIR/pmns/root $args >$tmp.out 2>&1
152 _filter
153 echo "=== -n .../root ===" | tee -a $seq.full
154 export PCP_DERIVED_CONFIG=$tmp.config
155 src/nameall -n $PCP_VAR_DIR/pmns/root $args >$tmp.out 2>&1
156 _filter | sed -e '/Name space load:/s/[0-9.]* msec/N.NN msec/'
157 unset PCP_DERIVED_CONFIG
158 done
160 echo | tee -a $seq.full
161 echo "Splice-n-dice into existing PMNS ..." | tee -a $seq.full
162 cat <<End-of-File >$tmp.config
163 derived = sample.long.one
164 derived_tree.ten = sample.long.ten
165 derived_tree.hundred = sample.long.hundred
166 derived_tree.sample.long.million = sample.long.million
167 sample.long.derived = sample.long.one
168 sample.long.foo.bar.derived = sample.long.one
169 End-of-File
170 echo | tee -a $seq.full
171 cat $tmp.config | tee -a $seq.full
173 _filter_derived()
175 # look for metric names containing "derived", apply a blacklist
176 grep derived | \
177 sed \
178 -e '/perfevent.derived/d' \
179 #end
182 for args in "" derived derived_tree sample
184 echo | tee -a $seq.full
185 echo "=== $args ===" | tee -a $seq.full
186 pminfo -c $tmp.config $args 2>&1 | _filter_derived
187 done
189 echo | tee -a $seq.full
190 echo "Check diags ..." | tee -a $seq.full
191 cat <<End-of-File >$tmp.config
192 derived.tree.one = sample.long.one
193 derived.tree.ten = sample.long.ten
194 derived.tree.hundred = sample.long.hundred
195 derived.tree.a.million = sample.long.million
196 derived.tree.b.million = sample.long.million
197 derived.tree.b.cmillion = sample.long.million
198 sample.long.derived = sample.long.one
199 sample.long.foo.bar.derived = sample.long.one
200 End-of-File
201 cat $tmp.config
202 export PCP_DERIVED_CONFIG=$tmp.config
203 #debug# src/torture_pmns -Dall -h localhost derived.tree >$tmp.out 2>&1
204 src/torture_pmns -Dderive,appl1 -h localhost derived.tree >$tmp.out 2>&1
205 _filter | _filter2
207 # success, all done
208 exit