diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 16:28:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 16:28:20 +0000 |
commit | dcc721a95bef6f0d8e6d8775b8efe33e5aecd562 (patch) | |
tree | 66a2774cd0ee294d019efd71d2544c70f42b2842 /tests/imfile-logrotate-copytruncate.sh | |
parent | Initial commit. (diff) | |
download | rsyslog-dcc721a95bef6f0d8e6d8775b8efe33e5aecd562.tar.xz rsyslog-dcc721a95bef6f0d8e6d8775b8efe33e5aecd562.zip |
Adding upstream version 8.2402.0.upstream/8.2402.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/imfile-logrotate-copytruncate.sh')
-rwxr-xr-x | tests/imfile-logrotate-copytruncate.sh | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/imfile-logrotate-copytruncate.sh b/tests/imfile-logrotate-copytruncate.sh new file mode 100755 index 0000000..74643a4 --- /dev/null +++ b/tests/imfile-logrotate-copytruncate.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# This is part of the rsyslog testbench, licensed under ASL 2.0 +. $srcdir/diag.sh check-inotify-only +. ${srcdir:=.}/diag.sh init +check_command_available logrotate + +export TESTMESSAGES=10000 +export RETRIES=50 +export TESTMESSAGESFULL=19999 + +generate_conf +add_conf ' +$WorkDirectory '$RSYSLOG_DYNNAME'.spool + +/* Filter out busy debug output */ +global( + debug.whitelist="off" + debug.files=["rainerscript.c", "ratelimit.c", "ruleset.c", "main Q", "msg.c", "../action.c"] + ) + +module( load="../plugins/imfile/.libs/imfile" + mode="inotify" + PollingInterval="1") + +input(type="imfile" + File="./'$RSYSLOG_DYNNAME'.input.*.log" + Tag="file:" + Severity="error" + Facility="local7" + addMetadata="on" + reopenOnTruncate="on" +) + +$template outfmt,"%msg:F,58:2%\n" +if $msg contains "msgnum:" then + action( + type="omfile" + file=`echo $RSYSLOG_OUT_LOG` + template="outfmt" + ) +' + +# Write logrotate config file +echo '"./'$RSYSLOG_DYNNAME'.input.*.log" +{ + rotate 7 + create + daily + missingok + notifempty + compress + copytruncate +}' > $RSYSLOG_DYNNAME.logrotate + +# generate input file first. +./inputfilegen -m $TESTMESSAGES > $RSYSLOG_DYNNAME.input.1.log +ls -l $RSYSLOG_DYNNAME.input* + +startup + +# Wait until testmessages are processed by imfile! +wait_file_lines $RSYSLOG_OUT_LOG $TESTMESSAGES $RETRIES + +# Logrotate on logfile +logrotate --state $RSYSLOG_DYNNAME.logrotate.state -f $RSYSLOG_DYNNAME.logrotate + +# generate more input after logrotate into new logfile +./inputfilegen -m $TESTMESSAGES -i $TESTMESSAGES >> $RSYSLOG_DYNNAME.input.1.log +ls -l $RSYSLOG_DYNNAME.input* +echo ls ${RSYSLOG_DYNNAME}.spool: +ls -l ${RSYSLOG_DYNNAME}.spool + +msgcount=$((2* TESTMESSAGES)) +wait_file_lines $RSYSLOG_OUT_LOG $msgcount $RETRIES + +shutdown_when_empty # shut down rsyslogd when done processing messages +wait_shutdown # we need to wait until rsyslogd is finished! +seq_check 0 $TESTMESSAGESFULL +exit_test |