rsyslog/tests/sndrcv_kafka_multi_topics.sh
Andre Lorbach 4f5da2c50d ci: add macOS CI workflows and improve test diagnostics
Add comprehensive macOS CI support with two new GitHub Actions workflows:

- run_macos.yml: PR-triggered CI with matrix strategy covering macOS 13-15,
  x64/arm64 architectures, and sanitizer combinations (none, ASAN, TSAN)
- run_macos_weekly.yml: Scheduled weekly testing with full matrix coverage
  and automated failure reporting via GitHub issues

Enhance test diagnostics in tests/diag.sh:
- Add separate startup timeout handling for valgrind vs normal runs
- Implement immediate crash detection during rsyslog startup
- Add comprehensive core dump analysis with platform-specific debuggers
- Improve macOS-specific error reporting and system information gathering
- Add disk space monitoring to prevent core dump creation failures
- tests/kafka: give unique names in sndrcv_kafka_multi_topics
  Rename the second omkafka action to a distinct name (kafka-fwd-2).
  Using the same action name twice can lead to only one effective
  publisher with newer builds, which caused
  tests/sndrcv_kafka_multi_topics.sh to publish to a single topic and
  fail the final count check.

Fix macOS-specific test issues:
- Skip failing TCP tests on Darwin due to TCP chunking behavior
- Add maxframesize parameter to imptcp tests for better reliability

The CI workflows include proper sanitizer configuration, core dump handling,
disk space management, and comprehensive error reporting to improve
debugging capabilities on macOS platforms.

Impact: Enables continuous testing on macOS, improves test reliability,
and provides better diagnostics for platform-specific issues.

Fixes: https://github.com/rsyslog/rsyslog/issues/5629
Refs: https://github.com/rsyslog/rsyslog/pull/5635
Refs: https://github.com/Homebrew/homebrew-core/issues/221869
Refs: https://github.com/Homebrew/homebrew-core/issues/226378
2025-09-17 12:58:46 +02:00

174 lines
4.7 KiB
Bash
Executable File

#!/bin/bash
# added 2018-08-13 by alorbach
# This file is part of the rsyslog project, released under ASL 2.0
: "${STARTUP_MAX_RUNTIME:=300}"
export STARTUP_MAX_RUNTIME
. ${srcdir:=.}/diag.sh init
export TESTMESSAGES=50000
export TESTMESSAGESFULL=100000
# Generate random topic name
export RANDTOPIC1="$(printf '%08x' "$(( (RANDOM<<16) ^ RANDOM ))")"
export RANDTOPIC2="$(printf '%08x' "$(( (RANDOM<<16) ^ RANDOM ))")"
# Set EXTRA_EXITCHECK to dump kafka/zookeeperlogfiles on failure only.
export EXTRA_EXITCHECK=dumpkafkalogs
export EXTRA_EXIT=kafka
echo STEP: Check and Stop previous instances of kafka/zookeeper
download_kafka
stop_zookeeper
stop_kafka
echo STEP: Create kafka/zookeeper instance and topics
start_zookeeper
start_kafka
create_kafka_topic $RANDTOPIC1 '.dep_wrk' '22181'
create_kafka_topic $RANDTOPIC2 '.dep_wrk' '22181'
# --- Create omkafka sender config
export RSYSLOG_DEBUGLOG="log"
generate_conf
add_conf '
main_queue(queue.timeoutactioncompletion="60000" queue.timeoutshutdown="60000")
$imdiagInjectDelayMode full
module(load="../plugins/omkafka/.libs/omkafka")
template(name="outfmt" type="string" string="%msg%\n")
local4.* action( name="kafka-fwd"
type="omkafka"
topic="'$RANDTOPIC1'"
broker="localhost:29092"
template="outfmt"
confParam=[ "compression.codec=none",
"socket.timeout.ms=10000",
"socket.keepalive.enable=true",
"reconnect.backoff.jitter.ms=1000",
"queue.buffering.max.messages=10000",
"enable.auto.commit=true",
"message.send.max.retries=1"]
topicConfParam=["message.timeout.ms=10000"]
partitions.auto="on"
closeTimeout="60000"
resubmitOnFailure="on"
keepFailedMessages="on"
failedMsgFile="'$RSYSLOG_OUT_LOG'-failed-'$RANDTOPIC1'.data"
action.resumeInterval="1"
action.resumeRetryCount="10"
queue.saveonshutdown="on"
)
local4.* action( name="kafka-fwd-2"
type="omkafka"
topic="'$RANDTOPIC2'"
broker="localhost:29092"
template="outfmt"
confParam=[ "compression.codec=none",
"socket.timeout.ms=10000",
"socket.keepalive.enable=true",
"reconnect.backoff.jitter.ms=1000",
"queue.buffering.max.messages=10000",
"enable.auto.commit=true",
"message.send.max.retries=1"]
topicConfParam=["message.timeout.ms=10000"]
partitions.auto="on"
closeTimeout="60000"
resubmitOnFailure="on"
keepFailedMessages="on"
failedMsgFile="'$RSYSLOG_OUT_LOG'-failed-'$RANDTOPIC2'.data"
action.resumeInterval="1"
action.resumeRetryCount="10"
queue.saveonshutdown="on"
)
syslog.* action(type="omfile" file="'$RSYSLOG_DYNNAME.sender.syslog'")
'
echo STEP: Starting sender instance [omkafka]
startup
# ---
# Injection messages now before starting receiver, simply because omkafka will take some time and
# there is no reason to wait for the receiver to startup first.
echo STEP: Inject messages into rsyslog sender instance
injectmsg 1 $TESTMESSAGES
# --- Create omkafka receiver config
export RSYSLOG_DEBUGLOG="log2"
generate_conf 2
add_conf '
main_queue(queue.timeoutactioncompletion="60000" queue.timeoutshutdown="60000")
module(load="../plugins/imkafka/.libs/imkafka")
/* Polls messages from kafka server!*/
input( type="imkafka"
topic="'$RANDTOPIC1'"
broker="localhost:29092"
consumergroup="default1"
confParam=[ "compression.codec=none",
"session.timeout.ms=10000",
"socket.timeout.ms=10000",
"enable.partition.eof=false",
"reconnect.backoff.jitter.ms=1000",
"socket.keepalive.enable=true"]
)
input( type="imkafka"
topic="'$RANDTOPIC2'"
broker="localhost:29092"
consumergroup="default2"
confParam=[ "compression.codec=none",
"session.timeout.ms=10000",
"socket.timeout.ms=10000",
"enable.partition.eof=false",
"reconnect.backoff.jitter.ms=1000",
"socket.keepalive.enable=true"]
)
template(name="outfmt" type="string" string="%msg:F,58:2%\n")
if ($msg contains "msgnum:") then {
action( type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt" )
}
syslog.* action(type="omfile" file="'$RSYSLOG_DYNNAME.receiver.syslog'")
' 2
echo STEP: Starting receiver instance [imkafka]
startup 2
# ---
echo STEP: Stopping sender instance [omkafka]
shutdown_when_empty
wait_shutdown
echo STEP: Stopping receiver instance [imkafka]
kafka_wait_group_coordinator
shutdown_when_empty 2
wait_shutdown 2
echo STEP: delete kafka topics
delete_kafka_topic $RANDTOPIC1 '.dep_wrk' '22181'
delete_kafka_topic $RANDTOPIC2 '.dep_wrk' '22181'
kafka_check_broken_broker "$RSYSLOG_DYNNAME.sender.syslog"
kafka_check_broken_broker "$RSYSLOG_DYNNAME.receiver.syslog"
# Dump Kafka log | uncomment if needed
# dump_kafka_serverlog
# Do the final sequence check
seq_check 1 $TESTMESSAGES -d
linecount=$(wc -l < ${RSYSLOG_OUT_LOG})
if [ $linecount -ge $TESTMESSAGESFULL ]; then
echo "Info: Count correct: $linecount"
else
echo "Count error detected in $RSYSLOG_OUT_LOG"
echo "number of lines in file: $linecount"
error_exit 1
fi
echo success
exit_test