Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 494
blob87345c5d1248748aabf0a7915cab88aa7297f207
1 #!/bin/sh
2 # PCP QA Test No. 494
3 # pmlogrewrite man page examples
5 # Copyright (c) 2011 Ken McDonell. All Rights Reserved.
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 which pmlogrewrite >/dev/null 2>&1 || _notrun "pmlogrewrite not installed"
18 status=0 # success is the default!
19 $sudo rm -rf $tmp.* $seq.full
20 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
22 _filter()
24 sed \
25 -e "s;$tmp;TMP;g" \
26 -e "s/^\([+-][+-][+-] TMP\...t*\).*/\1/"
29 _cmp()
31 if [ ! -f $1.0 ]
32 then
33 echo "Arrgh ... cannot find $1.0" | _filter
34 return
36 if [ ! -f $2.0 ]
37 then
38 echo "Arrgh ... cannot find $2.0" | _filter
39 return
41 pmdumplog -z -a $1 | tee -a $seq.full >$tmp.in
42 pmdumplog -z -a $2 | tee -a $seq.full >$tmp.out
43 echo "pmdumplog diffs ..."
44 diff -u $tmp.in $tmp.out | _filter
47 _cmp2()
49 if [ ! -f $1.0 ]
50 then
51 echo "Arrgh ... cannot find $1.0" | _filter
52 return
54 if [ ! -f $2.0 ]
55 then
56 echo "Arrgh ... cannot find $2.0" | _filter
57 return
59 echo "--- input metadata ---"
60 pminfo -d -a $1 $3
61 echo "--- output metadata ---"
62 pminfo -d -a $2 $3
63 pmval -zr -f 1 -w 12 -U $1 $3 | tee -a $seq.full >$tmp.in
64 pmval -zr -f 1 -w 12 -U $2 $3 | tee -a $seq.full >$tmp.out
65 echo "pmval diffs ..."
66 diff -u $tmp.in $tmp.out | _filter
69 # real QA test starts here
70 sed -e '/^#/d' <<End-of-File | while read arch_args spec
71 # archive[|arg1[|arg2[|...]]] spec
72 # double ->
73 archives/rewrite global { time -> 30 }
74 archives/rewrite global { time -> -23:59:59.999 }
75 archives/rewrite indom 29.* { indom -> 109.* }
76 archives/rewrite metric 30.*.* { pmid -> 123.*.* }
77 archives/rewrite indom 29.* { indom -> 109.* } metric sample.bin { indom -> 109.2 }
78 archives/rewrite indom 29.* { indom -> 109.* } metric sample.bin { indom -> 123.2 }
79 archives/proc indom 60.2 { inst 1 -> 60 iname "1 minute" -> "60 second" inst 5 -> 300 iname "5 minute" -> "300 second" inst 15 -> 900 iname "15 minute" -> "900 second" }
80 End-of-File
82 echo | tee -a $seq.full
83 echo "$spec" >$tmp.config
84 echo "=== `cat $tmp.config` ===" | tee -a $seq.full
85 rm -f $tmp.new.*
86 pmlogrewrite -ws -c $tmp.config `echo $arch_args | sed -e 's/|/ /g'` $tmp.new 2>&1 | _filter
87 _cmp `echo $arch_args | sed -e 's/|.*//'` $tmp.new
88 done
90 sed -e '/^#/d' <<End-of-File | while read arch_args spec
91 # archive[|arg1[|arg2[|...]]] spec|metric...
92 # double ->
93 archives/babylon.pmview_v2 metric disk.dev.read { type -> U64 } metric disk.dev.write { type -> U64 } metric disk.dev.total { type -> U64 }|disk.dev.read disk.dev.write disk.dev.total
94 End-of-File
96 echo | tee -a $seq.full
97 metrics=`echo "$spec" | sed -e 's/.*|//'`
98 spec=`echo "$spec" | sed -e 's/|.*//'`
99 echo "$spec" >$tmp.config
100 echo "=== `cat $tmp.config` ===" | tee -a $seq.full
101 rm -f $tmp.new.*
102 pmlogrewrite -ws -c $tmp.config `echo $arch_args | sed -e 's/|/ /g'` $tmp.new 2>&1 | _filter
103 for m in $metrics
105 _cmp2 `echo $arch_args | sed -e 's/|.*//'` $tmp.new $m
106 done
107 done
109 echo | tee -a $seq.full
110 echo "=== proc metrics migration ===" | tee -a $seq.full
111 cat <<End-of-File >$tmp.config
112 # proc metrics are all in 7 clusters
113 metric 60.8.* { pmid -> 123.*.* }
114 metric 60.9.* { pmid -> 123.*.* }
115 metric 60.13.* { pmid -> 123.*.* }
116 metric 60.24.* { pmid -> 123.*.* }
117 metric 60.31.* { pmid -> 123.*.* }
118 metric 60.32.* { pmid -> 123.*.* }
119 metric 60.51.* { pmid -> 123.*.* }
120 # only one instance domain for Linux proc metrics
121 indom 60.9 { indom -> 123.0 }
122 End-of-File
123 rm -f $tmp.new.*
124 pmlogrewrite -ws -c $tmp.config archives/proc $tmp.new 2>&1 | _filter
126 pminfo -m -a archives/proc | LC_COLLATE=POSIX sort >$tmp.in
127 pminfo -m -a $tmp.new | LC_COLLATE=POSIX sort >$tmp.out
128 echo
129 echo "pmns diffs ..."
130 diff -u $tmp.in $tmp.out | _filter
132 for arg in -i -m
134 pmdumplog -z $arg archives/proc >$tmp.in 2>$tmp.err
135 if [ -s $tmp.err ]
136 then
137 echo "stderr from pmdumplog -z $arg archives/proc ..."
138 cat $tmp.err
140 pmdumplog -z $arg $tmp.new >$tmp.out 2>$tmp.err
141 if [ -s $tmp.err ]
142 then
143 echo "stderr from pmdumplog -z $arg $tmp.new ..." | _filter
144 cat $tmp.err
146 echo
147 echo "pmdumplog $arg diffs ..."
148 diff -u $tmp.in $tmp.out | _filter
149 done
151 # success, all done
152 exit