added test to check for deadlock condition in async-written files

Note that this introduces a test case that breaks the current code. This
commit does NOT yet provide the necessary code patch. Thus make check
does currently hang.
This commit is contained in:
Rainer Gerhards 2010-03-17 16:39:18 +01:00
parent ba0f23182a
commit 679434312c
3 changed files with 47 additions and 0 deletions

View File

@ -14,6 +14,7 @@ TESTS = $(TESTRUNS) cfg.sh \
asynwr_small.sh \
asynwr_tinybuf.sh \
asynwr_large.sh \
asynwr_deadlock.sh \
gzipwr_large.sh \
gzipwr_large_dynfile.sh \
complex1.sh \
@ -154,6 +155,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/asynwr_tinybuf.conf \
asynwr_large.sh \
testsuites/asynwr_large.conf \
asynwr_deadlock.sh \
testsuites/asynwr_deadlock.conf \
gzipwr_large.sh \
testsuites/gzipwr_large.conf \
gzipwr_large_dynfile.sh \

23
tests/asynwr_deadlock.sh Executable file
View File

@ -0,0 +1,23 @@
# This is test case from practice, with the version we introduced it, it
# caused a deadlock on shutdown. I have added it to the test suite to automatically
# detect such things in the future.
#
# added 2010-03-17 by Rgerhards
# This file is part of the rsyslog project, released under GPLv3
echo ================================================================================
echo TEST: \[asynwr_deadlock.sh\]: a case known to have caused a deadlock in the past
source $srcdir/diag.sh init
# uncomment for debugging support:
export RSYSLOG_DEBUG="debug nostdout noprintmutexaction"
export RSYSLOG_DEBUGLOG="log"
source $srcdir/diag.sh startup asynwr_deadlock.conf
# just send one message
source $srcdir/diag.sh tcpflood -m1
# sleep is important! need to make sure the instance is inactive
sleep 1
# now try shutdown. The actual test is if the process does hang here!
echo "processing must continue soon"
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh wait-shutdown # and wait for it to terminate
source $srcdir/diag.sh seq-check 0 0
source $srcdir/diag.sh exit

View File

@ -0,0 +1,21 @@
# simple async writing test
# rgerhards, 2010-03-09
$IncludeConfig diag-common.conf
$ModLoad ../plugins/imtcp/.libs/imtcp
$MainMsgQueueTimeoutShutdown 10000
$InputTCPServerRun 13514
$template outfmt,"%msg:F,58:2%\n"
$template dynfile,"rsyslog.out.log" # trick to use relative path names!
$OMFileFlushOnTXEnd on
$OMFileFlushInterval 10
$OMFileFlushIOBufferSize 10k
#:msg, contains, "msgnum:" ?dynfile;outfmt
:msg, contains, "msgnum:" ./rsyslog.out.log;outfmt
$OMFileFlushOnTXEnd on
$OMFileFlushInterval 10
$OMFileFlushIOBufferSize 10k
#:msg, contains, "msgnum:" ./rsyslog.out.2.log;outfmt