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
|
#! /bin/sh
# PCP QA Test No. 462
# For pv #581025, pv #589006
#
# Test out pmcd_wait
#
# Test:
# * Success:
#1 - try on already running pmcd
# * Failure:
#2 - pmcd not running at all
#3 - pmcd running but taking too long to get around to
# accepting connections
# * Wait delta:
#4 - delta = X, have pmcd dead for X-1 seconds
#5 - delta = X, have pmcd dead for X+1 seconds
#
# 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
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
host=`hostname`
_cleanup()
{
_change_config pmlogger on
_service pmcd restart 2>&1 | _filter_pcp_restart
_wait_for_pmcd
_restore_auto_restart pmcd
_service pmlogger restart 2>&1 | _filter_pcp_restart
_wait_for_pmlogger
_restore_auto_restart pmlogger
rm -f $tmp.*
}
_filter()
{
_filter_pcp_start \
| _filter_pcp_stop \
| sed -e '/^$PCP_RC_DIR\/pmlogger: pmlogger not running/d'
}
_wait_filter()
{
sed \
-e "s/$host/LOCALHOST/g" \
-e "s/unix:/LOCALHOST/g" \
-e "s/local:/LOCALHOST/g" \
#end
}
_start()
{
echo "restart @ `date` ..." >>$seq_full
$sudo $PCP_RC_DIR/pmcd restart >$tmp.start.out
echo "restart log @ `date` ..." >>$seq_full
cat $tmp.start.out >>$seq_full
_wait_for_pmcd || _exit 1
}
_stop()
{
echo "stop @ `date`..." >>$seq_full
$sudo $PCP_RC_DIR/pmcd stop >$tmp.stop.out
echo "stop log @ `date` ..." >>$seq_full
cat $tmp.stop.out >>$seq_full
}
# real QA test starts here
_change_config pmlogger off || _exit 1
_stop_auto_restart pmlogger
if ! _service pmlogger stop 2>&1; then _exit 1; fi \
| _filter_pcp_stop
_wait_pmlogger_end || _exit 1
if ! _service pmcd stop 2>&1; then _exit 1; fi \
| _filter_pcp_stop
_wait_pmcd_end || _exit 1
delta=10
pre_delta=5
post_delta=15
echo "*** test 1 ***" | tee -a $seq_full
_start
sleep 2
if pmcd_wait -v 2>$tmp.err
then
echo ""
echo "pmcd_wait succeeded as expected for running pmcd"
echo ""
else
_wait_filter < $tmp.err
fi
_filter <$tmp.start.out
echo "*** test 2 ***" | tee -a $seq_full
_stop
sleep 2
if pmcd_wait -v -t $delta 2>$tmp.err
then
echo ""
echo "ERROR: pmcd_wait should not have succeeded !" | tee -a $seq_full
echo ""
else
_wait_filter < $tmp.err
echo ""
echo "pmcd_wait failed as expected for dead pmcd"
echo ""
fi
_filter <$tmp.stop.out
echo "*** test 4 ***" | tee -a $seq_full
_stop
sleep 2
rm -f $tmp.done
( sleep $pre_delta; _start; touch $tmp.done ) &
if pmcd_wait -v -t $delta 2>$tmp.err
then
echo ""
echo "pmcd_wait succeeded as expected for sleeping pmcd - under timeout"
echo ""
else
echo ""
echo "ERROR: pmcd_wait should have succeeded !" | tee -a $seq_full
echo ""
_wait_filter < $tmp.err
fi
# Need to wait until _start is _really_ done and pmcd.log has been
# reported
for i in 1 2 3 4 5
do
[ -f $tmp.done ] && break
sleep 1
done
if [ ! -f $tmp.done ]
then
echo "Arrgh @ `date` ... _start is really dragging the chain ... check $seq.full" | tee -a $seq_full
status=1
exit
fi
_filter <$tmp.stop.out \
| sed -e '/pmlogger not running/d'
_filter <$tmp.start.out
echo "*** test 5 ***" | tee -a $seq_full
_stop
sleep 2
(sleep $post_delta; _start ) &
pid=$!
if pmcd_wait -v -t $delta 2>$tmp.err
then
echo ""
echo "ERROR: pmcd_wait should not have succeeded !" | tee -a $seq_full
echo ""
else
_wait_filter < $tmp.err
echo ""
echo "pmcd_wait failed as expected for sleeping pmcd - over timeout"
echo ""
fi
_filter <$tmp.stop.out \
| sed -e '/pmlogger not running/d'
_filter <$tmp.start.out
wait $pid # for background processs, "pcp start" to finish
# success, all done
status=0
exit
|