Drop unused condition check
[pcp.git] / qa / 244
blob4b01e00aa41a0f859a20e63084bd1c1de0bf0e17
1 #! /bin/sh
2 # PCP QA Test No. 244
3 # PMCD SIGHUP processing tests with $PCP_PMCDCONF_PATH changes
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 filters
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 _get_libpcp_config
17 rm -f $seq.out
18 if $ipv6 ; then
19 ln $seq.out.ipv6 $seq.out || exit 1
20 else
21 ln $seq.out.nonipv6 $seq.out || exit 1
24 _filter_log()
26 sleep 3
27 _filter_pmcd_log <./pmcd.log \
28 | sed \
29 -e '/^DATA: from client/d' \
30 -e '/cmd=.*pmdasample/s//cmd=...pmdasample/' \
31 -e 's/ \[(nil)]//' \
32 -e 's/Cannot open 000000660066: No such file or directory//' \
33 -e 's/^$//' \
34 -e '/^00[08]:/d' \
35 -e '/pmGetPDU/{
36 s/\[[0-9][0-9]*]/[PID]/
37 s/from=.*/from=PID/
38 }' \
39 -e '/_pmHaveMoreInput/{
40 s/\[[0-9][0-9]*]/[PID]/
41 s/0x[^ ]*\([^ ][^ ][^ ]\)/ADDR...\1/
42 }' \
43 -e '/Piggy-back/{
44 s/0x[^ ]*\([^ ][^ ][^ ]\)/ADDR...\1/
45 s/from=.*/from=PID/
46 }' \
47 -e '/pmXmitPDU/s/\[[0-9][0-9]*]/[PID]/' \
48 -e '/pmResult/s/ .* numpmid/ ... numpmid/' \
49 -e '/value /{
50 s/value [0-9][0-9]*/value INTEGER/
51 }' \
52 -e 's;pcp/lib/mips_[^.]*\.;pcp/lib/ISA.;' \
53 -e '/access violation from host/d' \
54 -e '/endclient client.* No permission/d' \
55 -e 's/fd=[0-9][0-9]*/fd=FD/g' \
56 -e "/sed: couldn't flush stdout: Broken pipe/d" \
57 -e '/UNIX_DOMAIN_SOCKET/d' \
58 -e '/unix:/d' \
59 | $PCP_AWK_PROG '
60 $3 ~ /^[0-9][0-9]*$/ { $3 = "A_PID" }
61 $1 == "news" { $4 = "fd_in"; $5 = "fd_out" }
62 $1 == "cisco" { $4 = "fd_in"; $5 = "fd_out"
63 for (i = 9; i <= NF; i++) {
64 # cull args like wanfoo:s0 or wanbar:e1
65 if ($i ~ /:[a-z]/) $i = ""
68 /pipe cmd=/ { $4 = "FD"; $5 = "FD" }
69 /Host access list:/ { localHostPrinted = 0 }
70 /localhost/ { if (! localHostPrinted) {
71 localHostPrinted = 1
72 sub(/^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/,"MYIPADDR",$5)
73 sub(/^[0-9a-f:][0-9a-f:]*%[0-9a-z]+$/,"MYIPADDR",$5)
74 sub(/^[0-9a-f:][0-9a-f:]*$/,"MYIPADDR",$5)
75 sub(/^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/,"MYHOSTMASK",$6)
76 sub(/^[0-9a-f:][0-9a-f:]*$/,"MYHOSTMASK",$6)
78 else next
80 { print }' \
81 | _filter_optional_pmdas \
82 | sed \
83 -e 's/_o32/_SIZE/' \
84 -e 's/_n32/_SIZE/' \
85 -e 's/_64/_SIZE/' \
86 -e "s;$here/src/;;" \
87 -e '/Cleanup "fake_linux" agent (dom 60): unconfigured/q'
90 CONFIG=$PCP_PMCDCONF_PATH
91 NEWCONFIG=$tmp/pmcd.conf
92 CONFIGSAVE=$tmp/pmcd.conf.save
93 [ -z "$PCP_PMLOGGERCONTROL_PATH" ] && \
94 PCP_PMLOGGERCONTROL_PATH="$PCP_SYSCONF_DIR/pmlogger/control"
95 LOGCONTROL=$PCP_PMLOGGERCONTROL_PATH
96 SAVE_LOGCONTROL=$tmp/control.save
97 signal="$sudo $PCP_BINADM_DIR/pmsignal"
98 _needclean=true
99 status=1
101 # for local PMNS to avoid conflict with pmcd tests
103 NAMESPACE="-n $here/src/root_irix"
105 rm -rf $tmp $tmp.*
106 mkdir $tmp
107 chmod ugo+rwx $tmp
108 cd $tmp
110 $sudo chmod u+w $CONFIG
111 cp $CONFIG $CONFIGSAVE
112 [ -f $LOGCONTROL ] && $sudo mv $LOGCONTROL $SAVE_LOGCONTROL
114 _cleanup()
116 cd $here
117 if $_needclean
118 then
119 _needclean=false
120 $signal -s TERM $pmcd
121 sleep 1
122 $sudo rm -f $CONFIG
123 $sudo cp $CONFIGSAVE $CONFIG
124 $sudo chmod u-w $CONFIG
125 [ -f $SAVE_LOGCONTROL ] && $sudo mv $SAVE_LOGCONTROL $LOGCONTROL
126 _restore_loggers
127 echo "Restart and ping pmcd ..."
128 unset PMCD_PORT
129 unset PMCD_SOCKET
130 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
131 _wait_for_pmcd
132 _wait_for_pmlogger
133 pmprobe pmcd.control.debug
134 sleepers=`ps $PCP_PS_ALL_FLAGS | grep '[d]umb_pmda' | $PCP_AWK_PROG '$3 == 1 { print $2 }'`
135 [ ! -z "$sleepers" ] && $sudo $signal -s KILL $sleepers
137 $sudo rm -rf $tmp $tmp.*
140 trap "_cleanup; exit \$status" 0 1 2 3 15
142 # real QA test starts here
144 $sudo $PCP_RC_DIR/pcp stop | _filter_pcp_stop
145 $sudo $signal -a pmgadgets pmchart pmview >/dev/null 2>&1
146 _disable_loggers
147 $sudo $signal -a -s TERM pmie >/dev/null 2>&1
149 # Make our own version of pmcd.conf with dummy agents that will time out.
150 # Copy the pmcd PMDA from the original pmcd.conf so that we can check pmcd's
151 # timeouts by storing into pmcd.control.timeout
152 # NOTE: none of the domains should clash with the pmcd PMDA (domain 2) or the
153 # sample agent (domain 254). These agents will be appended to the file.
155 echo "fake_irix 1 pipe binary $here/src/dumb_pmda -d 1 fake_irix" >$NEWCONFIG
156 echo "fake_sampledso 30 pipe binary $here/src/dumb_pmda -d 30 fake_sampledso" >>$NEWCONFIG
157 echo "fake_cisco 5 pipe binary $here/src/dumb_pmda -d 5 fake_cisco" >>$NEWCONFIG
158 echo "fake_linux 60 pipe binary $here/src/dumb_pmda -d 60 fake_linux" >>$NEWCONFIG
159 grep pmda_pmcd $CONFIGSAVE | sed -e 's/[ ][ ]*/ /g' -e 's/[ ]*$//' >>$NEWCONFIG
160 echo "[access]" >>$NEWCONFIG
161 echo "allow localhost : all;" >>$NEWCONFIG
162 echo "disallow * : all;" >>$NEWCONFIG
163 $sudo cp $NEWCONFIG $CONFIG
165 echo '$PCP_PMCDCONF_PATH contains:'
166 echo '<BEGIN>'
167 sed <$CONFIG \
168 -e '/^pmcd/s; [^ ]*pmda_pmcd.'$DSO_SUFFIX'; ...pmda_pmcd.$DSO_SUFFIX;' \
169 -e "s;$here/src/;;"
170 echo '<END>'
172 # Use a different port to avoid interference by remote monitors
174 port=`_find_free_port 5432`
175 export PMCD_PORT=$port
176 export PMCD_SOCKET=$tmp/pmcd.socket
178 # Note: start pmcd with -f so that its PID stays the same (no daemon)
179 # Also figure out which user we will run pmcd and its pmdas as
181 username=`id -u -n`
182 sudoopts="-u $username"
183 id pcp >/dev/null 2>&1 && sudoopts="-u pcp"
185 cat >$tmp.sh <<END
186 #!/bin/sh
187 export PATH=$here/src:$PATH
188 $PCP_PMCD_PROG -f -t 2 &
189 echo \$!
191 pmcd=`$sudo $sudoopts sh $tmp.sh`
193 # complete V1 PMDA timeouts, then wait for pmcd
195 sleep 12
196 _wait_for_pmcd
198 # If agent not restarted then both messages will be "no agent for domain..."
200 echo "Expect \"IPC protocol failure\" ..."
201 pminfo $NAMESPACE -d hinv.ncpu
203 # Now remove the fake_sampledso agent and add the sample agent from the
204 # original config file and restart PMCD.
205 # The config file has changed and there is also a dead agent to restart.
207 sed <$NEWCONFIG >$tmp.tmp \
208 -e '1{
210 '"`grep pmdasample $CONFIGSAVE | sed -e 's/[ ][ ]*/ /g' -e 's/[ ]*$//'`"'
211 }' \
212 -e '/fake_sampledso/d'
213 mv $tmp.tmp $NEWCONFIG
214 $sudo cp $NEWCONFIG $CONFIG
216 echo '$PCP_PMCDCONF_PATH now contains:'
217 echo '<BEGIN>'
218 sed <$CONFIG \
219 -e '/^pmcd/s; [^ ]*pmda_pmcd.'$DSO_SUFFIX'; ...pmda_pmcd.$DSO_SUFFIX;' \
220 -e '/^sample/s; [^ ]*pmdasample; ...pmdasample;' \
221 -e "s;$here/src/;;"
222 echo '<END>'
224 $signal -s HUP $pmcd
225 _wait_for_pmcd
227 echo "Expect \"Unknown or illegal metric identifier\" ..."
228 pminfo $NAMESPACE -d sampledso.control
229 echo "Expect \"IPC protocol failure\" ..."
230 pminfo $NAMESPACE -d hinv.ncpu
231 echo "Expect 9 values available ..."
232 pmprobe $NAMESPACE -v sample.bin
234 # Next, get the PID of the sample agent, copy the original config file back,
235 # restart PMCD (the sample agent's config line will be unchanged) and check
236 # that the sample agent has the same PID.
237 # The bogus fake_sampledso agent should have been terminated because it is
238 # no longer in the config file.
239 # That isn't enough to terminate the sleep agent.
241 echo
242 echo "Deleting, adding and keeping agents test"
243 sample=`pminfo $NAMESPACE -f sample.daemon_pid | $PCP_AWK_PROG '
244 $1 == "value" { print $2 }
246 sleep 1
247 ps -edf | grep dumb_pmda | grep fake_cisco >/dev/null || echo "Error: phony fake_cisco agent died prematurely"
249 $sudo cp $CONFIGSAVE $CONFIG
251 $signal -s HUP $pmcd
252 _wait_for_pmcd
254 ps -edf | grep dumb_pmda | grep fake_cisco >/dev/null && echo "Error: phony fake_cisco agent still lives!"
256 # Generate a PDU into the domain where the fake_sampledso agent used to be (#30 is
257 # assumed to be the sampledso PMDA)
259 echo "Getting a desriptor from domain 30 (fake_sampledso agent had this domain)"
260 pminfo $NAMESPACE -md sampledso.control
262 # check pmdasample has same pid (not restarted)
264 sample2=`pminfo $NAMESPACE -f sample.daemon_pid | $PCP_AWK_PROG '
265 $1 == "value" { print $2 }
267 if [ "X$sample" != "X$sample2" ]
268 then
269 echo "Sample agent needlessly restarted (pid changed from $sample to $sample2)"
272 _filter_log
273 echo
274 echo "..."
276 # success, all done
277 status=0
278 exit