4 # Test pmcd timeouts with the pmcd PMDA's pmcd.control.timeout
6 # Test setting the app's timeouts < pmcd's timeout and vice versa
8 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
12 echo "QA output created by $seq"
14 # get standard environment, filters and checks
20 echo "Test pmcd timeouts with the pmcd PMDA's pmcd.control.timeout"
24 signal
=$PCP_BINADM_DIR/pmsignal
28 sed -e 's/\.\.\.\.\.*/[dots]/'
33 $sudo $PCP_RC_DIR/pcp stop
>$tmp.stop
34 # primary pmlogger exiting during the test is racey depending on timing
35 # of fetches and stopping/starting pmcd (this is also not under test).
36 _filter_pcp_stop
<$tmp.stop | _filter_dots |
sed -e '/logger not running/d'
37 _restore_config
$PCP_PMCDCONF_PATH
38 $sudo $PCP_RC_DIR/pcp start
>$tmp.start
39 _filter_pcp_start
<$tmp.start | _filter_dots
46 status
=1 # failure is the default!
47 trap "_cleanup; exit \$status" 0 1 2 3 15
50 # real QA test starts here
52 # This value is passed to processes this script creates on the command line.
53 # It's unlikely to occur anywhere in a ps output and is used as a tag to
54 # terminate or check for the existence of the processes later.
61 n_pmcd
=`ps $PCP_PS_ALL_FLAGS \
63 | fgrep "$PCP_PMCD_PATH" \
67 if [ "X$n_pmcd" != "X$1" ]
69 echo "Expected $1 pmcd processes but found $n_pmcd:"
72 file $PCP_LOG_DIR/core
* $PCP_LOG_DIR/pmcd
/core
*
84 echo "app timeout = $app_timeout"
85 echo "pmcd timeout = $pmcd_timeout"
86 PMCD_REQUEST_TIMEOUT
=$app_timeout
87 export PMCD_REQUEST_TIMEOUT
89 pmstore pmcd.control.timeout
$pmcd_timeout
102 # use a dummy pmns for pminfo
103 dummy_domain
=160 # choose non-existent domain
106 dummyproc $dummy_domain:0:0
110 # pmcd will run a dumb_pmda, masquerading as the IRIX agent. This will
111 # not respond to PDUs from PMCD, which should then time it out.
112 # The pmcd PMDA is required so that pmcd.control.timeout can be modified.
113 # We don't need any other PMDAs and in particular all pmlogger and pmie
114 # processes are stopped before pmcd is reconfigured.
115 # Save the current pmcd.conf so it can be restored afterwards.
117 _save_config
$PCP_PMCDCONF_PATH
118 cat >$tmp.tmp
<<End-Of-File
119 # QA test 169 dummy pmcd.conf (blame Jonathan if you find this!)
121 dummyproc $dummy_domain pipe binary $here/src/dumb_pmda -d $dummy_domain $TAG
124 $PCP_AWK_PROG <$PCP_PMCDCONF_PATH >>$tmp.tmp
'$1 == "pmcd" { print }'
126 pmcdlog
=$PCP_PMCDLOG_PATH
128 $sudo $signal -a -s TERM pmie
129 $sudo $signal -a -s TERM pmlogger
131 $sudo cp $tmp.tmp
$PCP_PMCDCONF_PATH
132 $sudo $PCP_RC_DIR/pmcd start
>$tmp.start
133 _filter_pcp_start
<$tmp.start |
sed -e 's/\.\.\.\.\.*/[dots]/'
135 if _check_pmcd_procs
1
139 _echo
"pmcd didn't start!"
141 cat $pmcdlog >>$seq.full
145 ps
$PCP_PS_ALL_FLAGS >$tmp.ps
146 egrep '[P]ID|[p]m' $tmp.ps
>>$seq.full
147 if grep "[d]umb_pmda" $tmp.ps
>/dev
/null
151 _echo
"pmcd didn't create the dumb_pmda agent"
153 cat $pmcdlog >>$seq.full
157 # force to a known state
159 pmstore pmcd.control.timeout
5 >/dev
/null
163 #debug# pmstore pmcd.control.tracenobuf 1 >/dev/null
166 # pmcd agent timeout < application time out
169 _echo
"*** pmcd agent timeout < app timeout ***"
170 _echo
"*** pmcd will killoff agent ***"
174 # Fetch from dummy domain. This should cause the dumb_pmda agent to be
175 # timed-out by pmcd, resulting in its termination.
178 _echo
"Expect dummyproc to fail (IPC protocol failure):"
179 pminfo
-n $pmns -d dummyproc
181 # make sure pmcd has had a chance to wait() on the pmda process
184 pminfo
-n $pmns -d dummyproc
>/dev
/null
2>&1
186 ps
$PCP_PS_ALL_FLAGS >$tmp.ps
187 egrep '[P]ID|[p]m' $tmp.ps
>>$seq.full
188 if grep "[d]umb_pmda" <$tmp.ps
>/dev
/null
190 _echo
"Error: pmcd didn't terminate the dumb_pmda agent"
191 cat $pmcdlog >>$seq.full
194 _echo
"pmcd terminated dummy the dumb_pmda agent as desired"
198 cat $PCP_LOG_DIR/pmcd
/pmcd.log
>>$seq.full
200 cat $PCP_LOG_DIR/pmcd
/dumb_pmda.log
>>$seq.full
202 # Restart pmcd and its agents
204 $sudo $signal -a -s HUP pmcd
207 if _check_pmcd_procs
1
211 _echo
"pmcd was sent SIGHUP and died"
213 cat $pmcdlog >>$seq.full
217 ps
$PCP_PS_ALL_FLAGS >$tmp.ps
218 egrep '[P]ID|[p]m' $tmp.ps
>>$seq.full
219 if grep "[d]umb_pmda" <$tmp.ps
>/dev
/null
221 psline
=`ps $PCP_PS_ALL_FLAGS | grep "[d]umb_pmda"`
222 old_dummy_pid
=`echo $psline | cut -d ' ' -f 2`
224 _echo
"pmcd SIGHUP didn't restart the dumb_pmda agent"
226 cat $pmcdlog >>$seq.full
231 # pmcd agent timeout > application time out
234 _echo
"*** pmcd agent timeout > app timeout ***"
235 _echo
"*** pmcd will not killoff agent until later ***"
239 # Fetch from dummy domain. This should cause the dumb_pmda agent to be
240 # timed-out by pmcd, resulting in its termination.
243 _echo
"Expect dummyproc to fail (timeout for pmcd failure):"
245 pminfo
-n $pmns -d dummyproc
249 ps
$PCP_PS_ALL_FLAGS >$tmp.ps
250 egrep '[P]ID|[p]m' $tmp.ps
>>$seq.full
251 if grep "[d]umb_pmda" <$tmp.ps
>/dev
/null
253 _echo
"pmcd did NOT terminate the dumb_pmda agent as desired"
255 # make sure it is really the same process - check pid
256 psline
=`ps $PCP_PS_ALL_FLAGS | grep "[d]umb_pmda"`
257 new_dummy_pid
=`echo $psline | cut -d ' ' -f 2`
258 if [ $old_dummy_pid -ne $new_dummy_pid ]
260 _echo
"Error: dumb_pmda proc has been recreated"
261 _echo
"pid mismatch: $old_dummy_pid versus $new_dummy_pid"
265 _echo
"Error: pmcd terminated the dumb_pmda agent"
266 cat $pmcdlog >>$seq.full
271 _echo
"Now wait for pmcd to timeout..."
275 ps
$PCP_PS_ALL_FLAGS >$tmp.ps
276 egrep '[P]ID|[p]m' $tmp.ps
>>$seq.full
277 if grep "[d]umb_pmda" <$tmp.ps
>/dev
/null
279 _echo
"Error: pmcd didn't terminate the dumb_pmda agent"
280 cat $pmcdlog >>$seq.full
283 _echo
"pmcd terminated the dumb_pmda agent as desired"
287 cat $PCP_LOG_DIR/pmcd
/pmcd.log
>>$seq.full
289 cat $PCP_LOG_DIR/pmcd
/dumb_pmda.log
>>$seq.full