testbench: prototype of sndrcv test in modern style

This commit is contained in:
Rainer Gerhards 2018-07-30 15:12:57 +02:00
parent 1f8f621a97
commit 6bb5bc91f5
No known key found for this signature in database
GPG Key ID: 0CB6B2A8BE80B499
2 changed files with 84 additions and 21 deletions

View File

@ -84,21 +84,28 @@ function setvar_RS_HOSTNAME() {
# begin a new testconfig
# $1 is the instance id, if given
function generate_conf() {
export IMDIAG_PORT="$(get_free_port)"
echo default-instance imdiag running on port $IMDIAG_PORT
new_port="$(get_free_port)"
if [ "$1" == "" ]; then
export IMDIAG_PORT=$new_port
else
export IMDIAG_PORT2=$new_port
fi
echo imdiag running on port $new_port
echo "module(load=\"../plugins/imdiag/.libs/imdiag\")
global(inputs.timeout.shutdown=\"10000\")
\$IMDiagServerRun $IMDIAG_PORT
\$IMDiagServerRun $new_port
:syslogtag, contains, \"rsyslogd\" ./rsyslogd.started
###### end of testbench instrumentation part, test conf follows:" > testconf.conf
:syslogtag, contains, \"rsyslogd\" ./rsyslogd$1.started
###### end of testbench instrumentation part, test conf follows:" > testconf$1.conf
}
# add more data to config file. Note: generate_conf must have been called
# $1 is config fragment, $2 the instance id, if given
function add_conf() {
printf "%s" "$1" >> testconf.conf
printf "%s" "$1" >> testconf$2.conf
}
@ -134,20 +141,24 @@ function cmp_exact() {
# start rsyslogd with default params. $1 is the config file name to use
# returns only after successful startup, $2 is the instance (blank or 2!)
function startup() {
echo in startup
if [ "$1" == "" ]; then
instance=
if [ "$1" == "2" ]; then
CONF_FILE="testconf2.conf"
instance=2
elif [ "$1" == "" ]; then
CONF_FILE="testconf.conf"
echo $CONF_FILE is:
cat -n $CONF_FILE
else
CONF_FILE="$srcdir/testsuites/$1"
instance=$2
fi
if [ ! -f $CONF_FILE ]; then
echo "ERROR: config file '$CONF_FILE' not found!"
exit 1
error_exit 1
fi
LD_PRELOAD=$RSYSLOG_PRELOAD $valgrind ../tools/rsyslogd -C -n -irsyslog$2.pid -M../runtime/.libs:../.libs -f$CONF_FILE &
. $srcdir/diag.sh wait-startup $2
echo $CONF_FILE is:
cat -n $CONF_FILE
LD_PRELOAD=$RSYSLOG_PRELOAD $valgrind ../tools/rsyslogd -C -n -irsyslog$instance.pid -M../runtime/.libs:../.libs -f$CONF_FILE &
. $srcdir/diag.sh wait-startup $instance
}
# start rsyslogd with default params. $1 is the config file name to use
@ -481,7 +492,7 @@ case $1 in
rm -rf test-spool test-logdir stat-file1
rm -f rsyslog.pipe rsyslog.input.*
rm -f rsyslog.input rsyslog.empty rsyslog.input.* imfile-state* omkafka-failed.data
rm -f testconf.conf HOSTNAME
rm -f testconf*.conf HOSTNAME
rm -f rsyslog.errorfile tmp.qi nocert
rm -f core.* vgcore.* core*
# Note: rsyslog.action.*.include must NOT be deleted, as it
@ -503,6 +514,8 @@ case $1 in
fi
export RSYSLOG_DFLT_LOG_INTERNAL=1 # testbench needs internal messages logged internally!
export IMDIAG_PORT=13500
export IMDIAG_PORT2=13501
export TCPFLOOD_PORT=13514
;;
'check-command-available') # check if command $2 is available - will exit 77 when not OK
@ -650,7 +663,7 @@ case $1 in
'get-mainqueuesize') # show the current main queue size
if [ "$2" == "2" ]
then
echo getmainmsgqueuesize | $TESTTOOL_DIR/diagtalker -p13501 || error_exit $?
echo getmainmsgqueuesize | $TESTTOOL_DIR/diagtalker -p$IMDIAG_PORT2 || error_exit $?
else
echo getmainmsgqueuesize | $TESTTOOL_DIR/diagtalker -p$IMDIAG_PORT || error_exit $?
fi
@ -658,7 +671,7 @@ case $1 in
'wait-queueempty') # wait for main message queue to be empty. $2 is the instance.
if [ "$2" == "2" ]
then
echo WaitMainQueueEmpty | $TESTTOOL_DIR/diagtalker -p13501 || error_exit $?
echo WaitMainQueueEmpty | $TESTTOOL_DIR/diagtalker -p$IMDIAG_PORT2 || error_exit $?
else
echo WaitMainQueueEmpty | $TESTTOOL_DIR/diagtalker -p$IMDIAG_PORT || error_exit $?
fi
@ -666,7 +679,7 @@ case $1 in
'await-lookup-table-reload') # wait for all pending lookup table reloads to complete $2 is the instance.
if [ "$2" == "2" ]
then
echo AwaitLookupTableReload | $TESTTOOL_DIR/diagtalker -p13501 || error_exit $?
echo AwaitLookupTableReload | $TESTTOOL_DIR/diagtalker -pIMDIAG_PORT2 || error_exit $?
else
echo AwaitLookupTableReload | $TESTTOOL_DIR/diagtalker -p$IMDIAG_PORT || error_exit $?
fi
@ -686,7 +699,7 @@ case $1 in
;;
'tcpflood') # do a tcpflood run and check if it worked params are passed to tcpflood
shift 1
eval ./tcpflood "$@" $TCPFLOOD_EXTRA_OPTS
eval ./tcpflood -p$TCPFLOOD_PORT "$@" $TCPFLOOD_EXTRA_OPTS
if [ "$?" -ne "0" ]; then
echo "error during tcpflood! see rsyslog.out.log.save for what was written"
cp rsyslog.out.log rsyslog.out.log.save

View File

@ -1,6 +1,56 @@
#!/bin/bash
# added 2013-12-10 by Rgerhards
# This file is part of the rsyslog project, released under ASL 2.0
echo ===============================================================================
echo \[sndrcv_relp.sh\]: testing sending and receiving via relp
. $srcdir/sndrcv_drvr.sh sndrcv_relp 50000
#. $srcdir/sndrcv_drvr.sh sndrcv_relp 50000
. $srcdir/diag.sh init
########## receiver ##########
#export RSYSLOG_DEBUG="debug nostdout noprintmutexaction"
#export RSYSLOG_DEBUGLOG="log"
generate_conf
export PORT_RCVR="$(get_free_port)"
add_conf '
module(load="../plugins/imrelp/.libs/imrelp")
# then SENDER sends to this port (not tcpflood!)
input(type="imrelp" port=`echo $PORT_RCVR`)
$template outfmt,"%msg:F,58:2%\n"
:msg, contains, "msgnum:" action(type="omfile" file="rsyslog.out.log" template="outfmt")
'
startup
. $srcdir/diag.sh wait-startup
printf "#### RECEIVER STARTED\n\n"
########## sender ##########
#export RSYSLOG_DEBUGLOG="log2"
export TCPFLOOD_PORT="$(get_free_port)" # TODO: move to diag.sh
generate_conf 2
add_conf '
module(load="../plugins/omrelp/.libs/omrelp")
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port=`echo $TCPFLOOD_PORT`) /* this port for tcpflood! */
action(type="omrelp" name="omrelp" target="127.0.0.1" port=`echo $PORT_RCVR`)
' 2
startup 2
. $srcdir/diag.sh wait-startup 2
# may be needed by TLS (once we do it): sleep 30
printf "#### SENDER STARTED\n\n"
# now inject the messages into instance 2. It will connect to instance 1,
# and that instance will record the data.
. $srcdir/diag.sh tcpflood -m50000 -i1
#sleep 5 # make sure all data is received in input buffers
shutdown_when_empty 2
wait_shutdown 2
# now it is time to stop the receiver as well
shutdown_when_empty
wait_shutdown
# may be needed by TLS (once we do it): sleep 60
# do the final check
seq_check 1 50000
unset PORT_RCVR # TODO: move to exit_test()?
exit_test