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-multiple.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-multiple.sh')
-rwxr-xr-x | tests/imfile-logrotate-multiple.sh | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/imfile-logrotate-multiple.sh b/tests/imfile-logrotate-multiple.sh new file mode 100755 index 0000000..e63a308 --- /dev/null +++ b/tests/imfile-logrotate-multiple.sh @@ -0,0 +1,85 @@ +#!/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 IMFILEROTATES="10" +export TESTMESSAGES=10000 +export TESTMESSAGESFULL=$((IMFILEROTATES * TESTMESSAGES-1)) + +generate_conf +add_conf ' +global( + workDirectory="'$RSYSLOG_DYNNAME'.spool" + /* Filter out busy debug output */ + debug.whitelist="off" + debug.files=["omfile.c", "queue.c", "rainerscript.c", "ratelimit.c", "ruleset.c", "main Q", "msg.c", "../action.c"] + ) + +module(load="../plugins/imfile/.libs/imfile" mode="inotify") + +input(type="imfile" File="./'$RSYSLOG_DYNNAME'.input" + Tag="file:" Severity="error" Facility="local7" addMetadata="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" +{ + create + daily + missingok + rotate 14 + notifempty + compress + delaycompress +}' > $RSYSLOG_DYNNAME.logrotate + + +display_file() { + printf '\nFILE %s content:\n' $1 + cat -n $1 +} + +startup + +TESTMESSAGESSTART=0 +for i in $(seq 1 $IMFILEROTATES); +do + #printf 'PRESS ENTER TO CONTINUE\n' + #read + printf '\n\nNEW RUN:\n' + + ./inputfilegen -m $TESTMESSAGES -i $TESTMESSAGESSTART > $RSYSLOG_DYNNAME.input + + ls -li $RSYSLOG_DYNNAME.input* + echo ls ${RSYSLOG_DYNNAME}.spool: + ls -li ${RSYSLOG_DYNNAME}.spool + echo STATE FILE CONTENT: + shopt -s extglob + for filename in "$RSYSLOG_DYNNAME.spool"/imfile-state:*; do display_file $filename; done + + # Wait until testmessages are processed by imfile! + msgcount=$((i * TESTMESSAGES-1)) + # echo "TESTMESSAGESSTART: $TESTMESSAGESSTART - TotalMsgCount: $msgcount" + wait_file_lines $RSYSLOG_OUT_LOG $msgcount $RETRIES + + # Logrotate on logfile + logrotate --state $RSYSLOG_DYNNAME.logrotate.state -f $RSYSLOG_DYNNAME.logrotate + + TESTMESSAGESSTART=$((TESTMESSAGESSTART+TESTMESSAGES)) +done + + +shutdown_when_empty +wait_shutdown +seq_check 0 $TESTMESSAGESFULL +exit_test |