testbench: fix unreliable gzipwrite test

The test was timing-sensitive as we did not properly check all data
was output to the output file - we just relied on sleep periods.

This has been changed. Also, we made some changes to the testing
framework to fully support sequence checking of multiple ZIP files.
This commit is contained in:
Rainer Gerhards 2019-10-14 13:14:45 +02:00
parent 14c77385bb
commit 73dc50ad0c
No known key found for this signature in database
GPG Key ID: 0CB6B2A8BE80B499
2 changed files with 31 additions and 24 deletions

View File

@ -988,6 +988,9 @@ wait_seq_check() {
fi fi
while true ; do while true ; do
if [ "$PRE_SEQ_CHECK_FUNC" != "" ]; then
$PRE_SEQ_CHECK_FUNC
fi
if [ "${filename##.*}" != "gz" ]; then if [ "${filename##.*}" != "gz" ]; then
if [ -f "$filename" ]; then if [ -f "$filename" ]; then
count=$(wc -l < "$filename") count=$(wc -l < "$filename")
@ -1260,6 +1263,7 @@ error_stats() {
# add -v to chkseq if you need more verbose output # add -v to chkseq if you need more verbose output
# argument --check-only can be used to simply do a check without abort in fail case # argument --check-only can be used to simply do a check without abort in fail case
# env var SEQ_CHECK_FILE permits to override file name to check # env var SEQ_CHECK_FILE permits to override file name to check
# env var SEQ_CHECK_OPTIONS provide the ability to add extra options for check program
seq_check() { seq_check() {
if [ "$SEQ_CHECK_FILE" == "" ]; then if [ "$SEQ_CHECK_FILE" == "" ]; then
SEQ_CHECK_FILE="$RSYSLOG_OUT_LOG" SEQ_CHECK_FILE="$RSYSLOG_OUT_LOG"
@ -1292,7 +1296,7 @@ seq_check() {
if [ "${SEQ_CHECK_FILE##*.}" == "gz" ]; then if [ "${SEQ_CHECK_FILE##*.}" == "gz" ]; then
gunzip -c "${SEQ_CHECK_FILE}" | $RS_SORTCMD $RS_SORT_NUMERIC_OPT | ./chkseq -s$startnum -e$endnum $3 $4 $5 $6 $7 gunzip -c "${SEQ_CHECK_FILE}" | $RS_SORTCMD $RS_SORT_NUMERIC_OPT | ./chkseq -s$startnum -e$endnum $3 $4 $5 $6 $7
else else
$RS_SORTCMD $RS_SORT_NUMERIC_OPT < "${SEQ_CHECK_FILE}" | ./chkseq -s$startnum -e$endnum $3 $4 $5 $6 $7 $RS_SORTCMD $RS_SORT_NUMERIC_OPT < "${SEQ_CHECK_FILE}" | ./chkseq -s$startnum -e$endnum $3 $4 $5 $6 $7 $SEQ_CHEKC_OPTIONS
fi fi
ret=$? ret=$?
if [ "$check_only" == "YES" ]; then if [ "$check_only" == "YES" ]; then

View File

@ -16,34 +16,37 @@
# #
# This file is part of the rsyslog project, released under ASL 2.0 # This file is part of the rsyslog project, released under ASL 2.0
. ${srcdir:=.}/diag.sh init . ${srcdir:=.}/diag.sh init
skip_platform "SunOS" "FIXME: this test does not work on Solaris because of what looks like a BUG! It is just disabled here so that we can gain the benefits of a better test on other platforms. Bug on solaris must be addressed"
combine_files() {
gunzip -c < $RSYSLOG_DYNNAME.out.0.log > $RSYSLOG_OUT_LOG
gunzip -c < $RSYSLOG_DYNNAME.out.1.log >> $RSYSLOG_OUT_LOG
gunzip -c < $RSYSLOG_DYNNAME.out.2.log >> $RSYSLOG_OUT_LOG
gunzip -c < $RSYSLOG_DYNNAME.out.3.log >> $RSYSLOG_OUT_LOG
gunzip -c < $RSYSLOG_DYNNAME.out.4.log >> $RSYSLOG_OUT_LOG
}
export NUMMESSAGES=4000
export QUEUE_EMPTY_CHECK_FUNC=wait_seq_check
export PRE_SEQ_CHECK_FUNC=combine_files
export SEQ_CHECK_FILE=$RSYSLOG_OUT_LOG
export SEQ_CHECK_OPTIONS=-E
generate_conf generate_conf
add_conf ' add_conf '
$MaxMessageSize 10k global(MaxMessageSize="10k")
module(load="../plugins/imtcp/.libs/imtcp")
$ModLoad ../plugins/imtcp/.libs/imtcp input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port")
$MainMsgQueueTimeoutShutdown 10000
$InputTCPServerRun '$TCPFLOOD_PORT'
$template outfmt,"%msg:F,58:3%,%msg:F,58:4%,%msg:F,58:5%\n" $template outfmt,"%msg:F,58:3%,%msg:F,58:4%,%msg:F,58:5%\n"
$template dynfile,"'$RSYSLOG_DYNNAME'.out.%msg:F,58:2%.log" # use multiple dynafiles $template dynfile,"'$RSYSLOG_DYNNAME'.out.%msg:F,58:2%.log" # use multiple dynafiles
$OMFileFlushOnTXEnd off local0.* action(type="omfile" template="outfmt"
$OMFileZipLevel 6 zipLevel="6" ioBufferSize="256k" veryRobustZip="on"
$OMFileIOBufferSize 256k flushOnTXEnd="off" flushInterval="1"
$DynaFileCacheSize 4 asyncWriting="on" dynaFileCacheSize="4"
$omfileFlushInterval 1 dynafile="dynfile")
local0.* ?dynfile;outfmt
' '
startup startup
# send 4000 messages of 10.000bytes plus header max, randomized # send messages of 10.000bytes plus header max, randomized
tcpflood -m4000 -r -d10000 -P129 -f5 tcpflood -m$NUMMESSAGES -r -d10000 -P129 -f5
sleep 2 # due to large messages, we need this time for the tcp receiver to settle... shutdown_when_empty
shutdown_when_empty # shut down rsyslogd when done processing messages wait_shutdown
wait_shutdown # and wait for it to terminate seq_check
gunzip < $RSYSLOG_DYNNAME.out.0.log > $RSYSLOG_OUT_LOG
gunzip < $RSYSLOG_DYNNAME.out.1.log >> $RSYSLOG_OUT_LOG
gunzip < $RSYSLOG_DYNNAME.out.2.log >> $RSYSLOG_OUT_LOG
gunzip < $RSYSLOG_DYNNAME.out.3.log >> $RSYSLOG_OUT_LOG
gunzip < $RSYSLOG_DYNNAME.out.4.log >> $RSYSLOG_OUT_LOG
#cat $RSYSLOG_DYNNAME.out.* > $RSYSLOG_OUT_LOG
seq_check 0 3999 -E
exit_test exit_test