Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 260
blob803b3e36377657ba97144ff5a1e7663e1a300104
1 #!/bin/sh
2 # PCP QA Test No. 260
4 # Exercise delta() for derived metrics
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 status=0 # success is the default!
18 $sudo rm -rf $tmp.* $seq.full
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
21 export PCP_DERIVED_CONFIG=$tmp.config
23 # Derived metric expr dump from 0x8513a48...
24 # expr node 0x867eb68 type=PLUS left=0x867eb98 right=0x867ed28
25 _filter()
27 cat $tmp.out >>$seq.full
28 awk <$tmp.out >$tmp.sed '
29 BEGIN { n = 0 }
30 # expr node 0x9edc340 type=PLUS left=0x9edc2f8 right=0x9edc370
31 $1 == "expr" && $2 == "node" && $3 ~ /^0x/ { print "s/" $3 "/<addr-" n ">/"; n++ }
32 { next }'
33 echo "=== sed ===" >>$seq.full
34 cat $tmp.sed >>$seq.full
35 sed -f $tmp.sed <$tmp.out \
36 | sed \
37 -e '/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/s/[^ ]*.*numpmid/TIMESTAMP ... numpmid/' \
38 -e 's/=0x0 /=(nil) /g' \
39 -e "s;$tmp;TMP;"
40 # -e 's/ val=[0-9][0-9]*/ val=<number>/g'
43 # tolerate some arithmetic "slop" in the reported values ... mostly
44 # due to timer sensitivity for sample intervals at client and at the
45 # PMDAs
47 _filter_pmie()
49 tee -a $seq.full \
50 | $PCP_AWK_PROG '
51 BEGIN { sample = 1 }
52 $1 ~ /^debug_/ { next }
53 NF == 0 { sample++ }
54 $2 == "?" { print; next }
55 $1 == "r_xpect_one_quarter:" { if ($2 >= 0.246 && $2 <= 0.254) $2 = "0.25"; else $0 = $0 " !bad" }
56 $1 == "pmie_xpect_120:" { if ($2 >= 115.0 && $2 <= 122.0) $2 = "120"; else $0 = $0 " !bad" }
57 $1 == "pmie_xpect_360:" { if ($2 >= 355.0 && $2 <= 363.0) $2 = "360"; else $0 = $0 " !bad" }
58 $1 == "derived_xpect_60:" { if (sample < 3) $2 = "<skipped>"
59 else if ($2 >= 55.0 && $2 <= 61.0) $2 = "60"; else $0 = $0 " !bad" }
60 $1 == "derived_xpect_180:" { if (sample < 3) $2 = "<skipped>"
61 else if ($2 >= 170.0 && $2 <= 183.0) $2 = "180"; else $0 = $0 " !bad" }
62 { print }'
65 # initialize counters used in expressions
67 pmstore sample.const_rate.gradient 120 >>$seq.full 2>&1
68 pmstore sample.const_rate.value 0 >>$seq.full 2>&1
69 pmstore sampledso.const_rate.gradient 360 >>$seq.full 2>&1
70 pmstore sampledso.const_rate.value 0 >>$seq.full 2>&1
72 # real QA test starts here
74 echo "=== expression trees and pmDesc propagation ===" | tee -a $seq.full
75 cat <<End-of-File >$tmp.config
76 delta.m1 = delta(sample.const_rate.value)
77 delta.m2 = delta(sampledso.const_rate.value) + sample.bigid
78 delta.m3 = sample.bigid - delta(sampledso.const_rate.value)
79 delta.m4 = sample.bigid - 3 * delta(sampledso.const_rate.value) / sample.long.ten
80 delta.m5 = delta(sample.const_rate.value) / ( delta(sample.const_rate.value) + delta(sampledso.const_rate.value) )
81 delta.m6 = delta(sample.const_rate.value) / delta(sample.const_rate.value) - delta(sampledso.const_rate.value) / delta(sample.const_rate.value)
82 End-of-File
83 echo
84 cat $tmp.config
86 for args in delta
88 echo
89 echo "=== $args ==="
90 pminfo -Dderive,appl0,appl1 -dm $args >$tmp.out 2>&1
91 _filter
92 done
94 # how expected values are determined ...
96 # sample.const_rate.value is increasing 120 per second
97 # sampledso.const_rate.value is increasing 360 per second
98 # pmie is sampling @ 0.5 second intervals, so the derived metrics
99 # will increase at half this rate, but pmie converts back to a rate
100 # per second (so 120.0 and 360.0)
101 # r = 60 / (60 + 180) = 0.25
102 # all of the others are constant, so delta() is zero
104 echo | tee -a $seq.full
105 echo "=== fetch values exercises ===" | tee -a $seq.full
106 cat <<End-of-File >$tmp.config
107 d1 = delta(sample.const_rate.value)
108 d2 = delta(sampledso.const_rate.value)
109 ratio = delta(sample.const_rate.value) / ( delta(sample.const_rate.value) + delta(sampledso.const_rate.value) )
110 delta_l = delta(sample.long.hundred)
111 delta_ull = delta(sample.ulonglong.hundred)
112 delta_f = delta(sample.float.hundred)
113 delta_d = delta(sample.double.hundred)
114 End-of-File
116 cat <<End-of-File \
117 | pmie -h localhost -v -t 0.5 -T '+5sec' 2>&1 \
118 | sed \
119 -e 's/.*Info: evaluator exiting/pmie: note - evaluator exiting/g' \
120 | _filter_pmie
121 debug_1 = sample.const_rate.value;
122 debug_2 = sampledso.const_rate.value;
123 debug_3 = d1;
124 debug_4 = d2;
125 r_xpect_one_quarter = ratio;
126 l_xpect_0 = delta_l;
127 ull_xpect_0 = delta_ull;
128 f_xpect_0 = delta_f;
129 d_xpect_0 = delta_d;
130 pmie_xpect_120 = sample.const_rate.value;
131 derived_xpect_60 = d1;
132 pmie_xpect_360 = sampledso.const_rate.value;
133 derived_xpect_180 = d2;
134 End-of-File
136 # success, all done
137 exit