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
|
#!/bin/sh
# PCP QA Test No. 1896
# test pmlogger SIGUSR2/reexec handling and strftime substitution
#
# Copyright (c) 2020 Red Hat. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
. ./common.secure
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.* Latest
}
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
mkdir -p $tmp
PMLOGGER=$PCP_BIN_DIR/pmlogger
spec=qa-$seq-%Y%m%d.%H.%M
echo == checking strftime archive name substitution | tee -a $seq_full
base=`pmdate $spec`
nextbase=`pmdate +1M $spec`
$PMLOGGER -s20 -t 1s -c config.default -l $tmp/pmlogger.log $tmp/$spec 2>$tmp/$seq.err &
pid=$!; sleep 5; kill -TERM $pid
echo === log === >>$seq_full; cat $tmp/pmlogger.log >>$seq_full
echo === err === >>$seq_full; cat $tmp/$seq.err >>$seq_full
if [ -f $tmp/$base.index ]
then
echo "found base: `ls -l $tmp/$base.index`" >>$seq_full
elif [ -f $nextbase.index ]
then
echo "found nextbase: `ls -l $tmp/$nextbase.index`" >>$seq_full
else
echo "FAILED, expected $base.index or $nextbase.index" | tee -a $seq_full
ls -l $tmp >>$seq_full
exit
fi
echo == checking SIGUSR2 starts a new log as non-root user | tee -a $seq_full
base=`pmdate $spec`
nextbase=`pmdate +1M $spec`
$PMLOGGER -U$username -s30 -t 1s -c config.default -l $tmp/pmlogger.log $tmp/$spec 2>$tmp/$seq.err &
pid=$!; sleep 5;
$sudo -u $username kill -USR2 $pid; sleep 5
echo === log === >>$seq_full; cat $tmp/pmlogger.log >>$seq_full
echo === err === >>$seq_full; cat $tmp/$seq.err >>$seq_full
if [ -f $tmp/$base.index ]
then
echo "found 1st base: `ls -l $tmp/$base.index`" >>$seq_full
elif [ -f $nextbase.index ]
then
echo "found 1st nextbase: `ls -l $tmp/$nextbase.index`" >>$seq_full
else
echo "FAILED, expected to find 1st $base.index or $nextbase.index" | tee -a $seq_full
ls -l $tmp >>$seq_full
exit
fi
if [ -f $tmp/$base-00.index ]
then
echo "found 2nd base: `ls -l $tmp/$base-00.index`" >>$seq_full
elif [ -f $nextbase.index ]
then
echo "found 2nd nextbase: `ls -l $tmp/$nextbase.index`" >>$seq_full
elif [ -f $nextbase-00.index ]
then
echo "found 2nd nextbase: `ls -l $tmp/$nextbase-00.index`" >>$seq_full
else
echo "FAILED, expected to find 2nd $base-00.index or $nextbase.index or $nextbase-00.index" | tee -a $seq_full
ls -l $tmp >>$seq_full
exit
fi
echo == check pmlc can connect to pmlogger after reexec
(echo status | pmlc $pid >>$seq_full) || echo pmlc failed to connect to pid $pid
# kill it off
$sudo -u $username kill -TERM $pid
# success, all done
status=0
exit
|