pmrep: really drop non-ascii
[pcp.git] / qa / 340
blobb33c7d8b0200967af916ca3e98d8d0a6860836c0
1 #! /bin/sh
2 # PCP QA Test No. 340
3 # PMCD denies all access?
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. 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 perl -e "use PCP::PMDA" >/dev/null 2>&1
17 test $? -eq 0 || _notrun "PCP::PMDA perl module is not installed"
19 status=1 # failure is the default!
21 [ -z "$PCP_PMLOGGERCONTROL_PATH" ] && \
22 PCP_PMLOGGERCONTROL_PATH="$PCP_SYSCONF_DIR/pmlogger/control"
24 _filter_pminfo()
26 sed \
27 -e 's/Connection reset by peer/No permission to perform requested operation/'
30 # real QA test starts here
32 me=`_get_fqdn`
33 _needclean=true
35 cleanup()
37 if $_needclean
38 then
39 _needclean=false
40 _restore_config $PCP_PMCDCONF_PATH
41 _change_config pmlogger on
42 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
43 _wait_for_pmcd
44 _wait_for_pmlogger
47 if $_chkconfig_pmlogger_on
48 then
49 [ -f $tmp.control ] && \
50 $sudo cp $tmp.control $PCP_PMLOGGERCONTROL_PATH
51 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
52 _wait_for_pmcd
53 _wait_for_pmlogger
54 _chkconfig_pmlogger_on=false
57 $sudo rm -f $tmp.*
58 exit $status
61 trap "cleanup; exit \$status" 0 1 2 3 15
63 rm -f $seq.full
65 # real QA test starts here
66 dov1hosts=true
68 # disable all pmloggers ...
69 _chkconfig_pmlogger_on=true
70 $sudo cp $PCP_PMLOGGERCONTROL_PATH $tmp.control
71 cat <<End-of-File >$tmp.tmp
72 # dummy file created by qa/$seq on `date`
73 # the goal here is to have a controlled primary logger that does
74 # not make requests to pmcd!
75 \$version=1.1
76 LOCALHOSTNAME y n $PCP_LOG_DIR/pmlogger/LOCALHOSTNAME -c /dev/null
77 End-of-File
78 $sudo cp $tmp.tmp $PCP_PMLOGGERCONTROL_PATH
79 #_change_config pmlogger off
81 _save_config $PCP_PMCDCONF_PATH
83 other1=bogus
84 other2=bogus
86 other1=`./getpmcdhosts -n 1 -L -v 'pcp=1' 2>$tmp.err`
87 if [ -z "$other1" ]
88 then
89 echo "[test configuration only for v2 hosts]"
90 dov1hosts=false
91 rm -f $seq.out ; ln $seq-v2.out $seq.out
92 else
93 rm -f $seq.out ; ln $seq-v1v2.out $seq.out
96 other2=`./getpmcdhosts -n 1 -L -v 'pcp>=2' 2>$tmp.err`
97 if [ -z "$other2" ]
98 then
99 # Unable to find remote PCP 2.x host
100 cat $tmp.err >$seq.notrun
101 exit
104 echo "other1=$other1" >>$seq.full
105 echo "other2=$other2" >>$seq.full
107 list1=
108 if $dov1hosts
109 then
110 list1=`_all_hostnames $other1`
111 if [ -z "$list1" ]
112 then
113 echo "Error: failed to expand hostnames for other1=\"$other1\""
114 exit
116 echo "V1 list1=$list1" >>$seq.full
117 list2=`_all_hostnames $other2`
118 if [ -z "$list2" ]
119 then
120 echo "Error: failed to expand hostnames for other2=\"$other2\""
121 exit
123 echo "V1 list2=$list2" >>$seq.full
125 cat >$tmp.access <<End-Of-File
127 [access]
128 disallow $list1 : all;
129 disallow $list2 : all;
130 allow * : all;
131 End-Of-File
132 else
133 list2=`_all_hostnames $other2`
134 if [ -z "$list2" ]
135 then
136 echo "Error: failed to expand hostnames for other2=\"$other2\""
137 exit
139 echo "V2 list2=$list2" >>$seq.full
141 cat >$tmp.access <<End-Of-File
143 [access]
144 disallow $list2 : all;
145 allow * : all;
146 End-Of-File
148 sed -e '/\[access]/q' $PCP_PMCDCONF_PATH.$seq \
149 | sed -e '/\[access]/d' >$tmp.config
150 cat $tmp.access >>$tmp.config
151 $sudo cp $tmp.config $PCP_PMCDCONF_PATH
153 echo >>$seq.full
154 echo "---- start pmcd.conf ----" >>$seq.full
155 cat $PCP_PMCDCONF_PATH >>$seq.full
156 echo "---- end pmcd.conf ----" >>$seq.full
158 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
159 _wait_for_pmcd
161 echo " checking default access for this host ..."
162 pminfo -f sample.long.million \
163 | _filter_pminfo
164 pmstore sample.write_me 111
166 if $dov1hosts
167 then
168 echo
169 echo " checking access for list1 (should fail)"
170 ssh -q pcpqa@$other1 pminfo -h $me -f pmcd.numclients 2>&1 \
171 | sed -e 's/"'$me'"/"HOST"/g'
173 echo
174 echo " checking access for list2 (should fail)"
175 ssh -q pcpqa@$other2 pminfo -h $me -f pmcd.numclients 2>&1 \
176 | sed -e 's/"'$me'"/"HOST"/g'
178 echo "pmcd.log:======="
179 sed -n <$PCP_PMCDLOG_PATH -e '/endclient/{
180 s/\[[0-9]*]/[M]/
181 s/(fd [0-9]*)/(fd N)/
184 echo "================"
186 iplist1=
187 if $dov1hosts
188 then
189 iplist1=`_all_ipaddrs $other1`
190 if [ -z "$iplist1" ]
191 then
192 echo "Error: failed to expand ip addrs for other1=\"$other1\""
193 exit
195 echo "V1 iplist1=$iplist1" >>$seq.full
196 iplist2=`_all_ipaddrs $other2`
197 if [ -z "$iplist2" ]
198 then
199 echo "Error: failed to expand ip addrs for other2=\"$other2\""
200 exit
202 echo "V1 iplist2=$iplist2" >>$seq.full
204 cat >$tmp.access <<End-Of-File
206 [access]
207 disallow $iplist1 : all;
208 disallow $iplist2 : all;
209 allow * : all;
210 End-Of-File
211 else
212 iplist2=`_all_ipaddrs $other2`
213 if [ -z "$iplist2" ]
214 then
215 echo "Error: failed to expand ip addrs for other2=\"$other2\""
216 exit
218 echo "V2 iplist2=$iplist2" >>$seq.full
220 cat >$tmp.access <<End-Of-File
222 [access]
223 disallow $iplist2 : all;
224 allow * : all;
225 End-Of-File
228 sed -e '/\[access]/q' $PCP_PMCDCONF_PATH.$seq \
229 | sed -e '/\[access]/d' >$tmp.config
230 cat $tmp.access >>$tmp.config
231 $sudo cp $tmp.config $PCP_PMCDCONF_PATH
233 echo >>$seq.full
234 echo "---- start pmcd.conf ----" >>$seq.full
235 cat $PCP_PMCDCONF_PATH >>$seq.full
236 echo "---- end pmcd.conf ----" >>$seq.full
238 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
239 _wait_for_pmcd
241 echo " checking default access for this host ..."
242 pminfo -f sample.long.million
243 pmstore sample.write_me 444
245 if $dov1hosts
246 then
247 echo
248 echo " checking access for iplist1 (should fail)"
249 ssh -q pcpqa@$other1 pminfo -h $me -f pmcd.numclients 2>&1 \
250 | sed -e 's/"'$me'"/"HOST"/g'
253 echo
254 echo " checking access for iplist2 (should fail)"
255 ssh -q pcpqa@$other2 pminfo -h $me -f pmcd.numclients 2>&1 \
256 | sed -e 's/"'$me'"/"HOST"/g'
258 echo "pmcd.log:======="
259 sed -n <$PCP_PMCDLOG_PATH -e '/endclient/{
260 s/\[[0-9]*]/[M]/
261 s/(fd [0-9]*)/(fd N)/
264 echo "================"
266 # success, all done
267 status=0
268 exit