testbench: added new tests for failover cases

This commit is contained in:
Rainer Gerhards 2011-06-20 15:57:15 +02:00
parent 656740b663
commit 9fcc6b7285
10 changed files with 130 additions and 52 deletions

View File

@ -18,6 +18,7 @@ TESTS += \
imtcp_conndrop.sh \
imtcp_addtlframedelim.sh \
sndrcv.sh \
sndrcv_failover.sh \
sndrcv_gzip.sh \
sndrcv_udp.sh \
sndrcv_udp_nonstdpt.sh \
@ -52,6 +53,8 @@ TESTS += \
discard-rptdmsg.sh \
discard-allmark.sh \
discard.sh \
failover-async.sh \
failover-double.sh \
failover-basic.sh \
failover-rptd.sh \
failover-no-rptd.sh \
@ -285,6 +288,10 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
failover-basic.sh \
failover-basic-vg.sh \
testsuites/failover-basic.conf \
failover-async.sh \
testsuites/failover-async.conf \
failover-double.sh \
testsuites/failover-double.conf \
discard-rptdmsg.sh \
discard-rptdmsg-vg.sh \
testsuites/discard-rptdmsg.conf \
@ -307,6 +314,10 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
threadingmqaq.sh \
testsuites/threadingmqaq.conf \
sndrcv_drvr.sh \
sndrcv_drvr_noexit.sh \
sndrcv_failover.sh \
testsuites/sndrcv_failover_sender.conf \
testsuites/sndrcv_failover_rcvr.conf \
sndrcv.sh \
testsuites/sndrcv_sender.conf \
testsuites/sndrcv_rcvr.conf \

View File

@ -22,7 +22,7 @@ case $1 in
rm -f work rsyslog.out.log rsyslog2.out.log rsyslog.out.log.save # common work files
rm -rf test-spool test-logdir
rm -f rsyslog.out.*.log work-presort rsyslog.pipe
rm -f rsyslog.input
rm -f rsyslog.input rsyslog.empty
rm -f core.* vgcore.*
mkdir test-spool
;;
@ -31,7 +31,7 @@ case $1 in
rm -f work rsyslog.out.log rsyslog2.out.log rsyslog.out.log.save # common work files
rm -rf test-spool test-logdir
rm -f rsyslog.out.*.log rsyslog.random.data work-presort rsyslog.pipe
rm -f rsyslog.input stat-file1
rm -f rsyslog.input stat-file1 #rsyslog.empty
echo -------------------------------------------------------------------------------
;;
'startup') # start rsyslogd with default params. $2 is the config file name to use

View File

@ -3,7 +3,7 @@ echo ===========================================================================
echo \[failover-async.sh\]: async test for failover functionality
source $srcdir/diag.sh init
source $srcdir/diag.sh startup failover-async.conf
source $srcdir/diag.sh injectmsg 0 5
source $srcdir/diag.sh injectmsg 0 5000
echo doing shutdown
source $srcdir/diag.sh shutdown-when-empty
echo wait on shutdown

12
tests/failover-double.sh Executable file
View File

@ -0,0 +1,12 @@
# This file is part of the rsyslog project, released under GPLv3
echo ===============================================================================
echo \[failover-double.sh\]: test for double failover functionality
source $srcdir/diag.sh init
source $srcdir/diag.sh startup failover-double.conf
source $srcdir/diag.sh injectmsg 0 5000
echo doing shutdown
source $srcdir/diag.sh shutdown-when-empty
echo wait on shutdown
source $srcdir/diag.sh wait-shutdown
source $srcdir/diag.sh seq-check 0 4999
source $srcdir/diag.sh exit

View File

@ -1,50 +1,2 @@
# This is test driver for testing two rsyslog instances. It can be
# utilized by any test that just needs two instances with different
# config files, where messages are injected in instance TWO and
# (with whatever rsyslog mechanism) being relayed over to instance ONE,
# where they are written to the log file. After the run, the completeness
# of that log file is checked.
# The code is almost the same, but the config files differ (probably greatly)
# for different test cases. As such, this driver needs to be called with the
# config file name ($2). From that name, the sender and receiver config file
# names are automatically generated.
# So: $1 config file name, $2 number of messages
#
# A note on TLS testing: the current testsuite (in git!) already contains
# TLS test cases. However, getting these test cases correct is not simple.
# That's not a problem with the code itself, but rater a problem with
# synchronization in the test environment. So I have deciced to keep the
# TLS tests in, but not yet actually utilize them. This is most probably
# left as an excercise for future (devel) releases. -- rgerhards, 2009-11-11
#
# added 2009-11-11 by Rgerhards
# This file is part of the rsyslog project, released under GPLv3
# uncomment for debugging support:
source $srcdir/diag.sh init
# start up the instances
#export RSYSLOG_DEBUG="debug nostdout noprintmutexaction"
#export RSYSLOG_DEBUGLOG="log"
source $srcdir/diag.sh startup $1_rcvr.conf
source $srcdir/diag.sh wait-startup
#export RSYSLOG_DEBUGLOG="log2"
#valgrind="valgrind"
source $srcdir/diag.sh startup $1_sender.conf 2
source $srcdir/diag.sh wait-startup 2
# may be needed by TLS (once we do it): sleep 30
# now inject the messages into instance 2. It will connect to instance 1,
# and that instance will record the data.
source $srcdir/diag.sh tcpflood -m$2 -i1
sleep 2 # make sure all data is received in input buffers
# shut down sender when everything is sent, receiver continues to run concurrently
# may be needed by TLS (once we do it): sleep 60
source $srcdir/diag.sh shutdown-when-empty 2
source $srcdir/diag.sh wait-shutdown 2
# now it is time to stop the receiver as well
source $srcdir/diag.sh shutdown-when-empty
source $srcdir/diag.sh wait-shutdown
# may be needed by TLS (once we do it): sleep 60
# do the final check
source $srcdir/diag.sh seq-check 1 $2
source $srcdir/sndrcv_drvr_noexit.sh $1 $2
source $srcdir/diag.sh exit

49
tests/sndrcv_drvr_noexit.sh Executable file
View File

@ -0,0 +1,49 @@
# This is test driver for testing two rsyslog instances. It can be
# utilized by any test that just needs two instances with different
# config files, where messages are injected in instance TWO and
# (with whatever rsyslog mechanism) being relayed over to instance ONE,
# where they are written to the log file. After the run, the completeness
# of that log file is checked.
# The code is almost the same, but the config files differ (probably greatly)
# for different test cases. As such, this driver needs to be called with the
# config file name ($2). From that name, the sender and receiver config file
# names are automatically generated.
# So: $1 config file name, $2 number of messages
#
# A note on TLS testing: the current testsuite (in git!) already contains
# TLS test cases. However, getting these test cases correct is not simple.
# That's not a problem with the code itself, but rater a problem with
# synchronization in the test environment. So I have deciced to keep the
# TLS tests in, but not yet actually utilize them. This is most probably
# left as an excercise for future (devel) releases. -- rgerhards, 2009-11-11
#
# added 2009-11-11 by Rgerhards
# This file is part of the rsyslog project, released under GPLv3
# uncomment for debugging support:
source $srcdir/diag.sh init
# start up the instances
#export RSYSLOG_DEBUG="debug nostdout noprintmutexaction"
#export RSYSLOG_DEBUGLOG="log"
source $srcdir/diag.sh startup $1_rcvr.conf
source $srcdir/diag.sh wait-startup
#export RSYSLOG_DEBUGLOG="log2"
#valgrind="valgrind"
source $srcdir/diag.sh startup $1_sender.conf 2
source $srcdir/diag.sh wait-startup 2
# may be needed by TLS (once we do it): sleep 30
# now inject the messages into instance 2. It will connect to instance 1,
# and that instance will record the data.
source $srcdir/diag.sh tcpflood -m$2 -i1
sleep 2 # make sure all data is received in input buffers
# shut down sender when everything is sent, receiver continues to run concurrently
# may be needed by TLS (once we do it): sleep 60
source $srcdir/diag.sh shutdown-when-empty 2
source $srcdir/diag.sh wait-shutdown 2
# now it is time to stop the receiver as well
source $srcdir/diag.sh shutdown-when-empty
source $srcdir/diag.sh wait-shutdown
# may be needed by TLS (once we do it): sleep 60
# do the final check
source $srcdir/diag.sh seq-check 1 $2

21
tests/sndrcv_failover.sh Executable file
View File

@ -0,0 +1,21 @@
# This tests failover capabilities. Data is sent to local port 13516, where
# no process shall listen. Then it fails over to a second instance, then to
# a file. The second instance is started. So all data should be received
# there and none be logged to the file.
# This builds on the basic sndrcv.sh test, but adds a first, failing,
# location to the conf file.
# added 2011-06-20 by Rgerhards
# This file is part of the rsyslog project, released under GPLv3
echo ===============================================================================
echo \[sndrcv_failover.sh\]: testing failover capabilities for tcp sending
source $srcdir/sndrcv_drvr_noexit.sh sndrcv_failover 50000
ls -l rsyslog.empty
if [[ -s rsyslog.empty ]] ; then
echo "FAIL: rsyslog.empty has data. Failover handling failed. Data is written"
echo " even though the previous action (in a failover chain!) properly"
echo " worked."
exit 1
else
echo "rsyslog.empty is empty - OK"
fi ;
source $srcdir/diag.sh exit

View File

@ -0,0 +1,9 @@
$IncludeConfig diag-common.conf
$template outfmt,"%msg:F,58:2%\n"
:msg, contains, "msgnum:" @@127.0.0.1:13516
$ActionExecOnlyWhenPreviousIsSuspended on
& @@127.0.0.1:1234
& ./rsyslog.out.log;outfmt
$ActionExecOnlyWhenPreviousIsSuspended off

View File

@ -0,0 +1,11 @@
# see equally-named shell file for details
# rgerhards, 2009-11-11
$IncludeConfig diag-common.conf
$ModLoad ../plugins/imtcp/.libs/imtcp
# then SENDER sends to this port (not tcpflood!)
$InputTCPServerRun 13515
$template outfmt,"%msg:F,58:2%\n"
$template dynfile,"rsyslog.out.log" # trick to use relative path names!
:msg, contains, "msgnum:" ?dynfile;outfmt

View File

@ -0,0 +1,13 @@
# see tcpsndrcv.sh for details
# rgerhards, 2009-11-11
$IncludeConfig diag-common2.conf
$ModLoad ../plugins/imtcp/.libs/imtcp
# this listener is for message generation by the test framework!
$InputTCPServerRun 13514
*.* @@127.0.0.1:13516 # this must be DEAD
$ActionExecOnlyWhenPreviousIsSuspended on
& @@127.0.0.1:13515
& ./rsyslog.empty
$ActionExecOnlyWhenPreviousIsSuspended off