rsyslog/tests/sndrcv_tls_anon_rebind.sh
Rainer Gerhards 1c0f9bba50
omfwd: implement native load balancing - phase 1
This patch implements a simple round-robin load balancer
for omfwd. It provides equal distribution of load to a pool
of target servers.

The code currently has no different modes and no special tuning
for the load balancer. However, it works very well in the most
common use cases. Furthermore, it provides a solid base on which
more elaborate functionality can be build if there is need to.

The new functionality is fully backwards compatible with previous
configuration settings.

New action() config params:
* pool.resumeinterval

New/"changed" rstats counters
Each target receives its own set of pstats counters. Most
importantly this is the case for byte counts. That counter retains
the same naming, but there may now be multiple of these counters,
one for each target ip, port tuple.

New pstats message count to target
Among others, this can be used for checking that the load balancer
works as intended. The so-far byte count emitted does not provide
a clear indication of how many messages the targets had actually
processed.

For obvious reasons, this message count makes most sense in
advanced load balancing scenarios, but also provides additional
insight into round-robin. Non-matches indicate that targets
went offline, and we can now evaluate the impact this had
on processing.

- re-design rebind functionality

This now works at the transaction level. It causes a rebind of all
pool members. Previous code did not work 100% correct since for a
couple of years now (after output batching integration).

As cleanup, rebindInterval support has been removed from tcpClt,
because omfwd is the only user. This permits a cleaner code path.

We also noticed a bug with rebindInterval:  it caused some mild
message duplication for quite some time. This went unnoticed.
To address that efficiently, rebindInterval in the future will
be considered once per batch. That means up to (maxBatchSize - 1)
messages may be transmitted more than the rebindinterval is.
That's the cleanest mode of operation and should not make any
difference for real deployments.

Some additional work done in this commit:

netstream: harden component against upper-layer logic errors

network subsystem: better handle API errors and provide more info

omfwd: add new parameter "iobuffer.maxsize"

add new global parameter debug.abortoninternalerror and use it

This parameter permits to make test runs fail when an internal error
is detected and gracefully handled by rsyslog. While it is great to
have it gracefully handled in practice, we should not accept this
during testing. The new parameter permits to abort in this case and
emits the related error message beforehand. It is turned on by
default in our regular tests.

add dedicated error code for "hard" program errors

omfwd: some cleanup + error message fix + new debug level messages

imptcp: improve error messages

add omfwd option to NOT do extended connection check

also output wrkr id in some omfwd messages (primarily debugging aid)

better debug info via LogMsg() interface

improve messages regarding imptcp and omfwd suspension / thread IDs

refactor and enchance minitcpsrvr for mimicing died servers

new global (debugging) option, correction of an informational msg

add global option allmessagestostderr

add new tests
2024-08-19 08:54:31 +02:00

69 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# testing sending and receiving via TLS with anon auth and rebind
# rgerhards, 2011-04-04
# This file is part of the rsyslog project, released under GPLv3
. ${srcdir:=.}/diag.sh init
export NUMMESSAGES=25000 #25000
# uncomment for debugging support:
# start up the instances
#export RSYSLOG_DEBUG="debug nostdout noprintmutexaction"
export RSYSLOG_DEBUGLOG="log"
generate_conf
export PORT_RCVR="$(get_free_port)"
add_conf '
global(
defaultNetstreamDriverCAFile="'$srcdir/testsuites/x.509/ca.pem'"
defaultNetstreamDriverCertFile="'$srcdir/testsuites/x.509/client-cert.pem'"
defaultNetstreamDriverKeyFile="'$srcdir/testsuites/x.509/client-key.pem'"
defaultNetstreamDriver="gtls"
)
module( load="../plugins/imtcp/.libs/imtcp"
StreamDriver.Name="gtls"
StreamDriver.Mode="1"
StreamDriver.AuthMode="anon" )
# then SENDER sends to this port (not tcpflood!)
input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port")
$template outfmt,"%msg:F,58:2%\n"
$template dynfile,"'$RSYSLOG_OUT_LOG'" # trick to use relative path names!
:msg, contains, "msgnum:" ?dynfile;outfmt
'
startup
export PORT_RCVR=$TCPFLOOD_PORT # save this, will be rewritten with next config
#export RSYSLOG_DEBUG="debug nostdout"
export RSYSLOG_DEBUGLOG="log2"
#valgrind="valgrind"
generate_conf 2
add_conf '
global(
defaultNetstreamDriverCAFile="'$srcdir/tls-certs/ca.pem'"
defaultNetstreamDriverCertFile="'$srcdir/tls-certs/cert.pem'"
defaultNetstreamDriverKeyFile="'$srcdir/tls-certs/key.pem'"
defaultNetstreamDriver="gtls"
)
# set up the action
$ActionSendStreamDriverMode 1 # require TLS for the connection
$ActionSendStreamDriverAuthMode anon
$ActionSendTCPRebindInterval 50
*.* @@127.0.0.1:'$PORT_RCVR'
' 2
startup 2
# now inject the messages into instance 2. It will connect to instance 1,
# and that instance will record the data.
injectmsg2 1 $NUMMESSAGES
# shut down sender when everything is sent, receiver continues to run concurrently
shutdown_when_empty 2
wait_shutdown 2
# now it is time to stop the receiver as well
shutdown_when_empty
wait_shutdown
seq_check 1 $NUMMESSAGES
exit_test