pmrep: fix archive end time reporting
[pcp.git] / qa / setup.051
blob49fa707f521531c69e519f25527ae1ec01437610
1 #! /bin/sh
4 . $PCP_DIR/etc/pcp.env
5 . ./common.check
7 # get valid hostnames: $remote_1, $remote_2, etc.
9 . ./051.hosts
11 host=`hostname`
12 if [ -z "$host" ]
13 then
14 echo "Cannot discover local host name!"
15 exit 1
18 ipaddr=`_host_to_ipaddr $host`
19 if [ -z "$ipaddr" ]
20 then
21 echo "Cannot translate hostname ($host) to an IP address!"
22 exit 1
25 rm -rf 051.work
26 mkdir 051.work
27 cd 051.work
29 ##############################################################################
30 # The die.* tests die automatically by themselves.
32 cat >die.001 <<End-of-File
33 # Test whitespace in "[access]" token
35 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
37 [access]
39 die!
40 End-of-File
42 cat >die.002 <<End-of-File
43 # Test whitespace in "[access]" token
45 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
47 [ access]
49 die!
50 End-of-File
52 cat >die.003 <<End-of-File
53 # Test whitespace in "[access]" token
55 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
57 [ access ]
59 die!
60 End-of-File
62 cat >die.004 <<End-of-File
63 # Test whitespace in "[access]" token
65 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
68 # what the &^*%# is this doing here!?
69 access
72 die!
73 End-of-File
75 cat >die.005 <<End-of-File
76 # Test missing host list
78 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
80 [access]
81 allow : all;
83 die!
84 End-of-File
86 cat >die.006 <<End-of-File
87 # Test missing comma in host list
89 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
91 [access]
92 allow $remote_1 $remote_2: all;
94 die!
95 End-of-File
97 cat >die.007 <<End-of-File
98 # Test extra comma in host list
100 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
102 [access]
103 allow $remote_1,: all;
105 die!
106 End-of-File
108 cat >die.008 <<End-of-File
109 # Test missing colon after host list
111 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
113 [access]
114 allow $remote_1 all;
116 die!
117 End-of-File
119 cat >die.009 <<End-of-File
120 # Test extra comma and missing colon after host list
122 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
124 [access]
125 allow $remote_1, all;
127 die!
128 End-of-File
130 cat >die.010 <<End-of-File
131 # Test missing semicolon
133 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
135 [access]
136 allow $remote_1: all
138 die!
139 End-of-File
141 cat >die.011 <<End-of-File
142 # Test statement with lotsa whitespace and comments interspersed.
144 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
146 [access]
147 # I think
148 allow#that I
149 #will never
150 $remote_1
154 #see
155 : #a thing as beautiful
157 # as
158 # the bottom of my in-tray
162 die here!
163 End-of-File
165 cat >die.012 <<End-of-File
166 # Test all operation types.
168 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
170 [access]
172 allow $remote_1 : fetch;
173 allow $remote_1 : store;
174 allow $remote_1 : all;
175 allow $remote_1 : maximum 666 connections;
177 die!
178 End-of-File
180 cat >die.013 <<End-of-File
181 # Test all operations in a single permission list.
183 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
185 [access]
186 allow $remote_1: fetch, store, maximum 666 connections;
188 die!
189 End-of-File
191 cat >die.014 <<End-of-File
192 # Test clash of "all" with a specific operation.
194 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
196 [access]
197 allow $remote_1: all, fetch;
199 die!
200 End-of-File
202 cat >die.015 <<End-of-File
203 # Test that "all" works with a connection limit.
205 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
207 [access]
208 allow $remote_1: all, maximum 666 connections;
210 die!
211 End-of-File
213 cat >die.016 <<End-of-File
214 # Test that specific operations work with a connection limit.
216 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
218 [access]
219 allow $remote_1: fetch, store, maximum 666 connections;
221 die!
222 End-of-File
224 cat >die.017 <<End-of-File
225 # Test that a connection limit fails in a disallow.
227 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
229 [access]
230 disallow $remote_1: store, maximum 666 connections;
232 die!
233 End-of-File
235 cat >die.018 <<End-of-File
236 # Test that a connection limit fails in a disallow with except.
238 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
240 [access]
241 disallow $remote_1: all except fetch, maximum 666 connections;
243 die!
244 End-of-File
246 cat >die.019 <<End-of-File
247 # Test that a connection limit is OK in an allow with an except.
249 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
251 [access]
252 allow $remote_1: all except store, maximum 666 connections;
254 die!
255 End-of-File
257 cat >die.020 <<End-of-File
258 # Test that a bogus hostname is detected
260 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
262 [access]
263 allow error...mebourne : fetch;
265 die!
266 End-of-File
268 cat >die.021 <<End-of-File
269 # Test a no such host condition
271 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
273 [access]
274 allow nosuchhost.melbourne.sgi.com : fetch;
276 die!
277 End-of-File
279 cat >die.022 <<End-of-File
280 # Test that a bogus IP address
282 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
284 [access]
285 allow 192.2.3.999 : fetch;
287 die!
288 End-of-File
290 cat >die.023 <<End-of-File
291 # Test bad wildcard detection in IP address
293 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
295 [access]
296 allow 192.*.2 : fetch;
298 die!
299 End-of-File
301 cat >die.024 <<End-of-File
302 # Test embedded wildcard detection in host name
304 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
306 [access]
307 allow *.melbourne : fetch;
309 die!
310 End-of-File
312 cat >die.025 <<End-of-File
313 # Test wildcard detection in textual host name
315 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
317 [access]
318 allow melbourne.* : fetch;
320 die!
321 End-of-File
323 cat >die.026 <<End-of-File
324 # Test range check for IP address components
326 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
328 [access]
329 allow 192.-1.* : fetch;
330 allow 192.256.* : fetch;
332 die!
333 End-of-File
335 cat >die.027 <<End-of-File
336 # Test "reinforcing" of permissions
338 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
340 [access]
341 allow $remote_1 : fetch;
342 allow $remote_1 : fetch;
344 die!
345 End-of-File
347 cat >die.028 <<End-of-File
348 # Test contradictory permissions
350 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
352 [access]
353 allow $remote_1 : fetch;
354 disallow $remote_1 : fetch;
356 die!
357 End-of-File
359 cat >die.029 <<End-of-File
360 # Test contradictory permissions with host aliasing (IP and name)
362 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
364 [access]
365 allow $host : all;
366 disallow $ipaddr : fetch;
368 die!
369 End-of-File
371 cat >die.030 <<End-of-File
372 # Test contradictory permissions with host aliasing (different names)
374 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
376 [access]
377 allow $remote_1 : all;
378 disallow $remote_1 : fetch;
380 die!
381 End-of-File
383 cat >die.031 <<End-of-File
384 # Test mutually exclusive host lists
386 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
388 [access]
389 allow $remote_1, $remote_2 : all;
390 disallow $remote_3, $remote_4 : store;
392 die!
393 End-of-File
395 cat >die.032 <<End-of-File
396 # Test overlapping host lists
398 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
400 [access]
401 allow $remote_1, $remote_2 : all;
402 allow $remote_3, $remote_2 : fetch, store;
404 die!
405 End-of-File
407 cat >die.033 <<End-of-File
408 # Test overlapping host lists with conflict
410 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
412 [access]
413 allow $remote_1, $remote_4, $remote_2 : all;
414 disallow $remote_3, $remote_2, $remote_5 : store;
416 die!
417 End-of-File
419 cat >die.034 <<End-of-File
420 # Test overlapping host lists with conflicting connection counts
422 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
424 [access]
425 allow $remote_1, $remote_4, $remote_2 : all, maximum 30 connections;
426 allow $remote_3, $remote_2, $remote_5 : fetch, store, maximum 10 connections;
428 die!
429 End-of-File
431 cat >die.035 <<End-of-File
432 # Test various levels of wildcarding
434 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
436 [access]
437 allow 192.68.139.105: all;
438 allow 192.68.139.*: all, maximum 666 connections;
439 allow 192.68.*: all except store, maximum 555 connections;
440 allow 192.*: fetch, store, maximum 444 connections;
441 allow *: fetch, maximum 333 connections;
443 die!
444 End-of-File
446 cat >die.036 <<End-of-File
447 # Test various levels of wildcarding with several similar setups
449 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
451 [access]
452 allow 192.68.139.105: all;
453 allow 192.68.139.*: all, maximum 666 connections;
454 allow 192.68.*: all except store, maximum 555 connections;
455 allow 192.*: fetch, store, maximum 444 connections;
456 allow *: fetch, maximum 333 connections;
458 allow 193.68.139.105: all;
459 allow 193.68.139.*: all, maximum 666 connections;
460 allow 193.68.*: all except store, maximum 555 connections;
461 allow 193.*: fetch, store, maximum 444 connections;
463 allow 194.68.139.105: all;
464 allow 194.68.139.*: all, maximum 666 connections;
465 allow 194.68.*: all except store, maximum 555 connections;
466 allow 194.*: fetch, store, maximum 444 connections;
468 die!
469 End-of-File
471 cat >die.037 <<End-of-File
472 # Test reinforcing of disallows
474 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
476 [access]
477 disallow $remote_1: fetch;
478 disallow $remote_1: store;
479 disallow $remote_1: all;
481 die!
482 End-of-File
484 cat >die.038 <<End-of-File
485 # Test detection of multiple conflicting explicit connections limits
487 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
489 [access]
490 allow $remote_1: maximum 5 connections, fetch, maximum 666 connections;
492 die!
493 End-of-File
495 cat >die.039 <<End-of-File
496 # Test detection of connections limits immediately after "all except"
498 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
500 [access]
501 allow $remote_1: all except maximum 5 connections;
503 die!
504 End-of-File
506 cat >die.040 <<End-of-File
507 # Test unlimited connections access spec.
509 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
511 [access]
512 allow $remote_1: unlimited connections;
514 die!
515 End-of-File
517 cat >die.041 <<End-of-File
518 # Test clash of unlimited connections with explicit maximum
520 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
522 [access]
523 allow $remote_1: unlimited connections;
524 allow $remote_1: fetch, maximum 666 connections;
526 die!
527 End-of-File
529 cat >die.042 <<End-of-File
530 # Test reinforcing of unlimited connections
532 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
534 [access]
535 allow $remote_1: store, unlimited connections;
536 allow $remote_1: fetch, unlimited connections;
538 die!
539 End-of-File
541 # Note: no quotes around "End-Of-File" or $host and $ipaddr not expanded
543 cat >die.043 <<End-of-File
544 # Test conflicts with localhost aliasing
546 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
548 [access]
549 allow localhost: all;
550 disallow $host: fetch;
551 disallow $ipaddr : store;
553 die!
554 End-of-File
556 cat >die.044 <<End-of-File
557 # Check that log advisory and log mandatory no longer work
559 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
561 [access]
562 allow $remote_1 : log advisory;
563 allow $remote_1 : log mandatory;
565 die!
566 End-of-File
568 cat >die.045 <<End-of-File
569 # Test invalid and valid operations in a single permission list.
571 sample 254 socket inet 2077 $PCP_PMDAS_DIR/sample/pmdasample -i 2077
573 [access]
574 allow $remote_1: fetch, store, log advisory, log mandatory, maximum 666 connections;
576 die!
577 End-of-File
579 ##############################################################################
580 # The kill.* tests must be killed as they leave pmcd running.
582 cat >kill.001 <<End-of-File
583 # Test various special case tokens and the parser
585 tricky 128 pipe binary \\
586 cat "whacko name" \\
587 more params x-D x-R x-d 43\\
588 21 back\\\\slash "broken\\
589 string" \\
590 abc:def 1;2;3 zzz "#abc\\"def" "x \\"y\\" z" \\#abc #and a comment\\
591 to_end
592 End-of-File
595 cat >filter.kill.001 <<'End-of-File'
596 #! /bin/sh
598 # Filter log from kill.001
600 . $PCP_DIR/etc/pcp.env
602 echo "This is `basename $0` "
603 echo
604 sed -e '/No such file/s/^cat:/Cannot open/' \
605 | tee kill.001.$$ \
606 | grep -v "Cannot open" \
607 | sed -e 's/^$//' \
608 -e '/^[A-Z][a-z][a-z] [A-Z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/d' \
609 -e '/^Log for pmcd on/s/ on .*/ on .../' \
610 -e '/^Log finished/s/finished .*/finished .../' \
611 -e 's/^\[[A-Z].. [A-Z].. *[0-9][0-9]* ..:..:..]/[DATE]/' \
612 -e '/pmcd([0-9][0-9]*)/s//pmcd(PID)/' \
613 -e '/pcp\[[0-9][0-9]*]/s//pcp[PID]/' \
614 -e '/^pmcd: PID/s/= .*/= PID/' \
615 -e '/pmcd caught SIG.* from pid=/s/=[0-9][0-9]*/=N/g' \
616 | $PCP_AWK_PROG '
617 /pipe cmd=/ { $4 = "FD"; $5 = "FD" }
618 /ok .* INADDR_ANY/ { $2 = "FD" }
619 /ok .*pmcd.socket$/ { next }
620 /^tricky/ { for ( i = 1 ; i <= NF ; i++ )
621 if ( i == 3 ) printf "PID " ; else printf "%s ", $i
622 printf "\n"
623 next
625 { print }
627 echo
628 echo 'dummy cat agent should have produced "Cannot open" messages:'
629 grep "Cannot open" kill.001.$$
630 rm kill.001.$$
631 End-of-File
633 chmod u+x filter.kill.001