testbench: make complex1 test more robust on slow test machines

This commit is contained in:
Rainer Gerhards 2018-12-08 12:14:50 +01:00
parent 2f78d47df9
commit cc9cc2cc79
No known key found for this signature in database
GPG Key ID: 0CB6B2A8BE80B499
2 changed files with 64 additions and 17 deletions

View File

@ -6,9 +6,11 @@
# This file is part of the rsyslog project, released under ASL 2.0
. ${srcdir:=.}/diag.sh init
skip_platform "SunOS" "This test currently does not work on all flavors of Solaris."
export NUMMESSAGES=40000
export RSYSLOG_PORT2="$(get_free_port)"
export RSYSLOG_PORT3="$(get_free_port)"
generate_conf
echo ports: $TCPFLOOD_PORT $RSYSLOG_PORT2 $RSYSLOG_PORT3
add_conf '
$MaxMessageSize 10k
@ -34,10 +36,10 @@ $ActionQueueWorkerThreads 1
# action params:
$OMFileFlushOnTXEnd off
$OMFileZipLevel 6
#$OMFileIOBufferSize 256k
$DynaFileCacheSize 4
$omfileFlushInterval 1
*.* ?dynfile;outfmt
action(type="omfile" file ="'$RSYSLOG_DYNNAME'.countfile")
# listener
$InputTCPServerInputName '$TCPFLOOD_PORT'
$InputTCPServerBindRuleset R13514
@ -62,6 +64,7 @@ $OMFileIOBufferSize 256k
$DynaFileCacheSize 4
$omfileFlushInterval 1
*.* ?dynfile;outfmt
action(type="omfile" file ="'$RSYSLOG_DYNNAME'.countfile")
# listener
$InputTCPServerInputName '$RSYSLOG_PORT2'
$InputTCPServerBindRuleset R_PORT2
@ -87,22 +90,45 @@ $OMFileIOBufferSize 256k
$DynaFileCacheSize 4
$omfileFlushInterval 1
*.* ?dynfile;outfmt
action(type="omfile" file ="'$RSYSLOG_DYNNAME'.countfile")
# listener
$InputTCPServerInputName '$RSYSLOG_PORT3'
$InputTCPServerBindRuleset R_PORT3
$InputTCPServerRun '$RSYSLOG_PORT3'
'
# uncomment for debugging support:
#export RSYSLOG_DEBUG="debug nostdout"
#export RSYSLOG_DEBUGLOG="log"
count_function() {
# TODO: try to make this work on the compressed files, only
# idea does not work as we miss end-of-zip record
# leaving it commented out if we see we should really switch to that
# method; if we do not need for an extended period of time, this shall
# be removed -- rgerhards, 2018-12-19
#mkdir "$RSYSLOG_DYNNAME.countwrk"
#cp $RSYSLOG_DYNNAME.out.*.log.Z "$RSYSLOG_DYNNAME.countwrk"
#cd "$RSYSLOG_DYNNAME.countwrk"
#gunzip $RSYSLOG_DYNNAME.out.*.log.Z
#printf '%d' $(cat $RSYSLOG_DYNNAME.out.*.log | wc -l)
#cd ..
#rm -rf "$RSYSLOG_DYNNAME.countwrk"
# now the real - simple - code:
printf '%d' $(wc -l < $RSYSLOG_DYNNAME.countfile)
}
startup
# send 40,000 messages of 400 bytes plus header max, via three dest ports
export TCPFLOOD_PORT="$TCPFLOOD_PORT:$RSYSLOG_PORT2:$RSYSLOG_PORT3"
tcpflood -m40000 -rd400 -P129 -f5 -n3 -c15 -i1
shutdown_when_empty # shut down rsyslogd when done processing messages
wait_shutdown # and wait for it to terminate
tcpflood -m$NUMMESSAGES -rd400 -P129 -f5 -n3 -c15 -i1
# note: we have FlushOnTX=off, so we will not see the last block inside the file;
# as such we wait until a "sufficiently large" number of messages has arrived and
# hope that shutdown_when_empty gets us toward the rest. It's still a bit racy,
# but should be better than without the wait_file_lines.
wait_file_lines --delay 1000 --count-function count_function DUMMY-filename $((NUMMESSAGES - 1500))
shutdown_when_empty
wait_shutdown
ls $RSYSLOG_DYNNAME.out.*.log.Z
gunzip $RSYSLOG_DYNNAME.out.*.log.Z
cat $RSYSLOG_DYNNAME.out.*.log > $RSYSLOG_OUT_LOG
seq_check 1 40000 -E
seq_check 1 $NUMMESSAGES -E
exit_test

View File

@ -789,8 +789,11 @@ await_lookup_table_reload() {
# $2 expected nbr of lines, default $NUMMESSAGES
# $3 timout in seconds
# options (need to be specified in THIS ORDER if multiple given):
# --delay ms - if given, delay to use between retries
# --abort-on-oversize - error_exit if more lines than expected are present
# --delay ms -- if given, delay to use between retries
# --abort-on-oversize -- error_exit if more lines than expected are present
# --count-function func -- function to call to obtain current count
# this permits to override the default predicate and makes
# the wait really universally usable.
wait_file_lines() {
delay=200
if [ "$1" == "--delay" ]; then
@ -802,6 +805,11 @@ wait_file_lines() {
abort_oversize="YES"
shift
fi
count_function=
if [ "$1" == "--count-function" ]; then
count_function="$2"
shift 2
fi
timeout=${3:-$TB_TEST_TIMEOUT}
timeoutbegin=$(date +%s)
timeoutend=$(( timeoutbegin + timeout ))
@ -810,14 +818,26 @@ wait_file_lines() {
waitlines=${2:-$NUMMESSAGES}
while true ; do
if [ -f "$file" ]; then
count=$(wc -l < "$file")
count=0
if [ "$count_function" == "" ]; then
if [ -f "$file" ]; then
count=$(wc -l < "$file")
fi
else
count=$($count_function)
fi
if [ $abort_oversize == "YES" ] && [ ${count:=0} -gt $waitlines ]; then
printf 'FAIL: wait_file_lines, too many lines, expected %d, current %s, took %s seconds\n' $waitlines $count, "$(( $(date +%s) - timeoutbegin ))"
error_exit 1
if [ ${count} -gt $waitlines ]; then
if [ $abort_oversize == "YES" ] && [ ${count} -gt $waitlines ]; then
printf 'FAIL: wait_file_lines, too many lines, expected %d, current %s, took %s seconds\n' \
$waitlines $count "$(( $(date +%s) - timeoutbegin ))"
error_exit 1
else
printf 'wait_file_lines success, target %d or more lines, have %d, took %d seconds\n' \
"$waitlines" $count "$(( $(date +%s) - timeoutbegin ))"
return
fi
fi
if [ ${count:=0} -eq $waitlines ]; then
if [ ${count} -eq $waitlines ]; then
echo wait_file_lines success, have $waitlines lines, took $(( $(date +%s) - timeoutbegin )) seconds
break
else
@ -830,10 +850,11 @@ wait_file_lines() {
fi
fi
done
unset count
}
# wait until seq_check succeeds. This is used to synchronize various
# testbench timing-related issues, most importantly rsyslog shutdown
# all parameters are passed to seq_check