[fix][test] Make SameAuthParamsLookupAutoClusterFailoverTest less timing-sensitive - #25675
Merged
merlimat merged 1 commit intoMay 5, 2026
Conversation
…ing-sensitive The test wraps `producer.send(...)` and `getCurrentPulsarServiceIndex()` inside `Awaitility.untilAsserted(...)` together with the state-array convergence check. When state has converged but a producer reconnect is still in flight (closeAllConnections() runs inside updateServiceUrl), each retry of the lambda burns up to the producer send timeout (~30s), which on slow CI agents can exhaust the per-phase budget even though the failover state machine already settled. Split the convergence check from the side checks: - Wait for the per-index state and currentPulsarServiceIndex inside the Awaitility loop (cheap reads only). - Move `producer.send(...)` outside the loop so it runs exactly once per phase and surfaces send failures directly. Also extracted small helpers `awaitStatesAndIndex`/`assertStatesEqual` to remove the repetitive submit-future-join boilerplate, and bumped the per-phase budget to 180s with an overall 12 minute timeout to absorb slow CI agents (the probe timeout is 3s and a single failed probe during recovery resets recoverThreshold).
lhotari
approved these changes
May 5, 2026
2 tasks
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
May 6, 2026
sandeep-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 31, 2026
…ing-sensitive (apache#25675) (cherry picked from commit 17c6b13)
nodece
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Aug 28, 2026
…ing-sensitive (apache#25675) (cherry picked from commit 17c6b13)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
SameAuthParamsLookupAutoClusterFailoverTest.testAutoClusterFailoverwaits for the failover state machine to converge across three phases (failover 0→2, recover 2→1, recover 1→0). Each phase uses anAwaitility.untilAsserted(...)lambda that combined three assertions:pulsarServiceStateArraymatches the expected states.producer.send(...)succeeds.failover.getCurrentPulsarServiceIndex()returns the expected index.When the failover state has converged but the producer's underlying connection is still being re-established (
updateServiceUrlcallscnxPool.closeAllConnections()), theproducer.send(...)retry inside the lambda can stall up to the producer's send timeout (~30s). Each retry of the lambda then burns ~30s of the per-phase budget, even though the failover state machine itself already settled. On slow CI agents this causes the per-phase 120s budget to time out at phase 3 withexpected [true] but found [false].Example failure: https://scans.gradle.com/s/xiv7nu4ujnh5c/tests/task/:pulsar-broker:test/details/org.apache.pulsar.broker.SameAuthParamsLookupAutoClusterFailoverTest/testAutoClusterFailover%5B4%5D(false)/1/output
Modifications
Split the convergence check from the side checks per phase:
Awaitility.untilAsserted(...)only for the per-index state andcurrentPulsarServiceIndex(cheap reads on the failover executor).producer.send(...)outside the await loop so it runs once per phase and surfaces send failures directly.Also extracted small helpers (
awaitStatesAndIndex,assertStatesEqual) to remove the repetitive submit-future-join boilerplate, and bumped the per-phase budget to 180s with an overall 12-minute timeout (the probe timeout is 3s and a single failed probe during recovery resetsrecoverThreshold, so a phase can need up to ~30s of healthy probes to recover).Verifying this change
This change is already covered by existing tests:
SameAuthParamsLookupAutoClusterFailoverTest.testAutoClusterFailover(TLS and non-TLS variants).Locally I ran 3 times in a row with fresh Gradle daemons; each run took ~17s per variant and all passed.
Does this pull request potentially affect one of the following parts: