testbench: fix wait_startup() to use per-startup timeout, not global test start

wait_startup() was checking the elapsed time against TB_STARTTEST (set
once when the test begins), so any test that calls startup() multiple
times with message-processing phases in between could exhaust the 60 s
startup budget before the last startup even gets a chance to wait.

diskqueue-oncorruption-missing-segment.sh is the canonical example: it
runs three corruption modes each with two rsyslog invocations; the first
invocation of each mode injects 15,000 messages (~20 s on arm64/ASAN),
so by the time the sixth startup is attempted the global clock has
already ticked past TB_STARTTEST + 60.

Fix: record a per-call deadline at the top of wait_startup() and check
against that instead of the global test-start time.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Rainer Gerhards 2026-03-29 17:27:10 +02:00
parent 5a78def249
commit 0b01717a1d

View File

@ -940,6 +940,11 @@ wait_startup() {
local instance=$1
local pid_file="$RSYSLOG_PIDBASE$instance.pid"
local imdiag_port_file="$RSYSLOG_DYNNAME.imdiag$instance.port"
# Per-startup deadline: each rsyslog instance gets TB_STARTUP_MAX_RUNTIME
# seconds from the moment wait_startup() is called. Using TB_STARTTEST
# (global test start) would exhaust the budget in tests that call startup()
# multiple times with message-processing phases in between.
local startup_deadline=$(( $(date +%s) + TB_STARTUP_MAX_RUNTIME ))
while :; do
if [ -s "$imdiag_port_file" ]; then
# port file seen — quick liveness check before trusting it
@ -954,8 +959,8 @@ wait_startup() {
printf '%s ABORT! rsyslog exited during startup (config error?)\n' "$(tb_timestamp)"
error_exit 1 stacktrace
fi
# timeout check
if [ $(date +%s) -gt $(( TB_STARTTEST + TB_STARTUP_MAX_RUNTIME )) ]; then
# per-startup timeout check
if [ $(date +%s) -gt $startup_deadline ]; then
[ -s "$imdiag_port_file" ] && break
printf '%s ABORT! Timeout waiting for imdiag port file (%s) after %d seconds\n' \
"$(tb_timestamp)" "$imdiag_port_file" $TB_STARTUP_MAX_RUNTIME