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
|
#! /bin/sh
# PCP QA Test No. 603
# PCP 2.2 duplicate of 349 (pmdatrace, pmtrace, and libpcp_trace tests)
#
# 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/trace ] || _notrun "trace PMDA directory is not installed"
[ "`hostname`" = vm28.localdomain ] && _notrun "ssh to pcpqa@vm16 does not work here"
signal=$PCP_BINADM_DIR/pmsignal
status=1 # failure is the default!
_cleanup()
{
cd $here
if [ -n "$savedtracehost" ]
then
PCP_TRACE_HOST=$savedtracehost; export PCP_TRACE_HOST
fi
if $_needclean
then
if $install_on_cleanup
then
( cd $PCP_PMDAS_DIR/trace; $sudo ./Install </dev/null >/dev/null 2>&1 )
else
( cd $PCP_PMDAS_DIR/trace; $sudo ./Remove </dev/null >/dev/null 2>&1 )
fi
_needclean=false
fi
rm -f $tmp.*
exit $status
}
_filter_trace_install()
{
# some warnings are *expected* - no trace values yet
tee -a $seq_full | \
_filter_pmda_install | sed \
-e 's/ *[0-9]+ warnings,//g' \
-e "s/$qahost/HOSTNAME/g"
}
install_on_cleanup=false
pminfo trace >/dev/null 2>&1 && install_on_cleanup=true
_needclean=true
trap "_cleanup" 0 1 2 3 15
if [ -n "$PCP_TRACE_HOST" ]
then
savedtracehost=$PCP_TRACE_HOST; unset PCP_TRACE_HOST
fi
qahost=`_get_fqdn`
otherhost=`./getpmcdhosts -L -n 1 2>$tmp.out`
[ -z "$otherhost" ] && _notrun `cat $tmp.out`
qanet=`_host_to_ipaddr $otherhost | sed -e 's/[0-9][0-9]*$/*/'`
echo "qahost=$qahost" >$seq_full
echo "qanet=$qanet" >>$seq_full
echo "otherhost=$otherhost" >>$seq_full
cat > $tmp.conf1 << EOF
n
60
10
4323
y
y
D
$qahost
EOF
cat > $tmp.conf2 << EOF
n
60
10
4323
y
y
D
$qanet
A
$qahost
1
EOF
# real QA test starts here
cd $PCP_PMDAS_DIR/trace
echo >>$seq_full
echo "=== first local trace PMDA config ===" >>$seq_full
cat $tmp.conf1 >>$seq_full
echo "===" >>$seq_full
$sudo ./Install -R / < $tmp.conf1 2>&1 \
| _filter_trace_install
_wait_for_pmcd || _exit 1
grep trace $PCP_PMCDCONF_PATH >>$seq_full
echo '=== Attempting bad local access ==='
echo "=== Attempting bad local access ===" >>$seq_full
# Error message mapping is for Linux
#
pmtrace -h $qahost $qahost 2>&1 \
| tee -a $seq_full \
| sed \
-e "s/Connection reset by peer/Cannot connect to PMDA - permission denied/" \
-e "s/Connection refused/Cannot connect to PMDA - permission denied/"
if [ -f $PCP_LOG_DIR/pmcd/trace.log ]
then
cat $PCP_LOG_DIR/pmcd/trace.log >>$seq_full
elif [ -f $PCP_LOG_DIR/trace.log ]
then
cat $PCP_LOG_DIR/trace.log >>$seq_full
else
echo "Arrggh! Cannot find log for trace PMDA!" >>$seq_full
fi
echo
echo >>$seq_full
echo "=== second local trace PMDA config ===" >>$seq_full
cat $tmp.conf2 >>$seq_full
echo "===" >>$seq_full
$sudo ./Install -R / < $tmp.conf2 2>&1 \
| _filter_trace_install
_wait_for_pmcd || _exit 1
grep trace $PCP_PMCDCONF_PATH >>$seq_full
echo '=== Building demo program (app2) ==='
cd $PCP_DEMOS_DIR/trace
$sudo $PCP_MAKE_PROG app2 >$tmp.make 2>&1
if [ $? -ne 0 ]
then
echo "trace app2 make failed. Here is the make output ..."
cat $tmp.make
exit 1
fi
PCP_TRACE_HOST=$qahost; export PCP_TRACE_HOST
echo '=== Running demo program (app2) ==='
# use app2 process to bump the number of connections.
( ( $PCP_DEMOS_DIR/trace/app2 2>&1 >$tmp.out & ) )
sleep 3
echo '=== Check access limits ==='
echo "=== Check access limits ===" >>$seq_full
# Error message mapping is for Linux
#
pmtrace -h $qahost 'limit exceeded' 2>&1 \
| tee -a $seq_full \
| sed \
-e "s/Connection reset by peer/Cannot connect to PMDA - connection limit reached/"
$signal -a -s KILL app2
wait
echo "=== app2 ===" >>$seq_full
cat $tmp.out >>$seq_full
unset PCP_TRACE_HOST
echo '=== Attempting bad remote access ==='
echo "=== Attempting bad remote access ===" >>$seq_full
# Error message mapping is for Linux
#
ssh -q pcpqa@$otherhost "sh -c 'PCP_TRACE_HOST=$qahost pmtrace -v 1 eek'" 2>&1 \
| tee -a $seq_full \
| sed \
-e "s/Interrupted function call/Cannot connect to PMDA - permission denied/" \
-e "s/Connection refused/Cannot connect to PMDA - permission denied/" \
-e "s/Connection reset by peer/Cannot connect to PMDA - permission denied/" \
# end
if [ -f $PCP_LOG_DIR/pmcd/trace.log ]
then
cat $PCP_LOG_DIR/pmcd/trace.log >>$seq_full
elif [ -f $PCP_LOG_DIR/trace.log ]
then
cat $PCP_LOG_DIR/trace.log >>$seq_full
else
echo "Arrggh! Cannot find log for trace PMDA!" >>$seq_full
fi
echo
# Reinstall defaults
echo >>$seq_full
echo "=== Reinstall default config ===" >>$seq_full
cd $PCP_PMDAS_DIR/trace
$sudo ./Install -R / < /dev/null 2>&1 \
| _filter_trace_install
_wait_for_pmcd || _exit 1
cd $here
# success, all done
status=0
exit
|