[fix][test] Fix flaky AdminApiOffloadTest.testOffload status race#25674
Merged
merlimat merged 1 commit intoMay 5, 2026
Merged
Conversation
The post-failure status check ran synchronously right after `promise.completeExceptionally(...)`, but the offload failure handler runs asynchronously after the promise completes. This left a window where `offloadStatus()` still reported `RUNNING` when the assertion fired, producing the observed flake `expected [ERROR] but found [RUNNING]`. Wrap the assertion in `Awaitility.untilAsserted(...)` to allow the status to converge to ERROR, mirroring the success path below.
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
May 6, 2026
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
AdminApiOffloadTest.testOffload(parameterized astestOffloadV1andtestOffloadV2) checks the offload status immediately after completing the offload promise exceptionally:The failure handler that updates the offload status to
ERRORruns asynchronously after the promise completes. The synchronous assertion races with that handler and occasionally observesRUNNING, producing the flakeexpected [ERROR] but found [RUNNING].Example failure: https://scans.gradle.com/s/nv4xn5dwytjvs/tests/task/:pulsar-broker:test/details/org.apache.pulsar.broker.admin.AdminApiOffloadTest/testOffloadV2/2/output
Modifications
Wrap the
ERRORstatus assertion inAwaitility.untilAsserted(...)so the test waits for the failure handler to update the status, mirroring the success path immediately below it (which already used Awaitility).Verifying this change
This change is already covered by existing tests:
AdminApiOffloadTest.testOffloadV1AdminApiOffloadTest.testOffloadV2Locally I ran both 3 times in a row with fresh Gradle daemons; each run took ~0.4–0.9s and all passed.
Does this pull request potentially affect one of the following parts: