pmrep: fix archive end time reporting
[pcp.git] / qa / 766
blobbb97377f1f50b187e871b78d2981766b56a322b6
1 #!/bin/sh
2 # PCP QA Test No. 766
3 # Test using the pmfind app to find PCP servers using the active probing
4 # discovery mechanism. Probe inet only.
6 # Copyright (c) 2014 Red Hat. All Rights Reserved.
9 seq=`basename $0`
10 echo "QA output created by $seq"
12 # get standard environment, filters and checks
13 . ./common.discovery
15 _get_libpcp_config
16 $service_discovery || _notrun "No support for service discovery"
18 status=1 # failure is the default!
19 $sudo rm -rf $tmp.* $seq.full
20 trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
22 _sought_filter()
24 # Only pmcd is guaranteed to be running, but other services may also be.
25 # Transform two cases - no servers vs found servers - into deterministic
26 # output for the --all invocations
27 sed \
28 -e 's/No \(pmproxy servers\) discovered/Sought \1/g' \
29 -e 's/No \(pmwebd servers\) discovered/Sought \1/g' \
30 -e 's/Discovered \(pmproxy servers\):/Sought \1/g' \
31 -e 's/Discovered \(pmwebd servers\):/Sought \1/g' \
32 # end
35 _unresolved_filter()
37 sed -e '/ pcp:/d;
38 / proxy:/d;
39 / http:/d' \
40 | _sought_filter
43 _resolved_filter()
45 # Pass unresolved urls, filter the resolved ones.
46 sed -e '/ pcp:\/\/[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/{p;b};
47 / proxy:\/\/[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/{p;b};
48 / http:\/\/[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/{p;b};
49 / pcp:/d;
50 / proxy:/d;
51 / http:/d' \
52 | _sought_filter
55 _error_tolerance_filter()
57 grep Discovered.pmcd.servers:
58 # ignore everything else, incl. errors
61 # real QA test starts here
62 _control_service_discovery
64 # Obtain the inet address of an active network interface
65 # We're extracting a metric of the form:
67 # inst [0 or "eth0"] value "172.31.0.12"
69 # and then extracting the address
71 addr=`pminfo -f network.interface.inet_addr | \
72 tail -n +3 | \
73 grep -v 127.0.0.1 | \
74 head -n1 | \
75 awk '{ print $6 }' | \
76 sed s/\"//g`
78 [ -z addr ] && _notrun "no active inet interfaces"
80 # Probe the obtained network.
81 # Test various combinations of service queries and subnet sizes. Keep the
82 # subnet size small -- say max 4 bits.
83 echo "-m probe=$addr/32" >> $seq.full
84 echo "-m probe=INET_ADDR/32"
85 pmfind -m probe=$addr/32 | _unresolved_filter
86 echo "Exit status: $?" | tee -a $seq.full
88 echo "-s pmcd -m probe=$addr/31" -r >> $seq.full
89 echo "-s pmcd -m probe=INET_ADDR/31 -r"
90 pmfind -s pmcd -m probe=$addr/30 -r | _resolved_filter
91 echo "Exit status: $?" | tee -a $seq.full
93 echo "-q -m probe=$addr/30" >> $seq.full
94 echo "-q -m probe=INET_ADDR/30"
95 pmfind -q -m probe=$addr/29 | _unresolved_filter
96 echo "Exit status: $?" | tee -a $seq.full
98 echo "-q -s pmcd -m probe=$addr/29 --resolve" >> $seq.full
99 echo "-q -s pmcd -m probe=INET_ADDR/29 --resolve"
100 pmfind -q -s pmcd -m probe=$addr/28 --resolve | _resolved_filter
101 echo "Exit status: $?" | tee -a $seq.full
103 echo "-q -s pmcd -m probe=$addr/28,maxThreads=8" >> $seq.full
104 echo "-q -s pmcd -m probe=INET_ADDR/28,maxThreads=8"
105 pmfind -q -s pmcd -m probe=$addr/28,maxThreads=8 | _unresolved_filter
106 echo "Exit status: $?" | tee -a $seq.full
108 # Try to cause errors; check pmprintf path doesn't blow stack
109 # pmfind just needs to survive to its result message
110 echo "ulimit -n 10" >> $seq.full
111 echo "ulimit -n 10"
112 bash -c "ulimit -n 10; pmfind -s pmcd -m probe=127.0.0.1/24,maxThreads=64" 2>&1 | tee -a $seq.full | _error_tolerance_filter
113 echo "Exit status: $?" | tee -a $seq.full
115 # success, all done
116 status=0
118 exit