summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-11-12 13:14:39 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2009-11-12 13:14:39 +0100
commit0a5b731f2f18168795bcdefd9b6fa562dce6a0d5 (patch)
treec40937a25c2887cd267f8dcc43a00dece5d3258a /tests
parent9407f2a3e08940d0dd0367c5904654f5a56117af (diff)
downloadrsyslog-0a5b731f2f18168795bcdefd9b6fa562dce6a0d5.tar.gz
rsyslog-0a5b731f2f18168795bcdefd9b6fa562dce6a0d5.tar.xz
rsyslog-0a5b731f2f18168795bcdefd9b6fa562dce6a0d5.zip
bugfix: $ActionExecOnlyOnceEveryInterval did not work.
This was a regression from the time() optimizations done in v4. Bug tracker: http://bugzilla.adiscon.com/show_bug.cgi?id=143 Thanks to Klaus Tachtler for reporting this bug.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am4
-rwxr-xr-xtests/execonlyonce.sh28
-rw-r--r--tests/testsuites/execonlyonce.conf12
-rw-r--r--tests/testsuites/execonlyonce.data2
4 files changed, 46 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3f5a6c33..3c94a609 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,6 +6,7 @@ TESTS = $(TESTRUNS) cfg.sh \
imtcp-multiport.sh \
diskqueue.sh \
manytcp.sh \
+ execonlyonce.sh \
queue-persist.sh
if ENABLE_OMSTDOUT
@@ -74,6 +75,9 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
queue-persist.sh \
queue-persist-drvr.sh \
testsuites/queue-persist.conf \
+ execonlyonce.sh \
+ testsuites/execonlyonce.conf \
+ testsuites/execonlyonce.data \
DiagTalker.java \
cfg.sh
diff --git a/tests/execonlyonce.sh b/tests/execonlyonce.sh
new file mode 100755
index 00000000..a9b9d932
--- /dev/null
+++ b/tests/execonlyonce.sh
@@ -0,0 +1,28 @@
+# Test for the $ActionExecOnlyOnceEveryInterval directive.
+# We inject a couple of messages quickly during the interval,
+# then wait until the interval expires, then quickly inject
+# another set. After that, it is checked if exactly two messages
+# have arrived.
+# The once interval must be set to 3 seconds in the config file.
+# added 2009-11-12 by Rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
+echo \[execonlyonce.sh\]: test for the $ActionExecOnlyOnceEveryInterval directive
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup execonlyonce.conf
+source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 10 1
+# now wait until the interval definitely expires
+sleep 4 # one more than the once inerval!
+# and inject another couple of messages
+source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 10 100
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+
+# now we need your custom logic to see if the result is equal to the
+# expected result
+cmp rsyslog.out.log testsuites/execonlyonce.data
+if [ $? -eq 1 ]
+then
+ echo "ERROR, output not as expected"
+ exit 1
+fi
+source $srcdir/diag.sh exit
diff --git a/tests/testsuites/execonlyonce.conf b/tests/testsuites/execonlyonce.conf
new file mode 100644
index 00000000..085b970e
--- /dev/null
+++ b/tests/testsuites/execonlyonce.conf
@@ -0,0 +1,12 @@
+# see the equally-named .sh file for details
+# rgerhards, 2009-11-12
+$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!
+$ActionExecOnlyOnceEveryInterval 3
+:msg, contains, "msgnum:" ?dynfile;outfmt
diff --git a/tests/testsuites/execonlyonce.data b/tests/testsuites/execonlyonce.data
new file mode 100644
index 00000000..3c54f3d4
--- /dev/null
+++ b/tests/testsuites/execonlyonce.data
@@ -0,0 +1,2 @@
+00000001
+00000100