| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # added 2024-02-24 by rgerhards. Released under ASL 2.0 |
| 3 | . ${srcdir:=.}/diag.sh init |
| 4 | generate_conf |
| 5 | export NUMMESSAGES=10000 # MUST be an EVEN number! |
| 6 | |
| 7 | # starting minitcpsrvr receivers so that we can obtain their port |
| 8 | # numbers |
| 9 | start_minitcpsrvr $RSYSLOG_OUT_LOG 1 |
| 10 | |
| 11 | # regular startup |
| 12 | add_conf ' |
| 13 | $MainMsgQueueTimeoutShutdown 10000 |
| 14 | $MainMsgQueueWorkerThreads 2 |
| 15 | |
| 16 | template(name="outfmt" type="string" string="%msg:F,58:2%\n") |
| 17 | module(load="builtin:omfwd" template="outfmt") |
| 18 | |
| 19 | if $msg contains "msgnum:" then { |
| 20 | action(type="omfwd" target=["127.0.0.1", "127.0.0.1"] |
| 21 | port=["'$MINITCPSRVR_PORT1'", "'$TCPFLOOD_PORT'"] |
| 22 | protocol="tcp" |
| 23 | pool.resumeInterval="1" |
| 24 | action.resumeRetryCount="-1" action.resumeInterval="5") |
| 25 | } |
| 26 | ' |
| 27 | |
| 28 | startup |
| 29 | # we need special logic. In a first iteration, the second target is offline |
| 30 | # so everything is expected to go the the first target, only. |
| 31 | injectmsg |
| 32 | # combine both files to check for correct message content |
| 33 | #cat "$RSYSLOG_OUT_LOG" "$RSYSLOG2_OUT_LOG" > "$SEQ_CHECK_FILE" |
| 34 | wait_queueempty |
| 35 | wait_file_lines |
| 36 | cpscip-shell system . . cp. "$RSYSLOG_OUT_LOG" tmp.log |
| 37 | seq_check |
| 38 | printfscip-shell system . . printf. "\nSUCCESS for part 1 of the test\n\n" |
| 39 | |
| 40 | echoscip-shell system . . echo. WARNING: The next part of this test is flacky, because there is an |
| 41 | echoscip-shell system . . echo. inevitable race on the port number for minitcpsrvr. If another |
| 42 | echoscip-shell system . . echo. parallel test has aquired it in the interim, this test here will |
| 43 | echoscip-shell system . . echo. invalidly fail. |
| 44 | ./minitcpsrv -t127.0.0.1 -p $TCPFLOOD_PORT -f "$RSYSLOG2_OUT_LOG" \ |
| 45 | -P "$RSYSLOG_DYNNAME.minitcpsrvr_port2" & |
| 46 | # Note: we use the port file just to make sure minitcpsrvr has initialized! |
| 47 | wait_file_exists "$RSYSLOG_DYNNAME.minitcpsrvr_port2" |
| 48 | BGPROCESS=$! |
| 49 | echoscip-shell system . . echo. "### background minitcpsrv process id is $BGPROCESS port $TCPFLOOD_PORT ###" |
| 50 | echoscip-shell system . . echo. "waiting a bit to ensure rsyslog retries the currently suspended pool member" |
| 51 | |
| 52 | sleepscip-shell system . . sleep. 3 |
| 53 | |
| 54 | injectmsg $NUMMESSAGES $NUMMESSAGES |
| 55 | |
| 56 | shutdown_when_empty |
| 57 | wait_shutdown |
| 58 | |
| 59 | if [scip-shell system . . `[`. "$(wcscip-shell system . . wc. -l < $RSYSLOG2_OUT_LOG)" != "$(( NUMMESSAGES / 2 ))" ]; then |
| 60 | echoscip-shell system . . echo. "ERROR: RSYSLOG2_OUT_LOG has invalid number of messages $(( NUMMESSAGES / 2 ))" |
| 61 | catscip-shell system . . cat. -n $RSYSLOG2_OUT_LOG | headscip-shell system . . head. -10 |
| 62 | error_exit 100 |
| 63 | fi |
| 64 | |
| 65 | # combine both files to check for correct message content |
| 66 | export SEQ_CHECK_FILE="$RSYSLOG_DYNNAME.log-combined" |
| 67 | export NUMMESSAGES=$((NUMMESSAGES*2)) |
| 68 | catscip-shell system . . cat. "$RSYSLOG_OUT_LOG" "$RSYSLOG2_OUT_LOG" > "$SEQ_CHECK_FILE" |
| 69 | seq_check |
| 70 | |
| 71 | exit_test |