pmrep: fix archive end time reporting
[pcp.git] / qa / 481
blob719fe493bc2b3834aeec374933dfb81e520a77c9
1 #!/bin/sh
2 # PCP QA Test No. 481
3 # check pmlogrewrite config parser - global and indom clauses
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"
28 # real QA test starts here
29 cat <<End-of-File >$tmp.conf
30 global {
31 hostname -> whizz-bang.engr.sgi.com
32 TZ -> "GMT+10"
33 Time -> 10
36 indom 1.5 {
37 indom -> 1.10
38 iname "15 minute" -> "forever"
39 inst 15 -> 9999
41 End-of-File
42 rm -f $tmp.new.*
43 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
45 for t in +3 +3.5 +3. +03 4 4.000005 4. 04 -5 -5.005 -5. -05 \
46 +1:00.123456 +2:00 3:00. 04:00 -5:12.345 -6:30 \
47 +23:59:59 -0:0:1 +12:34:56.789012
49 echo
50 echo "=== global time -> $t ==="
51 echo "global { time -> $t }" >$tmp.conf
52 rm -f $tmp.new.*
53 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
54 done
56 for h in abc node123.localdomain foo-bar 123 123.456 123.456foobar \
57 100foo 100.foo 10.0.foo
59 echo
60 echo "=== global hostname -> $h ==="
61 echo "global { hostname -> $h }" >$tmp.conf
62 rm -f $tmp.new.*
63 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
64 done
66 for t in 60 123:45 123:0:61.678901
68 echo
69 echo "=== global time -> $t (expect warning) ==="
70 echo "global { time -> $t }" >$tmp.conf
71 rm -f $tmp.new.*
72 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
73 done
75 echo
76 echo "=== global dup hostname clause (expect error) ==="
77 cat <<End-of-File >$tmp.conf
78 global {
79 hostname -> whizz-bang.engr.sgi.com
80 tz -> "GMT+10"
81 time -> 10
82 hostname -> bogus.com
84 End-of-File
85 rm -f $tmp.new.*
86 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
88 echo
89 echo "=== global dup tz clause (expect error) ==="
90 cat <<End-of-File >$tmp.conf
91 global {
92 hostname -> whizz-bang.engr.sgi.com
93 tz -> "GMT+10"
94 tz -> "Bogus"
95 time -> 10
97 End-of-File
98 rm -f $tmp.new.*
99 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
101 echo
102 echo "=== global dup time clause (expect error) ==="
103 cat <<End-of-File >$tmp.conf
104 global {
105 hostname -> whizz-bang.engr.sgi.com
106 tz -> "GMT+10"
107 time -> 10
108 time -> 11
110 End-of-File
111 rm -f $tmp.new.*
112 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
114 echo
115 echo "=== indom dup indom clause (expect error) ==="
116 cat <<End-of-File >$tmp.conf
117 indom 1.5 {
118 indom -> 1.100
119 inst 15 -> 9999
120 indom -> 1.200
122 End-of-File
123 rm -f $tmp.new.*
124 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
126 echo
127 echo "=== indom dup name clause (expect error) ==="
128 cat <<End-of-File >$tmp.conf
129 indom 1.5 {
130 inst 1 -> 9999
131 iname "1 minute" -> "foo"
132 iname "1 minute" -> "bar"
134 End-of-File
135 rm -f $tmp.new.*
136 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
138 echo
139 echo "=== indom dup inst clause (expect error) ==="
140 cat <<End-of-File >$tmp.conf
141 indom 1.5 {
142 inst 1 -> 9999
143 inst 1 -> 9999
145 End-of-File
146 rm -f $tmp.new.*
147 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
149 # indom ... { indom ... } checks
151 # 4194304 is 2^22, 512 is 2^9 ... exceed serial and domain fields of a pmInDom
152 # 513.4194310 => 1.5 if field range checking not done!
153 for i in 1.5 '' 1.6 1.2.3 foo 1.4194304 512.1 513.4194310 1.*
155 echo
156 echo "=== indom $i { } ==="
157 echo "indom $i { }" >$tmp.conf
158 rm -f $tmp.new.*
159 pmlogrewrite -w -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
160 echo
161 echo "=== indom 1.5 { indom -> $i } ==="
162 echo "indom 1.5 { indom -> $i }" >$tmp.conf
163 rm -f $tmp.new.*
164 pmlogrewrite -w -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
165 done
167 # indom ... { iname | inst ... } exercises
169 for i in 'iname "15" -> "15 mid range"' 'inst 1 -> 3' \
170 'inst 5 -> delete' 'iname "5" -> delete' \
171 'inst 1 -> 3 iname "1" -> "3 minute"' \
172 'iname "15" ->' 'iname "15" -' 'iname "15"'
174 echo
175 echo "=== indom 1.5 { $i } ==="
176 echo "indom 1.5 { $i }" >$tmp.conf
177 rm -f $tmp.new.*
178 pmlogrewrite -w -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
179 done
181 # indom ... { iname | inst ... } checks
183 for i in 'iname "15" -> "16" iname "5" -> "6" iname "15" -> delete' \
184 'iname "5" -> "5 minute"' 'inst 1 -> 1' \
185 'iname "15" -> delete iname "5" -> "6" iname "15" -> "deleted"' \
186 'inst 5 -> 6 inst 1 -> 2 inst 5 -> delete' \
187 'inst 5 -> delete inst 1 -> 2 inst 5 -> 123'\
188 'iname "15" -> "16" inst 15 -> delete' \
189 'inst 15 -> delete iname "15" -> "16"' \
190 'inst 15 -> 16 iname "15" -> delete' \
191 'iname "15" -> delete inst 15 -> 16'
193 echo
194 echo "=== indom 1.5 { $i } (expect error) ==="
195 echo "indom 1.5 { $i }" >$tmp.conf
196 rm -f $tmp.new.*
197 pmlogrewrite -w -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
198 done
200 # instance iname upto space checks
201 for i in "5 minutes" 1 5 15 "1 does not matter" "15 eek"
203 echo
204 echo "=== indom 1.5 { iname \"$i\" -> \"yippee\" } ==="
205 echo "indom 1.5 { iname \"$i\" -> \"yippee\" }" >$tmp.conf
206 rm -f $tmp.new.*
207 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
208 done
209 for i in 19856 "19856 does not matter" 19857
211 echo
212 echo "=== indom 2.1 { iname \"$i\" -> \"19856 bozo\" } ==="
213 echo "indom 2.1 { iname \"$i\" -> \"19856 bozo\" }" >$tmp.conf
214 rm -f $tmp.new.*
215 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
216 done
218 echo
219 echo "=== context sensitive lexical scanning ... expect pass ==="
220 cat <<End-of-File >$tmp.conf
221 global {
222 hostname -> global
224 End-of-File
225 rm -f $tmp.new.*
226 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
227 cat <<End-of-File >$tmp.conf
228 global {
229 hostname -> inst
231 End-of-File
232 rm -f $tmp.new.*
233 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
234 cat <<End-of-File >$tmp.conf
235 global {
236 hostname -> hostname
238 End-of-File
239 rm -f $tmp.new.*
240 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
241 cat <<End-of-File >$tmp.conf
242 global {
243 hostname -> tz
245 End-of-File
246 rm -f $tmp.new.*
247 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
248 cat <<End-of-File >$tmp.conf
249 metric 1.18.3 {
250 name -> hostname
252 End-of-File
253 rm -f $tmp.new.*
254 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
255 cat <<End-of-File >$tmp.conf
256 metric 1.18.3 {
257 name -> indom
259 End-of-File
260 rm -f $tmp.new.*
262 echo
263 echo "=== context sensitive lexical scanning ... expect fail ==="
264 cat <<End-of-File >$tmp.conf
265 metric 1.18.3 {
266 name -> pmid
268 End-of-File
269 rm -f $tmp.new.*
270 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
271 cat <<End-of-File >$tmp.conf
272 metric 1.18.3 {
273 name -> units
275 End-of-File
276 rm -f $tmp.new.*
277 pmlogrewrite -C -c $tmp.conf archives/src-rattle $tmp.new 2>&1 | _filter
279 # success, all done
280 exit