summaryrefslogtreecommitdiffstats
path: root/tests/imdocker-new-logs-from-start.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:28:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:28:20 +0000
commitdcc721a95bef6f0d8e6d8775b8efe33e5aecd562 (patch)
tree66a2774cd0ee294d019efd71d2544c70f42b2842 /tests/imdocker-new-logs-from-start.sh
parentInitial commit. (diff)
downloadrsyslog-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/imdocker-new-logs-from-start.sh')
-rwxr-xr-xtests/imdocker-new-logs-from-start.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/imdocker-new-logs-from-start.sh b/tests/imdocker-new-logs-from-start.sh
new file mode 100755
index 0000000..aaaf07d
--- /dev/null
+++ b/tests/imdocker-new-logs-from-start.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+# This is part of the rsyslog testbench, licensed under ASL 2.0
+# imdocker unit tests are enabled with --enable-imdocker-tests
+. ${srcdir:=.}/diag.sh init
+export COOKIE=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 10 | head -n 1)
+generate_conf
+add_conf '
+#template(name="template_msg_only" type="string" string="%msg%\n")
+template(name="outfmt" type="string" string="%$!metadata!Names% %msg%\n")
+module(load="../contrib/imdocker/.libs/imdocker" PollingInterval="1"
+ ListContainersOptions="all=true"
+ GetContainerLogOptions="tail=1&timestamps=0&follow=1&stdout=1&stderr=0&tail=1"
+ RetrieveNewLogsFromStart="on"
+ )
+action(type="omfile" template="outfmt" file="'$RSYSLOG_OUT_LOG'")
+
+if $!metadata!Names == "'$COOKIE'" then {
+ action(type="omfile" template="outfmt" file="'$RSYSLOG_OUT_LOG'")
+}
+'
+
+#NUM_ITEMS=1000
+# launch a docker runtime to generate some logs.
+# these log items should be tailed.
+docker run \
+ --rm \
+ -e seq_start=101 \
+ -e seq_end=200 \
+ alpine \
+ /bin/sh -c 'for i in `seq $seq_start $seq_end`; do echo "tailed item $i"; sleep .01; done' > /dev/null &
+
+sleep 1
+
+#export RS_REDIR=-d
+startup
+NUMMESSAGES=1000
+# launch a docker runtime to generate some logs.
+# These logs started after start-up should get from beginning
+docker run \
+ --name $COOKIE \
+ -e NUMMESSAGES=$NUMMESSAGES \
+ alpine \
+ /bin/sh -c 'for i in `seq 1 $NUMMESSAGES`; do echo "log item $i"; done' > /dev/null
+
+shutdown_when_empty
+wait_shutdown
+
+echo "file name: $RSYSLOG_OUT_LOG"
+echo "\"tailed item\" occurred: $(grep -c 'tailed item ' $RSYSLOG_OUT_LOG)/100 (expect less)."
+
+docker container rm $COOKIE
+exit_test
+