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/loadbalance.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/loadbalance.sh')
-rwxr-xr-x | tests/loadbalance.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/loadbalance.sh b/tests/loadbalance.sh new file mode 100755 index 0000000..06a2a47 --- /dev/null +++ b/tests/loadbalance.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# a test to check load balancing via global variables +# note: for simplicity, we use omfile output; in practice this will usually +# be some kind of network output, e.g. omfwd or omrelp. From the method's +# point of view, the actual output does not matter. +# added by Rainer Gerhards 2020-01-03 +# part of the rsyslog project, released under ASL 2.0 +. ${srcdir:=.}/diag.sh init +export NUMMESSAGES=1000 # sufficient for our needs +export QUEUE_EMPTY_CHECK_FUNC=wait_seq_check +generate_conf +add_conf ' +template(name="outfmt" type="string" string="%msg:F,58:2%\n") + +# note: do NOT initialize $/lbcntr - it starts at "", which becomes 0 after cnum() +if $msg contains "msgnum" then { + set $.actnbr = cnum($/lbcntr) % 4; + if $.actnbr == 0 then { + action(type="omfile" file="'$RSYSLOG_DYNNAME'0.log" template="outfmt") + } else if $.actnbr == 1 then { + action(type="omfile" file="'$RSYSLOG_DYNNAME'1.log" template="outfmt") + } else if $.actnbr == 2 then { + action(type="omfile" file="'$RSYSLOG_DYNNAME'2.log" template="outfmt") + } else { + action(type="omfile" file="'$RSYSLOG_DYNNAME'3.log" template="outfmt") + } + set $/lbcntr = cnum($/lbcntr) + 1; +action(type="omfile" file="'$RSYSLOG_OUT_LOG'" template="outfmt") +} +' +startup +injectmsg +shutdown_when_empty +wait_shutdown +seq_check # validate test result as such +export SEQ_CHECK_FILE="${RSYSLOG_DYNNAME}0.log" +seq_check 0 $((NUMMESSAGES -4)) -i 4 +printf 'Checking file 1\n' +export SEQ_CHECK_FILE="${RSYSLOG_DYNNAME}1.log" +printf 'Checking file 2\n' +export SEQ_CHECK_FILE="${RSYSLOG_DYNNAME}2.log" +printf 'Checking file 3\n' +export SEQ_CHECK_FILE="${RSYSLOG_DYNNAME}3.log" +exit_test |