rsyslog/tests/execonlyonce.sh
Rainer Gerhards a3f99b7ae9
testbench: harden against slow testbench machines
alos modernize tests a bit
2018-12-20 12:08:40 +01:00

35 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# 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 ASL 2.0
. ${srcdir:=.}/diag.sh init
generate_conf
add_conf '
$ModLoad ../plugins/imtcp/.libs/imtcp
$MainMsgQueueTimeoutShutdown 10000
$InputTCPServerRun '$TCPFLOOD_PORT'
$template outfmt,"%msg:F,58:2%\n"
template(name="dynfile" type="string" string="'$RSYSLOG_OUT_LOG'")
$ActionExecOnlyOnceEveryInterval 3
:msg, contains, "msgnum:" ?dynfile;outfmt
'
startup
tcpflood -m10 -i1
# now wait until the interval definitely expires (at least we hope so...)
sleep 5
# and inject another couple of messages
tcpflood -m10 -i100
shutdown_when_empty
wait_shutdown
export EXPECTED="00000001
00000100"
cmp_exact
exit_test