Skip to content

[fix][test] Absorb Backoff jitter in PulsarServiceNameResolverTest.testRemoveUnavailableHost - #25714

Merged
merlimat merged 1 commit into
apache:masterfrom
merlimat:fix/resolver-test-backoff-jitter
May 8, 2026
Merged

[fix][test] Absorb Backoff jitter in PulsarServiceNameResolverTest.testRemoveUnavailableHost#25714
merlimat merged 1 commit into
apache:masterfrom
merlimat:fix/resolver-test-backoff-jitter

Conversation

@merlimat

@merlimat merlimat commented May 7, 2026

Copy link
Copy Markdown
Contributor

Motivation

The Backoff refactor in #25278 changed jitter from a one-sided "decrease only, clamped to initial" model to symmetric ±5%. As a result, the first call to Backoff.next() with initialDelay=1000ms can now return up to ~1050ms, whereas before it always returned exactly 1000ms.

PulsarServiceNameResolverTest.testRemoveUnavailableHost sleeps for exactly INIT_QUARANTINE_TIME_MS (1000ms) and then expects host1 to recover. With positive jitter, the recovery delay can exceed the sleep, so the elapsed-time check in computeEndpointStatus returns false and host1 stays unavailable, producing a flaky assertion failure on CI:

java.lang.AssertionError: Sets differ:
  expected [host2/<unresolved>:6651, host1/<unresolved>:6651, host3/<unresolved>:6651]
       but got [host2/<unresolved>:6651, host3/<unresolved>:6651]

Modifications

Sleep INIT_QUARANTINE_TIME_MS + 200ms instead of exactly INIT_QUARANTINE_TIME_MS, to absorb the ±5% jitter applied by the new Backoff implementation.

Verifying this change

This change is a trivial test fix.

Verified locally by running the test 5x with --rerun-tasks:

./gradlew :pulsar-client-original:test --tests \
  "org.apache.pulsar.client.impl.PulsarServiceNameResolverTest.testRemoveUnavailableHost" \
  --rerun-tasks

All 5 runs 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

…stRemoveUnavailableHost

The Backoff refactor in apache#25278 changed jitter from a one-sided "decrease only,
clamped to initial" model to symmetric ±5%. As a result, the first call to
Backoff.next() with initialDelay=1000ms can now return up to 1050ms, whereas
before it always returned exactly 1000ms.

testRemoveUnavailableHost sleeps for exactly INIT_QUARANTINE_TIME_MS (1000ms)
and then expects host1 to be recovered. With positive jitter, the recovery
delay can exceed the sleep, so the elapsed-time check in computeEndpointStatus
returns false and host1 stays unavailable, producing the assertion failure
seen on CI.

Sleep INIT_QUARANTINE_TIME_MS + 200ms to absorb the ±5% jitter.
@lhotari
lhotari self-requested a review May 8, 2026 17:01

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@merlimat
merlimat merged commit 5b4deb9 into apache:master May 8, 2026
43 checks passed
@lhotari lhotari added this to the 5.0.0-M1 milestone Jun 12, 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