summaryrefslogtreecommitdiff
path: root/qa/481
blob: 4055fdef2b53f7b853f94c80ad959d48146fb51c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#!/bin/sh
# PCP QA Test No. 481
# check pmlogrewrite config parser - global and indom clauses
#
# Copyright (c) 2011 Ken McDonell.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

which pmlogrewrite >/dev/null 2>&1 || _notrun "pmlogrewrite not installed"

status=0	# success is the default!
$sudo rm -rf $tmp.* $seq.full
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15

_filter()
{
    sed \
	-e "s;$tmp;TMP;g"
}

# real QA test starts here
cat <<End-of-File >$tmp.conf
global {
    hostname -> whizz-bang.engr.sgi.com
    TZ -> "GMT+10"
    Time -> 10
}

indom 1.5 {
    indom -> 1.10
    iname "15 minute" -> "forever"
    inst 15 -> 9999
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter

for t in +3 +3.5 +3. +03 4 4.000005 4. 04 -5 -5.005 -5. -05 \
	+1:00.123456 +2:00 3:00. 04:00 -5:12.345 -6:30 \
	+23:59:59 -0:0:1 +12:34:56.789012
do
    echo
    echo "=== global time -> $t ==="
    echo "global { time -> $t }" >$tmp.conf
    rm -f $tmp.new.*
    pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
done

for h in abc node123.localdomain foo-bar 123 123.456 123.456foobar \
	100foo 100.foo 10.0.foo
do
    echo
    echo "=== global hostname -> $h ==="
    echo "global { hostname -> $h }" >$tmp.conf
    rm -f $tmp.new.*
    pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
done

for t in 60 123:45 123:0:61.678901
do
    echo
    echo "=== global time -> $t (expect warning) ==="
    echo "global { time -> $t }" >$tmp.conf
    rm -f $tmp.new.*
    pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
done

echo
echo "=== global dup hostname clause (expect error) ==="
cat <<End-of-File >$tmp.conf
global {
    hostname -> whizz-bang.engr.sgi.com
    tz -> "GMT+10"
    time -> 10
    hostname -> bogus.com
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter

echo
echo "=== global dup tz clause (expect error) ==="
cat <<End-of-File >$tmp.conf
global {
    hostname -> whizz-bang.engr.sgi.com
    tz -> "GMT+10"
    tz -> "Bogus"
    time -> 10
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter

echo
echo "=== global dup time clause (expect error) ==="
cat <<End-of-File >$tmp.conf
global {
    hostname -> whizz-bang.engr.sgi.com
    tz -> "GMT+10"
    time -> 10
    time -> 11
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter

echo
echo "=== indom dup indom clause (expect error) ==="
cat <<End-of-File >$tmp.conf
indom 1.5 {
    indom -> 1.100
    inst 15 -> 9999
    indom -> 1.200
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter

echo
echo "=== indom dup name clause (expect error) ==="
cat <<End-of-File >$tmp.conf
indom 1.5 {
    inst 1 -> 9999
    iname "1 minute" -> "foo"
    iname "1 minute" -> "bar"
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter

echo
echo "=== indom dup inst clause (expect error) ==="
cat <<End-of-File >$tmp.conf
indom 1.5 {
    inst 1 -> 9999
    inst 1 -> 9999
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter

# indom ... { indom ... } checks
#
# 4194304 is 2^22, 512 is 2^9 ... exceed serial and domain fields of a pmInDom
# 513.4194310 => 1.5 if field range checking not done!
for i in 1.5 '' 1.6 1.2.3 foo 1.4194304 512.1 513.4194310 1.*
do
    echo
    echo "=== indom $i { } ==="
    echo "indom $i { }" >$tmp.conf
    rm -f $tmp.new.*
    pmlogrewrite -w -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
    echo
    echo "=== indom 1.5 { indom -> $i } ==="
    echo "indom 1.5 { indom -> $i }" >$tmp.conf
    rm -f $tmp.new.*
    pmlogrewrite -w -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
done

# indom ... { iname | inst ... } exercises
#
for i in 'iname "15" -> "15 mid range"' 'inst 1 -> 3' \
    'inst 5 -> delete' 'iname "5" -> delete' \
    'inst 1 -> 3 iname "1" -> "3 minute"' \
    'iname "15" ->' 'iname "15" -' 'iname "15"'
do
    echo
    echo "=== indom 1.5 { $i } ==="
    echo "indom 1.5 { $i }" >$tmp.conf
    rm -f $tmp.new.*
    pmlogrewrite -w -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
done

# indom ... { iname | inst ... } checks
#
for i in 'iname "15" -> "16" iname "5" -> "6" iname "15" -> delete' \
	'iname "5" -> "5 minute"' 'inst 1 -> 1' \
	'iname "15" -> delete iname "5" -> "6" iname "15" -> "deleted"' \
	'inst 5 -> 6 inst 1 -> 2 inst 5 -> delete' \
	'inst 5 -> delete inst 1 -> 2 inst 5 -> 123'\
	'iname "15" -> "16" inst 15 -> delete' \
	'inst 15 -> delete iname "15" -> "16"' \
	'inst 15 -> 16 iname "15" -> delete' \
	'iname "15" -> delete inst 15 -> 16'
do
    echo
    echo "=== indom 1.5 { $i } (expect error) ==="
    echo "indom 1.5 { $i }" >$tmp.conf
    rm -f $tmp.new.*
    pmlogrewrite -w -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
done

# instance iname upto space checks
for i in "5 minutes" 1 5 15 "1 does not matter" "15 eek"
do
    echo
    echo "=== indom 1.5 { iname \"$i\" -> \"yippee\" } ==="
    echo "indom 1.5 { iname \"$i\" -> \"yippee\" }" >$tmp.conf
    rm -f $tmp.new.*
    pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
done
for i in 19856 "19856 does not matter" 19857
do
    echo
    echo "=== indom 2.1 { iname \"$i\" -> \"19856 bozo\" } ==="
    echo "indom 2.1 { iname \"$i\" -> \"19856 bozo\" }" >$tmp.conf
    rm -f $tmp.new.*
    pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
done

echo
echo "=== context sensitive lexical scanning ... expect pass ==="
cat <<End-of-File >$tmp.conf
global {
    hostname -> global
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
cat <<End-of-File >$tmp.conf
global {
    hostname -> inst
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
cat <<End-of-File >$tmp.conf
global {
    hostname -> hostname
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
cat <<End-of-File >$tmp.conf
global {
    hostname -> tz
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
cat <<End-of-File >$tmp.conf
metric 1.18.3 {
    name -> hostname
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
cat <<End-of-File >$tmp.conf
metric 1.18.3 {
    name -> indom
}
End-of-File
rm -f $tmp.new.*

echo
echo "=== context sensitive lexical scanning ... expect fail ==="
cat <<End-of-File >$tmp.conf
metric 1.18.3 {
    name -> pmid
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter
cat <<End-of-File >$tmp.conf
metric 1.18.3 {
    name -> units
}
End-of-File
rm -f $tmp.new.*
pmlogrewrite -C -c $tmp.conf src/rattle $tmp.new 2>&1 | _filter

# success, all done
exit