3 # Test for Bug #660497, change openfds metric to be the
4 # largest known file descriptor used by pmcd.
5 # This means the file descriptor can only ever increase.
6 # The following behaviour is expected:
7 # the file descriptor will increase when a client or pmda connects
8 # the file descriptor will stay the same when a client or pmda disconnects
10 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
14 echo "QA output created by $seq"
16 # get standard filters
22 if [ $PCP_VER -lt 30600 ]
24 ln $seq.out
.1 $seq.out ||
exit 1
26 ln $seq.out
.2 $seq.out ||
exit 1
29 status
=1 # failure is the default!
30 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
33 signal
=$PCP_BINADM_DIR/pmsignal
44 pmval
-T 10sec kernel.all.load
>$tmp.tmp
2>&1 &
45 echo "=== Started client ===" |
tee -a $here/$seq.full
49 # Remove the PMDA and restore pmcd.conf
53 [ -f $PCP_PMDAS_DIR/simple
/simple.conf.
$seq ] && _restore_config
$PCP_PMDAS_DIR/simple
/simple.conf
55 if [ -f $PCP_PMCDCONF_PATH.
$seq ]
57 echo "=== Resetting pmcd.conf back to original state ==="
58 _restore_config
$PCP_PMCDCONF_PATH
59 _restore_config
$PCP_VAR_DIR/pmns
/root
60 echo "=== Restart PMCD ==="
62 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
66 if grep '^simple' $PCP_PMCDCONF_PATH >/dev
/null
70 # simple was not installed, cull namespace
72 cd $PCP_PMDAS_DIR/simple
73 $sudo .
/Remove
>/dev
/null
78 echo '=== pmcd log' >>$here/$seq.full
79 cat $tmp.log
>>$here/$seq.full
85 trap "_cleanup; exit \$status" 0 1 2 3 15
90 -e 's/.* \(hash table entries\)/ NNN \1/' \
91 -e 's/.* \(non-leaf nodes\)/ NNN \1/' \
92 -e 's/.* \(leaf nodes\)/ NNN \1/' \
93 -e 's/.* \(bytes of symbol table\)/ NNN \1/'
102 _filter_openfds_value
()
105 BEGIN { fst_fds = "fst_fds"; sec_fds = "sec_fds"; thr_fds = "thr_fds"; step = 0 }
106 $1 == "value" && step == 0 {
107 fst_fds = $2; step = 1; next }
108 $1 == "value" && step == 1 {
109 sec_fds = $2; step = 2; next }
110 $1 == "value" && step == 2 {
112 if (sec_fds > fst_fds)
113 printf("=== Info: After install, openfds has increased as expected ===\n");
115 printf("=== Error: After install, openfds has unexpectedly decreased or stayed the same ===\n");
116 printf("\t previous value %d, current value %d\n", fst_fds, sec_fds);
118 if (sec_fds == thr_fds)
119 printf("=== Info: After remove, openfds has stayed the same as expected ===\n");
121 printf("=== Error: After remove, openfds has unexpectedly changed ===\n")
122 printf("\t previous value %d, current value %d\n", sec_fds, thr_fds);
129 # no random clients, thanks
131 port
=`_get_port tcp 6060 6070`
134 echo "Arrggh ... no free TCP port in the range 6060 ... 6070"
143 echo "=== Building simple agent ===" |
tee -a $here/$seq.full
144 unset ROOT TOOLROOT MAKEFLAGS
145 cd $PCP_PMDAS_DIR/simple
147 # get rid of warnings from simple if no config exists
148 [ -f simple.conf
] && _save_config simple.conf
149 echo "sec,min,hour" >$tmp.simple.conf
150 $sudo cp $tmp.simple.conf simple.conf
152 # Install the simple namespace, I don't bother to remove it again
154 $sudo .
/Install
-N < /dev
/null | _filter_ins
2>&1
155 echo "Namespace installed"
157 if $sudo make > $tmp.
make 2>&1
161 echo "Unable to build the simple PMDA:"
166 sed -e "/^@ SIMPLE/s/SIMPLE/$simple_domain/" < help \
167 |
$sudo $PCP_BINADM_DIR/newhelp
-v 2 -o help
168 echo "Help generated"
175 echo "=== Restarting PMCD with minimal PMDAs ===" |
tee -a $here/$seq.full
176 if [ -f $tmp.newconf
]
178 $sudo cp $tmp.newconf
$PCP_PMCDCONF_PATH
179 $sudo $signal -a -s HUP pmcd
183 echo caller
- $1 - has not created
$tmp.newconf
!!!
187 # Install a standard pmda, but do not mess with the namespace
194 path
=$PCP_PMDAS_DIR/$agent
196 echo "=== Installing $agent ===" |
tee -a $here/$seq.full
197 cp $tmp.newconf
$tmp.latest
200 cat << end-of-file >> $tmp.latest
201 $agent $domain pipe binary $path/pmda$agent -d $domain
204 cat << end-of-file >> $tmp.latest
205 $agent $domain dso ${agent}_init $path/${style}pmda_$agent.$DSO_SUFFIX
209 $sudo cp $tmp.latest
$PCP_PMCDCONF_PATH
211 $sudo $signal -a -s HUP pmcd
215 if _check_agent
$agent true
217 echo "$agent is alive and well"
219 echo "Failed to install $agent"
230 echo "=== Removing $agent ===" |
tee -a $here/$seq.full
231 _renew_pmcd _agent_remove
233 if _check_agent
$agent true
235 echo "Failed to remove $agent"
238 echo "$agent was removed"
242 # real QA test starts here
244 # Copy and replace pmcd.conf
246 _save_config
$PCP_PMCDCONF_PATH
247 _save_config
$PCP_VAR_DIR/pmns
/root
249 if [ $PCP_PLATFORM = linux
]
251 cat << end-of-file > $tmp.newconf
252 # pmcd.conf generated by QA $seq
253 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
254 linux 60 dso linux_init $PCP_PMDAS_DIR/linux/pmda_linux.so
256 elif [ $PCP_PLATFORM = irix
]
258 cat << end-of-file > $tmp.newconf
259 # pmcd.conf generated by QA $seq
260 irix 1 dso irix_init libirixpmda.so
261 pmcd 2 dso pmcd_init pmda_pmcd.so
262 proc 3 dso proc_init pmda_proc.so
264 elif [ $PCP_PLATFORM = darwin
]
266 cat << end-of-file > $tmp.newconf
267 # pmcd.conf generated by QA $seq
268 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.dylib
269 darwin 78 dso darwin_init $PCP_PMDAS_DIR/darwin/pmda_darwin.dylib
271 elif [ $PCP_PLATFORM = solaris
]
273 cat << end-of-file > $tmp.newconf
274 # pmcd.conf generated by QA $seq
275 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
276 solaris 75 dso solaris_init $PCP_PMDAS_DIR/solaris/pmda_solaris.so
279 echo "Arrgh ... need pmcd.conf output for $PCP_PLATFORM"
285 if [ -f $tmp.newconf
]
287 $sudo cp $tmp.newconf
$PCP_PMCDCONF_PATH
290 # Start with a fresh pmcd log
292 # need to do this indirectly because system sudo cleanses the environment
294 echo "export PMCD_PORT=$PMCD_PORT" >$tmp.start
295 echo "$PCP_RC_DIR/pcp restart" >>$tmp.start
296 $sudo sh
$tmp.start | _filter_pcp_start | _filter_init
2>&1
306 echo "=== Testing PMDA as a $pmda_type ===" |
tee -a $here/$seq.full
310 pminfo
-f pmcd.openfds
>$tmp.pminfo
311 fst_openfds
=$openfds_value
313 if [ "$pmda_type" != PIPE
]
315 _agent_install simple
$simple_domain false
317 _agent_install simple
$simple_domain true
320 pminfo
-f pmcd.openfds
>>$tmp.pminfo
323 pminfo
-f pmcd.openfds
>>$tmp.pminfo
325 echo "=== pminfo output ===" >>$here/$seq.full
326 cat $tmp.pminfo
>>$here/$seq.full
328 cat $tmp.pminfo | _filter_openfds_value
330 echo "=== pmcd.log from _test_pmda ===" >>$here/$seq.full
331 cat $PCP_LOG_DIR/pmcd
/pmcd.log
>>$here/$seq.full
338 echo "=== Testing a Client ===" |
tee -a $here/$seq.full
342 pminfo
-f pmcd.openfds
>$tmp.pminfo
345 pminfo
-f pmcd.openfds
>>$tmp.pminfo
348 pminfo
-f pmcd.openfds
>>$tmp.pminfo
350 echo "=== pmval output ===" >>$here/$seq.full
351 cat $tmp.tmp
>>$here/$seq.full
352 echo "=== pminfo output ===" >>$here/$seq.full
353 cat $tmp.pminfo
>>$here/$seq.full
355 cat $tmp.pminfo | _filter_openfds_value
357 echo "=== pmcd.log from _test_client ===" >>$here/$seq.full
358 cat $PCP_LOG_DIR/pmcd
/pmcd.log
>>$here/$seq.full