Skip to content

[fix][test] Make SameAuthParamsLookupAutoClusterFailoverTest less timing-sensitive - #25675

Merged
merlimat merged 1 commit into
apache:masterfrom
merlimat:mmerli/fix-flaky-same-auth-params-failover-test
May 5, 2026
Merged

[fix][test] Make SameAuthParamsLookupAutoClusterFailoverTest less timing-sensitive#25675
merlimat merged 1 commit into
apache:masterfrom
merlimat:mmerli/fix-flaky-same-auth-params-failover-test

Conversation

@merlimat

@merlimat merlimat commented May 5, 2026

Copy link
Copy Markdown
Contributor

Motivation

SameAuthParamsLookupAutoClusterFailoverTest.testAutoClusterFailover waits for the failover state machine to converge across three phases (failover 0→2, recover 2→1, recover 1→0). Each phase uses an Awaitility.untilAsserted(...) lambda that combined three assertions:

  1. The per-index pulsarServiceStateArray matches the expected states.
  2. producer.send(...) succeeds.
  3. failover.getCurrentPulsarServiceIndex() returns the expected index.

When the failover state has converged but the producer's underlying connection is still being re-established (updateServiceUrl calls cnxPool.closeAllConnections()), the producer.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 with expected [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:

  • Wait inside Awaitility.untilAsserted(...) only for the per-index state and currentPulsarServiceIndex (cheap reads on the failover executor).
  • Move 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 resets recoverThreshold, 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:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

…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).
@merlimat
merlimat merged commit 17c6b13 into apache:master May 5, 2026
79 of 83 checks passed
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request May 6, 2026
@lhotari lhotari added this to the 5.0.0-M1 milestone Jun 12, 2026
lhotari pushed a commit that referenced this pull request Jun 22, 2026
lhotari pushed a commit that referenced this pull request Jun 22, 2026
sandeep-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 31, 2026
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants