pmrep: fix archive end time reporting
[pcp.git] / qa / 496
blob45e30691e9a8ea5230212611f8e26fafcb0a0b1d
1 #!/bin/sh
2 # PCP QA Test No. 496
3 # pmlogrewrite - multiple -c options and -c dir option
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 -rf $tmp.*; exit \$status" 0 1 2 3 15
22 _filter()
24 sed \
25 -e "s;$tmp;TMP;g" \
26 -e "s;/$seq-$$\.;/SEQ-PID.;g" \
27 -e '/[-+ ]\[[0-9][0-9]* bytes]/d' \
28 -e "s/^\([+-][+-][+-] TMP\...t*\).*/\1/"
31 _cmp()
33 if [ ! -f "$1.0" ]
34 then
35 echo "Arrgh ... $1.0 missing" | _filter
36 return
38 if [ ! -f "$2.0" ]
39 then
40 echo "Arrgh ... $2.0 missing" | _filter
41 return
43 pmdumplog -z -a $1 | tee -a $seq.full >$tmp.in
44 pmdumplog -z -a $2 | tee -a $seq.full >$tmp.out
45 diff -u $tmp.in $tmp.out | _filter
48 cat <<End-of-File >$tmp.conf.1
49 metric sample.ulong.bin_ctr {
50 indom -> NULL output MIN
51 type -> DOUBLE
52 units -> 1,0,0,BYTE,0,0
54 metric sample.ulonglong.bin_ctr {
55 indom -> NULL output MAX
56 type -> 32
57 units -> 1,0,0,BYTE,0,0
59 End-of-File
60 cat <<End-of-File >$tmp.conf.2
61 metric sampledso.double.bin_ctr {
62 indom -> NULL output AVG
63 type -> FLOAT
65 metric sample.float.bin_ctr {
66 indom -> NULL output SUM
67 type -> U64
69 metric sample.longlong.bin_ctr {
70 indom -> NULL output FIRST
71 type -> 64
72 units -> 1,-1,0,KBYTE,SEC,0
74 End-of-File
75 cat <<End-of-File >$tmp.conf.3
76 indom 29.2 { inst 200 -> DELETE }
77 indom 30.2 { inst 800 -> DELETE }
78 End-of-File
80 cat $tmp.conf.? >$tmp.conf.all
82 # real QA test starts here
84 # Note - correctness of this archive and config is established in QA 493
86 echo "=== baseline ==="
87 rm -f $tmp.baseline.*
88 pmlogrewrite -ws -c $tmp.conf.all archives/rewrite $tmp.baseline 2>&1 | _filter
90 echo
91 echo "=== one config file ==="
92 rm -f $tmp.new.*
93 pmlogrewrite -ws -c $tmp.conf.all archives/rewrite $tmp.new 2>&1 | _filter
94 _cmp $tmp.baseline $tmp.new
96 echo
97 echo "=== three config files ==="
98 rm -f $tmp.new.*
99 pmlogrewrite -ws -c $tmp.conf.1 -c $tmp.conf.2 -c $tmp.conf.3 archives/rewrite $tmp.new 2>&1 | _filter
100 _cmp $tmp.baseline $tmp.new
102 echo
103 echo "=== config dir with regular files ==="
104 mkdir $tmp.conf.dir
105 cp $tmp.conf.[123] $tmp.conf.dir
106 rm -f $tmp.new.*
107 pmlogrewrite -ws -c $tmp.conf.dir archives/rewrite $tmp.new 2>&1 | _filter
108 _cmp $tmp.baseline $tmp.new
110 echo
111 echo "=== config dir with symlinks files and hidden files ==="
112 rm -f $tmp.conf.dir/*
113 for i in 1 2 3
115 ln -s $tmp.conf.$i $tmp.conf.dir
116 done
117 echo "metric sampledso.ulong.hundred { type -> U32 }" >$tmp.conf.dir/.$seq-$$.conf.4
118 rm -f $tmp.new.*
119 pmlogrewrite -ws -c $tmp.conf.dir archives/rewrite $tmp.new 2>&1 | _filter
120 _cmp $tmp.baseline $tmp.new
122 echo
123 echo "=== config dir unhide bad file ==="
124 mv $tmp.conf.dir/.$seq-$$.conf.4 $tmp.conf.dir/$seq-$$.conf.4
125 rm -f $tmp.new.*
126 # need to sort here because the order in which the files are processed
127 # depends in readdir() and is not deterministic
128 pmlogrewrite -ws -c $tmp.conf.dir archives/rewrite $tmp.new 2>&1 \
129 | LC_COLLATE=POSIX sort \
130 | _filter
131 _cmp $tmp.baseline $tmp.new
133 # success, all done
134 exit