rsyslog/tests/testsuites/omprog-transactions-bin.sh
Rainer Gerhards dbe61eb06b
testbench: make some test files dynamic
This is work torward the ability to run the testbench in parallel.
Some small issues in tests have also been detected, which were not
previously seen. They have been fixed. We did not do separate
commits for this as it would clutter the commit log with not
really relevant info.

Also move some cleanup to "make clean" target

To support parallel testbench runs, we need to have dynamic work files.
So deleting work files on each test does not work, especially as we can
no longer assume they are "left-overs" from a failed test - they may
actually (and quite likely) belong to tests that run in parallel.

So the proper solution is to do via "make clean".

closes https://github.com/rsyslog/rsyslog/pull/2916
2018-08-13 15:04:47 +02:00

61 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
outfile=$RSYSLOG_OUT_LOG
status="OK"
echo "<= $status" >> $outfile
echo $status
in_transaction=false
fail_on_commit=false
retry_count=0
read line
while [[ -n "$line" ]]; do
message=${line//$'\n'}
echo "=> $message" >> $outfile
if [[ "$message" == "BEGIN TRANSACTION" ]]; then
in_transaction=true
status="OK"
elif [[ "$message" == "COMMIT TRANSACTION" ]]; then
in_transaction=false
if [[ $fail_on_commit == true ]]; then
status="Error: could not commit transaction"
fail_on_commit=false
else
status="OK"
fi
else
if [[ $in_transaction == true ]]; then
status="DEFER_COMMIT"
else
# Should not occur
status="Error: received a message out of a transaction"
fi
fi
# First command line argument ($1) indicates whether to test for negative
# cases. If --failed_messages is specified, an error is returned for certain
# messages, forcing them to be retried twice. If --failed_commits is
# specified, the error is returned when committing the transaction.
if [[ "$1" != "" && ($message == *04* || $message == *07*) ]]; then
if [[ $retry_count < 2 ]]; then
if [[ "$1" == "--failed_commits" ]]; then
fail_on_commit=true
else
status="Error: could not process log message"
fi
let "retry_count++"
else
retry_count=0
fi
fi
echo "<= $status" >> $outfile
echo $status
read line
done
exit 0