From ce1860a0bc77ec2ba7992547776a46df6b3d0e8a Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 16 Mar 2011 14:40:36 +0100 Subject: bugfix: failover did not work correctly if repeated msg reduction was on affected directive was: $ActionExecOnlyWhenPreviousIsSuspended on --- tests/Makefile.am | 9 +++++++++ tests/diag.sh | 2 +- tests/failover-async.sh | 12 ++++++++++++ tests/failover-basic.sh | 12 ++++++++++++ tests/failover-no-rptd.sh | 19 +++++++++++++++++++ tests/failover-rptd.sh | 12 ++++++++++++ tests/testsuites/failover-async.conf | 9 +++++++++ tests/testsuites/failover-basic.conf | 8 ++++++++ tests/testsuites/failover-no-rptd.conf | 9 +++++++++ tests/testsuites/failover-rptd.conf | 10 ++++++++++ 10 files changed, 101 insertions(+), 1 deletion(-) create mode 100755 tests/failover-async.sh create mode 100755 tests/failover-basic.sh create mode 100755 tests/failover-no-rptd.sh create mode 100755 tests/failover-rptd.sh create mode 100644 tests/testsuites/failover-async.conf create mode 100644 tests/testsuites/failover-basic.conf create mode 100644 tests/testsuites/failover-no-rptd.conf create mode 100644 tests/testsuites/failover-rptd.conf (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 03a4985a..3ca8efca 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -48,6 +48,9 @@ TESTS = $(TESTRUNS) cfg.sh \ dircreate_off.sh \ discard-rptdmsg.sh \ discard.sh \ + failover-basic.sh \ + failover-rptd.sh \ + failover-no-rptd.sh \ queue-persist.sh if ENABLE_IMPTCP @@ -217,6 +220,12 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \ omod-if-array.sh \ discard.sh \ testsuites/discard.conf \ + failover-no-rptd.sh \ + testsuites/failover-no-rptd.conf \ + failover-rptd.sh \ + testsuites/failover-rptd.conf \ + failover-basic.sh \ + testsuites/failover-basic.conf \ discard-rptdmsg.sh \ testsuites/discard-rptdmsg.conf \ diag.sh \ diff --git a/tests/diag.sh b/tests/diag.sh index bf12fbda..fc0d9000 100755 --- a/tests/diag.sh +++ b/tests/diag.sh @@ -10,7 +10,7 @@ #valgrind="valgrind --tool=helgrind --log-fd=1" #valgrind="valgrind --tool=exp-ptrcheck --log-fd=1" #set -o xtrace -#export RSYSLOG_DEBUG="debug nostdout" +#export RSYSLOG_DEBUG="debug nologfuncflow nostdout" #export RSYSLOG_DEBUGLOG="log" case $1 in 'init') $srcdir/killrsyslog.sh # kill rsyslogd if it runs for some reason diff --git a/tests/failover-async.sh b/tests/failover-async.sh new file mode 100755 index 00000000..f17bc0ff --- /dev/null +++ b/tests/failover-async.sh @@ -0,0 +1,12 @@ +# This file is part of the rsyslog project, released under GPLv3 +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 +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 diff --git a/tests/failover-basic.sh b/tests/failover-basic.sh new file mode 100755 index 00000000..031ea25b --- /dev/null +++ b/tests/failover-basic.sh @@ -0,0 +1,12 @@ +# This file is part of the rsyslog project, released under GPLv3 +echo =============================================================================== +echo \[failover-basic.sh\]: basic test for failover functionality +source $srcdir/diag.sh init +source $srcdir/diag.sh startup failover-basic.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 diff --git a/tests/failover-no-rptd.sh b/tests/failover-no-rptd.sh new file mode 100755 index 00000000..6abeba44 --- /dev/null +++ b/tests/failover-no-rptd.sh @@ -0,0 +1,19 @@ +# This file is part of the rsyslog project, released under GPLv3 +echo =============================================================================== +echo \[failover-no-rptd.sh\]: rptd test for failover functionality - no failover +source $srcdir/diag.sh init +source $srcdir/diag.sh startup failover-no-rptd.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 +# now we need our custom logic to see if the result file is empty +# (what it should be!) +cmp rsyslog.out.log /dev/null +if [ $? -eq 1 ] +then + echo "ERROR, output file not empty" + exit 1 +fi +source $srcdir/diag.sh exit diff --git a/tests/failover-rptd.sh b/tests/failover-rptd.sh new file mode 100755 index 00000000..8a313e9e --- /dev/null +++ b/tests/failover-rptd.sh @@ -0,0 +1,12 @@ +# This file is part of the rsyslog project, released under GPLv3 +echo =============================================================================== +echo \[failover-rptd.sh\]: rptd test for failover functionality +source $srcdir/diag.sh init +source $srcdir/diag.sh startup failover-rptd.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 diff --git a/tests/testsuites/failover-async.conf b/tests/testsuites/failover-async.conf new file mode 100644 index 00000000..76445de3 --- /dev/null +++ b/tests/testsuites/failover-async.conf @@ -0,0 +1,9 @@ +# see the equally-named .sh file for details +$IncludeConfig diag-common.conf + +$template outfmt,"%msg:F,58:2%\n" +# note: the target server shall not be available! + +$ActionQueueType LinkedList +:msg, contains, "msgnum:" @@127.0.0.1:13514 +& ./rsyslog.out.log;outfmt diff --git a/tests/testsuites/failover-basic.conf b/tests/testsuites/failover-basic.conf new file mode 100644 index 00000000..a858769c --- /dev/null +++ b/tests/testsuites/failover-basic.conf @@ -0,0 +1,8 @@ +# see the equally-named .sh file for details +$IncludeConfig diag-common.conf + +$template outfmt,"%msg:F,58:2%\n" +# note: the target server shall not be available! +:msg, contains, "msgnum:" @@127.0.0.1:13514 +$ActionExecOnlyWhenPreviousIsSuspended on +& ./rsyslog.out.log;outfmt diff --git a/tests/testsuites/failover-no-rptd.conf b/tests/testsuites/failover-no-rptd.conf new file mode 100644 index 00000000..a46ce116 --- /dev/null +++ b/tests/testsuites/failover-no-rptd.conf @@ -0,0 +1,9 @@ +# see the equally-named .sh file for details +$IncludeConfig diag-common.conf + +$RepeatedMsgReduction on + +# second action should never execute +:msg, contains, "msgnum:" /dev/null +$ActionExecOnlyWhenPreviousIsSuspended on +& ./rsyslog.out.log diff --git a/tests/testsuites/failover-rptd.conf b/tests/testsuites/failover-rptd.conf new file mode 100644 index 00000000..d3553dbb --- /dev/null +++ b/tests/testsuites/failover-rptd.conf @@ -0,0 +1,10 @@ +# see the equally-named .sh file for details +$IncludeConfig diag-common.conf + +$RepeatedMsgReduction on + +$template outfmt,"%msg:F,58:2%\n" +# note: the target server shall not be available! +:msg, contains, "msgnum:" @@127.0.0.1:13514 +$ActionExecOnlyWhenPreviousIsSuspended on +& ./rsyslog.out.log;outfmt -- cgit From 9e18ecc9bd14093b78199fd36c315cfce4d26a26 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 16 Mar 2011 15:04:43 +0100 Subject: fixed a regression of last patch and some cleanup --- tests/Makefile.am | 3 +++ tests/diag.sh | 2 +- tests/failover-no-basic.sh | 19 +++++++++++++++++++ tests/testsuites/failover-no-basic.conf | 9 +++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 tests/failover-no-basic.sh create mode 100644 tests/testsuites/failover-no-basic.conf (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 3ca8efca..137e2115 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -51,6 +51,7 @@ TESTS = $(TESTRUNS) cfg.sh \ failover-basic.sh \ failover-rptd.sh \ failover-no-rptd.sh \ + failover-no-basic.sh \ queue-persist.sh if ENABLE_IMPTCP @@ -222,6 +223,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \ testsuites/discard.conf \ failover-no-rptd.sh \ testsuites/failover-no-rptd.conf \ + failover-no-basic.sh \ + testsuites/failover-no-basic.conf \ failover-rptd.sh \ testsuites/failover-rptd.conf \ failover-basic.sh \ diff --git a/tests/diag.sh b/tests/diag.sh index fc0d9000..3075aa57 100755 --- a/tests/diag.sh +++ b/tests/diag.sh @@ -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 + rm -f rsyslog.input stat-file1 echo ------------------------------------------------------------------------------- ;; 'startup') # start rsyslogd with default params. $2 is the config file name to use diff --git a/tests/failover-no-basic.sh b/tests/failover-no-basic.sh new file mode 100755 index 00000000..6177e10d --- /dev/null +++ b/tests/failover-no-basic.sh @@ -0,0 +1,19 @@ +# This file is part of the rsyslog project, released under GPLv3 +echo =============================================================================== +echo \[failover-no-basic.sh\]: basic test for failover functionality - no failover +source $srcdir/diag.sh init +source $srcdir/diag.sh startup failover-no-basic.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 +# now we need our custom logic to see if the result file is empty +# (what it should be!) +cmp rsyslog.out.log /dev/null +if [ $? -eq 1 ] +then + echo "ERROR, output file not empty" + exit 1 +fi +source $srcdir/diag.sh exit diff --git a/tests/testsuites/failover-no-basic.conf b/tests/testsuites/failover-no-basic.conf new file mode 100644 index 00000000..b40ef7d7 --- /dev/null +++ b/tests/testsuites/failover-no-basic.conf @@ -0,0 +1,9 @@ +# see the equally-named .sh file for details +$IncludeConfig diag-common.conf + +$RepeatedMsgReduction off + +# second action should never execute +:msg, contains, "msgnum:" /dev/null +$ActionExecOnlyWhenPreviousIsSuspended on +& ./rsyslog.out.log -- cgit From 4a80242ffcfa93348453ff716f7f1abda417a416 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 16 Mar 2011 15:53:45 +0100 Subject: added some more valgrind-based tests --- tests/Makefile.am | 8 ++++++++ tests/failover-basic-vg.sh | 13 +++++++++++++ tests/failover-no-basic-vg.sh | 20 ++++++++++++++++++++ tests/failover-no-rptd-vg.sh | 20 ++++++++++++++++++++ tests/failover-rptd-vg.sh | 13 +++++++++++++ 5 files changed, 74 insertions(+) create mode 100755 tests/failover-basic-vg.sh create mode 100755 tests/failover-no-basic-vg.sh create mode 100755 tests/failover-no-rptd-vg.sh create mode 100755 tests/failover-rptd-vg.sh (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index c1818f36..ebbe0cf6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -65,6 +65,10 @@ if HAVE_VALGRIND TESTS += \ discard-rptdmsg-vg.sh \ discard-allmark-vg.sh \ + failover-basic-vg.sh \ + failover-rptd-vg.sh \ + failover-no-basic-vg.sh \ + failover-no-rptd-vg.sh \ tcp-msgreduc-vg.sh endif @@ -265,12 +269,16 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \ discard.sh \ testsuites/discard.conf \ failover-no-rptd.sh \ + failover-no-rptd-vg.sh \ testsuites/failover-no-rptd.conf \ failover-no-basic.sh \ + failover-no-basic-vg.sh \ testsuites/failover-no-basic.conf \ failover-rptd.sh \ + failover-rptd-vg.sh \ testsuites/failover-rptd.conf \ failover-basic.sh \ + failover-basic-vg.sh \ testsuites/failover-basic.conf \ discard-rptdmsg.sh \ discard-rptdmsg-vg.sh \ diff --git a/tests/failover-basic-vg.sh b/tests/failover-basic-vg.sh new file mode 100755 index 00000000..0eb77caa --- /dev/null +++ b/tests/failover-basic-vg.sh @@ -0,0 +1,13 @@ +# This file is part of the rsyslog project, released under GPLv3 +echo =============================================================================== +echo \[failover-basic.sh\]: basic test for failover functionality +source $srcdir/diag.sh init +source $srcdir/diag.sh startup-vg failover-basic.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-vg +source $srcdir/diag.sh check-exit-vg +source $srcdir/diag.sh seq-check 0 4999 +source $srcdir/diag.sh exit diff --git a/tests/failover-no-basic-vg.sh b/tests/failover-no-basic-vg.sh new file mode 100755 index 00000000..266163d4 --- /dev/null +++ b/tests/failover-no-basic-vg.sh @@ -0,0 +1,20 @@ +# This file is part of the rsyslog project, released under GPLv3 +echo =============================================================================== +echo \[failover-no-basic.sh\]: basic test for failover functionality - no failover +source $srcdir/diag.sh init +source $srcdir/diag.sh startup-vg failover-no-basic.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-vg +source $srcdir/diag.sh check-exit-vg +# now we need our custom logic to see if the result file is empty +# (what it should be!) +cmp rsyslog.out.log /dev/null +if [ $? -eq 1 ] +then + echo "ERROR, output file not empty" + exit 1 +fi +source $srcdir/diag.sh exit diff --git a/tests/failover-no-rptd-vg.sh b/tests/failover-no-rptd-vg.sh new file mode 100755 index 00000000..3b77a0a4 --- /dev/null +++ b/tests/failover-no-rptd-vg.sh @@ -0,0 +1,20 @@ +# This file is part of the rsyslog project, released under GPLv3 +echo =============================================================================== +echo \[failover-no-rptd.sh\]: rptd test for failover functionality - no failover +source $srcdir/diag.sh init +source $srcdir/diag.sh startup-vg failover-no-rptd.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-vg +source $srcdir/diag.sh check-exit-vg +# now we need our custom logic to see if the result file is empty +# (what it should be!) +cmp rsyslog.out.log /dev/null +if [ $? -eq 1 ] +then + echo "ERROR, output file not empty" + exit 1 +fi +source $srcdir/diag.sh exit diff --git a/tests/failover-rptd-vg.sh b/tests/failover-rptd-vg.sh new file mode 100755 index 00000000..d208003b --- /dev/null +++ b/tests/failover-rptd-vg.sh @@ -0,0 +1,13 @@ +# This file is part of the rsyslog project, released under GPLv3 +echo =============================================================================== +echo \[failover-rptd.sh\]: rptd test for failover functionality +source $srcdir/diag.sh init +source $srcdir/diag.sh startup-vg failover-rptd.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-vg +source $srcdir/diag.sh check-exit-vg +source $srcdir/diag.sh seq-check 0 4999 +source $srcdir/diag.sh exit -- cgit From 5bfa8d2a254e0ead0608b954bdab6dd2a7d9f3e0 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 29 Mar 2011 14:31:14 +0200 Subject: testbench samples incorrect, corrected this was due to the old RFC5424 parser being considered correct, what it was not. As such, the samples generated from it were incorrect as well. Now with the corrected parsers, the tests failed. --- tests/testsuites/rfc5424-1.parse1 | 2 +- tests/testsuites/rfc5424-2.parse1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/testsuites/rfc5424-1.parse1 b/tests/testsuites/rfc5424-1.parse1 index 23836c9f..8a66d7ba 100644 --- a/tests/testsuites/rfc5424-1.parse1 +++ b/tests/testsuites/rfc5424-1.parse1 @@ -1,3 +1,3 @@ #Example from RFC5424, section 6.5 / sample 1 <34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - ID47 - BOM'su root' failed for lonvick on /dev/pts/8 -34,auth,crit,Oct 11 22:14:15,mymachine.example.com,,su,- BOM'su root' failed for lonvick on /dev/pts/8 +34,auth,crit,Oct 11 22:14:15,mymachine.example.com,,su,BOM'su root' failed for lonvick on /dev/pts/8 diff --git a/tests/testsuites/rfc5424-2.parse1 b/tests/testsuites/rfc5424-2.parse1 index a86fbc35..f5449e68 100644 --- a/tests/testsuites/rfc5424-2.parse1 +++ b/tests/testsuites/rfc5424-2.parse1 @@ -1,4 +1,4 @@ <165>1 2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc 8710 - - %% It's time to make the do-nuts. -165,local4,notice,Aug 24 05:14:15,192.0.2.1,,myproc[8710],- %% It's time to make the do-nuts. +165,local4,notice,Aug 24 05:14:15,192.0.2.1,,myproc[8710],%% It's time to make the do-nuts. #Example from RFC5424, section 6.5 / sample 2 #Only the first two lines are important, you may place anything behind them! -- cgit From b59f8fd65d4f464ce3673439725db1606ec31329 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 30 Mar 2011 11:19:22 +0200 Subject: fixed problem in testbench & added new test (not yet integrated) The test is a setup scenario for this bug tracker: http://bugzilla.adiscon.com/show_bug.cgi?id=241 --- tests/diag.sh | 14 +++- tests/diagtalker.c | 6 +- tests/rcvr_fail_restore.sh | 96 ++++++++++++++++++++++++++ tests/testsuites/diag-common.conf | 5 +- tests/testsuites/rcvr_fail_restore_rcvr.conf | 8 +++ tests/testsuites/rcvr_fail_restore_sender.conf | 15 ++++ 6 files changed, 139 insertions(+), 5 deletions(-) create mode 100755 tests/rcvr_fail_restore.sh create mode 100644 tests/testsuites/rcvr_fail_restore_rcvr.conf create mode 100644 tests/testsuites/rcvr_fail_restore_sender.conf (limited to 'tests') diff --git a/tests/diag.sh b/tests/diag.sh index 8fbe42ed..d1242fb1 100755 --- a/tests/diag.sh +++ b/tests/diag.sh @@ -84,15 +84,27 @@ case $1 in exit 1 fi ;; + 'get-mainqueuesize') # show the current main queue size + if [ "$2" == "2" ] + then + echo getmainmsgqueuesize | ./diagtalker -p13501 + else + echo getmainmsgqueuesize | ./diagtalker + fi + ;; 'wait-queueempty') # wait for main message queue to be empty. $2 is the instance. if [ "$2" == "2" ] then - echo WaitMainQueueEmpty | ./diagtalker + echo WaitMainQueueEmpty | ./diagtalker -p13501 else echo WaitMainQueueEmpty | ./diagtalker fi ;; 'shutdown-when-empty') # shut rsyslogd down when main queue is empty. $2 is the instance. + if [ "$2" == "2" ] + then + echo Shutting down instance 2 + fi $srcdir/diag.sh wait-queueempty $2 kill `cat rsyslog$2.pid` # note: we do not wait for the actual termination! diff --git a/tests/diagtalker.c b/tests/diagtalker.c index 6a721e47..0d728bda 100644 --- a/tests/diagtalker.c +++ b/tests/diagtalker.c @@ -1,7 +1,7 @@ /* A yet very simple tool to talk to imdiag (this replaces the * previous Java implementation in order to get fewer dependencies). * - * Copyright 2010 Rainer Gerhards and Adiscon GmbH. + * Copyright 2010,2011 Rainer Gerhards and Adiscon GmbH. * * This file is part of rsyslog. * @@ -126,7 +126,7 @@ doProcessing() len = strlen(line); sendCmd(fd, line, len); waitRsp(fd, line, sizeof(line)); - printf("imdiag: %s", line); + printf("imdiag[%d]: %s", targetPort, line); } } @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) int ret = 0; int opt; - while((opt = getopt(argc, argv, "f:t:p:c:C:m:i:I:P:d:n:M:rB")) != -1) { + while((opt = getopt(argc, argv, "t:p:")) != -1) { switch (opt) { case 't': targetIP = optarg; break; diff --git a/tests/rcvr_fail_restore.sh b/tests/rcvr_fail_restore.sh new file mode 100755 index 00000000..e2f0a0d8 --- /dev/null +++ b/tests/rcvr_fail_restore.sh @@ -0,0 +1,96 @@ +# Copyright (C) 2011 by Rainer Gerhards +# This file is part of the rsyslog project, released under GPLv3 +echo =============================================================================== +echo \[rcvr_fail_restore.sh\]: test failed receiver restore case +source $srcdir/diag.sh init +# +# STEP1: start both instances and send 1000 messages. +# Note: receiver is instance 2, sender instance 1. +# +# start up the instances. Note that the envrionment settings can be changed to +# set instance-specific debugging parameters! +export RSYSLOG_DEBUG="debug nostdout" +#export RSYSLOG_DEBUGLOG="log2" +source $srcdir/diag.sh startup rcvr_fail_restore_rcvr.conf 2 +export RSYSLOG_DEBUGLOG="log" +#valgrind="valgrind" +source $srcdir/diag.sh startup rcvr_fail_restore_sender.conf +# re-set params so that new instances do not thrash it... +unset RSYSLOG_DEBUG +unset RSYSLOG_DEBUGLOG + +# now inject the messages into instance 2. It will connect to instance 1, +# and that instance will record the data. +source $srcdir/diag.sh injectmsg 1 1000 +source $srcdir/diag.sh wait-queueempty +./msleep 3000 # make sure some retries happen (retry interval is set to 1 second) +# +# Step 2: shutdown receiver, then send some more data, which then +# needs to go into the queue. +# +source $srcdir/diag.sh shutdown-when-empty 2 +source $srcdir/diag.sh wait-shutdown 2 + +source $srcdir/diag.sh injectmsg 1001 10000 +sleep 1 # we need to wait, otherwise we may be so fast that the receiver +# comes up before we have finally suspended the action +source $srcdir/diag.sh get-mainqueuesize +ls -l test-spool + +# +# Step 3: restart receiver, wait that the sender drains its queue +# +#export RSYSLOG_DEBUGLOG="log2" +source $srcdir/diag.sh startup rcvr_fail_restore_rcvr.conf 2 +echo waiting for sender to drain queue [may need a short while] +source $srcdir/diag.sh wait-queueempty +ls -l test-spool +OLDFILESIZE=$(stat -c%s test-spool/mainq.00000001) +echo file size to expect is $OLDFILESIZE + + +# +# Step 4: send new data. Queue files are not permitted to grow now +# (but one file continous to exist). +# +source $srcdir/diag.sh injectmsg 11001 10 +source $srcdir/diag.sh wait-queueempty + +# at this point, the queue file shall not have grown. Note +# that we MUST NOT shut down the instance right now, because it +# would clean up the queue files! So we need to do our checks +# first (here!). +ls -l test-spool +NEWFILESIZE=$(stat -c%s test-spool/mainq.00000001) +if [ $NEWFILESIZE != $OLDFILESIZE ] +then + echo file sizes do not match, expected $OLDFILESIZE, actual $NEWFILESIZE + echo this means that data has been written to the queue file where it + echo no longer should be written. + # abort will happen below, because we must ensure proper system shutdown + # HOWEVER, during actual testing it may be useful to do an exit here (so + # that e.g. the debug log is pointed right at the correct spot). + # exit 1 +fi + + +# +# Queue file size checks done. Now it is time to terminate the system +# and see if everything could be received (the usual check, done here +# for completeness, more or less as a bonus). +# +source $srcdir/diag.sh shutdown-when-empty +source $srcdir/diag.sh wait-shutdown + +# now it is time to stop the receiver as well +source $srcdir/diag.sh shutdown-when-empty 2 +source $srcdir/diag.sh wait-shutdown 2 + +# now abort test if we need to (due to filesize predicate) +if [ $NEWFILESIZE != $OLDFILESIZE ] +then + exit 1 +fi +# do the final check +source $srcdir/diag.sh seq-check 1 11010 +source $srcdir/diag.sh exit diff --git a/tests/testsuites/diag-common.conf b/tests/testsuites/diag-common.conf index 9e9e28fe..d76e2d15 100644 --- a/tests/testsuites/diag-common.conf +++ b/tests/testsuites/diag-common.conf @@ -13,4 +13,7 @@ $IMDiagServerRun 13500 $template startupfile,"rsyslogd.started" # trick to use relative path names! :syslogtag, contains, "rsyslogd" ?startupfile -$ErrorMessagesToStderr off +# I have disabled the directive below, so that we see errors in testcase +# creation. I am not sure why it was present in the first place, so for +# now I just leave it commented out -- rgerhards, 2011-03-30 +#$ErrorMessagesToStderr off diff --git a/tests/testsuites/rcvr_fail_restore_rcvr.conf b/tests/testsuites/rcvr_fail_restore_rcvr.conf new file mode 100644 index 00000000..38ebad29 --- /dev/null +++ b/tests/testsuites/rcvr_fail_restore_rcvr.conf @@ -0,0 +1,8 @@ +$IncludeConfig diag-common2.conf + +$ModLoad ../plugins/imtcp/.libs/imtcp +# then SENDER sends to this port (not tcpflood!) +$InputTCPServerRun 13515 + +$template outfmt,"%msg:F,58:2%\n" +:msg, contains, "msgnum:" ./rsyslog.out.log;outfmt diff --git a/tests/testsuites/rcvr_fail_restore_sender.conf b/tests/testsuites/rcvr_fail_restore_sender.conf new file mode 100644 index 00000000..6b11aa4a --- /dev/null +++ b/tests/testsuites/rcvr_fail_restore_sender.conf @@ -0,0 +1,15 @@ +$IncludeConfig diag-common.conf + +$ModLoad ../plugins/imtcp/.libs/imtcp +# this listener is for message generation by the test framework! +$InputTCPServerRun 13514 + +$WorkDirectory test-spool +$MainMsgQueueMaxFileSize 1g +$MainMsgQueueFileName mainq + +# we use the shortest resume interval a) to let the test not run too long +# and b) make sure some retries happen before the reconnect +$ActionResumeInterval 1 +$ActionResumeRetryCount -1 +*.* @@127.0.0.1:13515 -- cgit From eccfbf71f9dbc235309c2ad40035d41620f5e5df Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 31 Mar 2011 15:14:22 +0200 Subject: improved testbench, updated ChangeLog to reflect recent bugfix After trying out some more things with the new code (after last bugfix), I now think that the bugfix is OK to use and without regressions. --- tests/Makefile.am | 6 ++++-- tests/rcvr_fail_restore.sh | 42 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index ebbe0cf6..930aa304 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -56,8 +56,7 @@ TESTS += \ failover-rptd.sh \ failover-no-rptd.sh \ failover-no-basic.sh \ - queue-persist.sh - queue-persist.sh \ + rcvr_fail_restore.sh \ linkedlistqueue.sh endif @@ -289,6 +288,9 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \ diag.sh \ testsuites/diag-common.conf \ testsuites/diag-common2.conf \ + rcvr_fail_restore.sh \ + testsuites/rcvr_fail_restore_rcvr.conf \ + testsuites/rcvr_fail_restore_sender.conf \ daqueue-persist.sh \ daqueue-persist-drvr.sh \ queue-persist.sh \ diff --git a/tests/rcvr_fail_restore.sh b/tests/rcvr_fail_restore.sh index e2f0a0d8..79486f10 100755 --- a/tests/rcvr_fail_restore.sh +++ b/tests/rcvr_fail_restore.sh @@ -9,31 +9,32 @@ source $srcdir/diag.sh init # # start up the instances. Note that the envrionment settings can be changed to # set instance-specific debugging parameters! -export RSYSLOG_DEBUG="debug nostdout" +#export RSYSLOG_DEBUG="debug nostdout" #export RSYSLOG_DEBUGLOG="log2" source $srcdir/diag.sh startup rcvr_fail_restore_rcvr.conf 2 -export RSYSLOG_DEBUGLOG="log" +#export RSYSLOG_DEBUGLOG="log" #valgrind="valgrind" source $srcdir/diag.sh startup rcvr_fail_restore_sender.conf # re-set params so that new instances do not thrash it... -unset RSYSLOG_DEBUG -unset RSYSLOG_DEBUGLOG +#unset RSYSLOG_DEBUG +#unset RSYSLOG_DEBUGLOG # now inject the messages into instance 2. It will connect to instance 1, # and that instance will record the data. source $srcdir/diag.sh injectmsg 1 1000 source $srcdir/diag.sh wait-queueempty -./msleep 3000 # make sure some retries happen (retry interval is set to 1 second) +./msleep 1000 # let things settle down a bit + # # Step 2: shutdown receiver, then send some more data, which then # needs to go into the queue. # + source $srcdir/diag.sh shutdown-when-empty 2 source $srcdir/diag.sh wait-shutdown 2 source $srcdir/diag.sh injectmsg 1001 10000 -sleep 1 # we need to wait, otherwise we may be so fast that the receiver -# comes up before we have finally suspended the action +./msleep 3000 # make sure some retries happen (retry interval is set to 3 second) source $srcdir/diag.sh get-mainqueuesize ls -l test-spool @@ -73,6 +74,31 @@ then # exit 1 fi +# +# We now do an extra test (so this is two in one ;)) to see if the DA +# queue can be reactivated after its initial shutdown. In essence, we +# redo steps 2 and 3. +# +# Step 5: stop receiver again, then send some more data, which then +# needs to go into the queue. +# +echo "*** done primary test *** now checking if DA can be restarted" +source $srcdir/diag.sh shutdown-when-empty 2 +source $srcdir/diag.sh wait-shutdown 2 + +source $srcdir/diag.sh injectmsg 11011 10000 +sleep 1 # we need to wait, otherwise we may be so fast that the receiver +# comes up before we have finally suspended the action +source $srcdir/diag.sh get-mainqueuesize +ls -l test-spool + +# +# Step 6: restart receiver, wait that the sender drains its queue +# +source $srcdir/diag.sh startup rcvr_fail_restore_rcvr.conf 2 +echo waiting for sender to drain queue [may need a short while] +source $srcdir/diag.sh wait-queueempty +ls -l test-spool # # Queue file size checks done. Now it is time to terminate the system @@ -92,5 +118,5 @@ then exit 1 fi # do the final check -source $srcdir/diag.sh seq-check 1 11010 +source $srcdir/diag.sh seq-check 1 21010 source $srcdir/diag.sh exit -- cgit