testbench: sometimes an instance hangs at end of test

shutdown detection was based on pid file, we should check the
actual pid. We can't use wait, because we want to be able to
timeout. This patch should fairly portable handle the situation.

closes https://github.com/rsyslog/rsyslog/issues/1005
This commit is contained in:
Rainer Gerhards 2016-05-03 18:14:02 +02:00
parent 5b263a448d
commit de80ab60c3

View File

@ -215,7 +215,20 @@ case $1 in
'wait-shutdown') # actually, we wait for rsyslog.pid to be deleted. $2 is the
# instance
i=0
while test -f rsyslog$2.pid; do
ls -l rsyslog*
out_pid=`cat rsyslog$2.pid.save`
if [[ "x$out_pid" == "x" ]]
then
terminated=1
else
terminated=0
fi
while [[ $terminated -eq 0 ]]; do
ps -p $out_pid
if [[ $? != 0 ]]
then
terminated=1
fi
./msleep 100 # wait 100 milliseconds
let "i++"
if test $i -gt $TB_TIMEOUT_STARTSTOP
@ -226,6 +239,8 @@ case $1 in
exit 1
fi
done
unset terminated
unset out_pid
if [ -e core.* ]
then
echo "ABORT! core file exists"
@ -234,7 +249,7 @@ case $1 in
;;
'wait-shutdown-vg') # actually, we wait for rsyslog.pid to be deleted. $2 is the
# instance
wait `cat rsyslog.pid`
wait `cat rsyslog$2.pid`
export RSYSLOGD_EXIT=$?
echo rsyslogd run exited with $RSYSLOGD_EXIT
if [ -e vgcore.* ]
@ -284,11 +299,13 @@ case $1 in
echo Shutting down instance 2
fi
. $srcdir/diag.sh wait-queueempty $2
cp -v rsyslog$2.pid rsyslog$2.pid.save
./msleep 1000 # wait a bit (think about slow testbench machines!)
kill `cat rsyslog$2.pid`
# note: we do not wait for the actual termination!
;;
'shutdown-immediate') # shut rsyslogd down without emptying the queue. $2 is the instance.
cp rsyslog$2.pid rsyslog$2.pid.save
kill `cat rsyslog.pid`
# note: we do not wait for the actual termination!
;;