1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
|
#! /bin/sh
# PCP QA Test No. 578
# Test for Bug #660497, change openfds metric to be the
# largest known file descriptor used by pmcd.
# This means the file descriptor can only ever increase.
# The following behaviour is expected:
# the file descriptor will increase when a client or pmda connects
# the file descriptor will stay the same when a client or pmda disconnects
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard filters
. ./common.product
. ./common.filter
. ./common.check
[ -d $PCP_PMDAS_DIR/simple ] || _notrun "simple PMDA directory is not installed"
status=1 # failure is the default!
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
pmie_was_running=false
[ -f $PCP_RUN_DIR/pmie.pid ] && pmie_was_running=true
signal=$PCP_BINADM_DIR/pmsignal
simple_domain=253
if [ -x pmobjstyle ]
then
style=`pmobjstyle`
else
style=''
fi
_start_client()
{
pmval -T 10sec pmcd.client.whoami >$tmp.tmp 2>&1 &
echo "=== Started client ===" | tee -a $seq_full
sleep 3
}
# Remove the PMDA and restore pmcd.conf
#
_cleanup()
{
[ -f $PCP_PMDAS_DIR/simple/simple.conf.$seq ] && _restore_config $PCP_PMDAS_DIR/simple/simple.conf
if [ -f $PCP_PMCDCONF_PATH.$seq ]
then
echo "=== Resetting pmcd.conf back to original state ==="
_restore_config $PCP_PMCDCONF_PATH
_restore_config $PCP_VAR_DIR/pmns/root
echo "=== Restart PMCD ==="
unset PMCD_PORT
_service pmcd restart 2>&1 | _filter_pcp_restart
_wait_for_pmcd
_service pmlogger restart 2>&1 | _filter_pcp_restart
_wait_for_pmlogger
_restore_auto_restart pmlogger
fi
if grep '^simple' $PCP_PMCDCONF_PATH >/dev/null
then
:
else
# simple was not installed, cull namespace
#
cd $PCP_PMDAS_DIR/simple
$sudo ./Remove >/dev/null
fi
if [ -f $tmp.log ]
then
echo '=== pmcd log' >>$seq_full
cat $tmp.log >>$seq_full
fi
if $pmie_was_running
then
_restore_auto_restart pmie
_service pmie start >>$seq_full 2>&1
else
_service pmie stop >>$seq_full 2>&1
$sudo $PCP_BINADM_DIR/pmsignal -a -s TERM pmie >>$seq_full 2>&1
_wait_pmie_end
fi
rm -rf $tmp.*
}
trap "_cleanup; exit \$status" 0 1 2 3 15
_filter_ins()
{
sed \
-e 's/.* \(hash table entries\)/ NNN \1/' \
-e 's/.* \(non-leaf nodes\)/ NNN \1/' \
-e 's/.* \(leaf nodes\)/ NNN \1/' \
-e 's/.* \(bytes of symbol table\)/ NNN \1/'
}
_filter_init()
{
sed \
-e "s/$$/PID/g"
}
_filter_openfds_value()
{
$PCP_AWK_PROG '
BEGIN { fst_fds = "fst_fds"; sec_fds = "sec_fds"; thr_fds = "thr_fds"; step = 0 }
$1 == "pmcd.openfds" { want = 1; next }
NF == 0 { want = 0; next }
want == 1 && $1 == "value" && step == 0 {
fst_fds = $2; step = 1; next }
want == 1 && $1 == "value" && step == 1 {
sec_fds = $2; step = 2; next }
want == 1 && $1 == "value" && step == 2 {
thr_fds = $2;
# Need some slop here (possibly because of non-determinism in
# parallel checking in connection code), so
# - after Install open fds to be within 0,+10
# - after Remove open fds to be within 0,+4
#
if (fst_fds <= sec_fds && sec_fds <= fst_fds+10)
printf("=== Info: After Install, openfds has increased or stayed about the same as expected ===\n");
else {
printf("=== Error: After Install, openfds has unexpectedly changed ===\n");
printf("\t previous value %d, current value %d (expect [%d..%d])\n", fst_fds, sec_fds, fst_fds, fst_fds+10);
}
if (sec_fds <= thr_fds && thr_fds <= sec_fds+4)
printf("=== Info: After Remove, openfds has stayed about the same as expected ===\n");
else {
printf("=== Error: After Remove, openfds has unexpectedly changed ===\n")
printf("\t previous value %d, current value %d (expect [%d..%d]\n", sec_fds, thr_fds, sec_fds, sec_fds+4);
}
next;
}
{ next } '
}
# no random clients, thanks
#
port=`_get_port tcp 6060 6070`
if [ -z "$port" ]
then
echo "Arrggh ... no free TCP port in the range 6060 ... 6070"
netstat -an
exit
fi
PMCD_PORT=$port
export PMCD_PORT
# don't want these guys trying to connect to pmcd either ...
#
_stop_auto_restart pmlogger
if ! _service pmlogger stop >>$seq_full 2>&1; then _exit 1; fi
if $pmie_was_running
then
_stop_auto_restart pmie
if ! _service pmie stop >>$seq_full 2>&1; then _exit 1; fi
fi
# and we're starting a new pmcd ...
if ! _service pmcd stop; then _exit 1; fi \
| _filter_pcp_stop
# Build simple agent
#
echo "=== Building simple agent ===" | tee -a $seq_full
unset ROOT TOOLROOT MAKEFLAGS
cd $PCP_PMDAS_DIR/simple
# get rid of warnings from simple if no config exists
[ -f simple.conf ] && _save_config simple.conf
echo "sec,min,hour" >$tmp.simple.conf
$sudo cp $tmp.simple.conf simple.conf
if $sudo $PCP_MAKE_PROG > $tmp.make 2>&1
then
echo "PMDA built"
else
echo "Unable to build the simple PMDA:"
cat $tmp.make
exit
fi
sed -e "/^@ SIMPLE/s/SIMPLE/$simple_domain/" < help \
| $sudo $PCP_BINADM_DIR/newhelp -v 2 -o help
echo "Help generated"
cd $here
# Refresh PMCD
#
_renew_pmcd()
{
echo "=== Restarting PMCD with minimal PMDAs ===" | tee -a $seq_full
if [ -f $tmp.newconf ]
then
$sudo cp $tmp.newconf $PCP_PMCDCONF_PATH
$sudo $signal -a -s HUP pmcd
sleep 4
_wait_for_pmcd || _exit 1
else
echo caller - $1 - has not created $tmp.newconf !!!
fi
}
# Install a standard pmda, but do not mess with the namespace
#
_agent_install()
{
agent=$1
domain=$2
daemon=$3
path=$PCP_PMDAS_DIR/$agent
echo "=== Installing $agent ===" | tee -a $seq_full
cp $tmp.newconf $tmp.latest
if $daemon
then
cat << End-of-File >> $tmp.latest
$agent $domain pipe binary $path/pmda$agent -d $domain
End-of-File
else
cat << End-of-File >> $tmp.latest
$agent $domain dso ${agent}_init $path/${style}pmda_$agent.$DSO_SUFFIX
End-of-File
fi
$sudo cp $tmp.latest $PCP_PMCDCONF_PATH
$sudo $signal -a -s HUP pmcd
sleep 4
_wait_for_pmcd || _exit 1
if _check_agent $agent true
then
echo "$agent is alive and well"
else
echo "Failed to install $agent"
exit
fi
}
# Remove a pmda
#
_agent_remove()
{
agent=$1
echo "=== Removing $agent ===" | tee -a $seq_full
_renew_pmcd _agent_remove
if _check_agent $agent true
then
echo "Failed to remove $agent"
exit
else
echo "$agent was removed"
fi
}
# real QA test starts here
# Copy and replace pmcd.conf
#
_save_config $PCP_PMCDCONF_PATH
_save_config $PCP_VAR_DIR/pmns/root
if [ $PCP_PLATFORM = linux ]
then
cat << End-of-File > $tmp.newconf
# Installed by PCP QA test $seq on `date`
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
linux 60 dso linux_init $PCP_PMDAS_DIR/linux/pmda_linux.so
End-of-File
elif [ $PCP_PLATFORM = darwin ]
then
cat << End-of-File > $tmp.newconf
# Installed by PCP QA test $seq on `date`
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.dylib
darwin 78 dso darwin_init $PCP_PMDAS_DIR/darwin/pmda_darwin.dylib
End-of-File
elif [ $PCP_PLATFORM = solaris ]
then
cat << End-of-File > $tmp.newconf
# Installed by PCP QA test $seq on `date`
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
solaris 75 dso solaris_init $PCP_PMDAS_DIR/solaris/pmda_solaris.so
End-of-File
elif [ $PCP_PLATFORM = freebsd ]
then
cat << End-of-File > $tmp.newconf
# Installed by PCP QA test $seq on `date`
freebsd 85 dso freebsd_init $PCP_PMDAS_DIR/freebsd/pmda_freebsd.so
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
End-of-File
elif [ $PCP_PLATFORM = openbsd ]
then
cat << End-of-File > $tmp.newconf
# Installed by PCP QA test $seq on `date`
freebsd 139 dso openbsd_init $PCP_PMDAS_DIR/openbsd/pmda_openbsd.so
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
End-of-File
else
echo "Arrgh ... need pmcd.conf output for $PCP_PLATFORM"
exit 1
fi
#_renew_pmcd main
if [ -f $tmp.newconf ]
then
$sudo cp $tmp.newconf $PCP_PMCDCONF_PATH
fi
# Start with a fresh pmcd log
#
# need to do this indirectly because system sudo cleanses the environment
#
echo "PMCD_PORT=$PMCD_PORT; export PMCD_PORT" >$tmp.start
echo "$PCP_RC_DIR/pmcd start" >>$tmp.start
$sudo sh $tmp.start | _filter_pcp_start | _filter_init 2>&1
_wait_for_pmcd || _exit 1
_test_pmda()
{
pmda_type=$1
# Test PMDA
#
echo
echo "=== Testing PMDA as a $pmda_type ===" | tee -a $seq_full
rm -f $tmp.pminfo
pminfo -b 1 -f pmcd.openfds pmcd.client.whoami >$tmp.pminfo
if [ "$pmda_type" != PIPE ]
then
_agent_install simple $simple_domain false
else
_agent_install simple $simple_domain true
fi
pminfo -b 1 -f pmcd.openfds pmcd.client.whoami >>$tmp.pminfo
_agent_remove simple
pminfo -b 1 -f pmcd.openfds pmcd.client.whoami >>$tmp.pminfo
echo "=== pminfo output ===" >>$seq_full
cat $tmp.pminfo >>$seq_full
cat $tmp.pminfo | _filter_openfds_value
echo "=== pmcd.log from _test_pmda ===" >>$seq_full
cat $PCP_LOG_DIR/pmcd/pmcd.log >>$seq_full
}
_test_client()
{
# Test a client
#
echo "=== Testing a Client ===" | tee -a $seq_full
rm -f $tmp.pminfo
pminfo -b 1 -f pmcd.openfds pmcd.client.whoami >$tmp.pminfo
_start_client
pminfo -b 1 -f pmcd.openfds pmcd.client.whoami >>$tmp.pminfo
wait
pminfo -b 1 -f pmcd.openfds pmcd.client.whoami >>$tmp.pminfo
echo "=== pmval output ===" >>$seq_full
cat $tmp.tmp >>$seq_full
echo "=== pminfo output ===" >>$seq_full
cat $tmp.pminfo >>$seq_full
cat $tmp.pminfo | _filter_openfds_value
echo "=== pmcd.log from _test_client ===" >>$seq_full
cat $PCP_LOG_DIR/pmcd/pmcd.log >>$seq_full
}
_test_client
_test_pmda DSO
_test_pmda PIPE
status=0
# success, all done
exit
|