test(sdk-core): Fix flaky test failures in FileAsyncResponseTransformerPublisherTest#7044
Merged
joviegas merged 2 commits intoJun 17, 2026
Merged
Conversation
…her in FileAsyncResponseTransformerPublisherTest to prevent flaky test failures
Fred1155
approved these changes
Jun 17, 2026
joviegas
enabled auto-merge
June 17, 2026 16:45
|
This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Use Flowable.just instead of hand-written mock publisher in FileAsyncResponseTransformerPublisherTest to prevent flaky test failures
Motivation and Context
Test
FileAsyncResponseTransformerPublisherTest.requestManyTransformers_withResponseContainingDifferentContentRanges_shouldWriteToFileAtThoseRangeswas flaky. It failed intermittently with "Expected size: 80 but was: 90" because some bytes were written to the file twice.The possible root cause was the hand-written mock publisher used in the test. It emitted its data and called
onCompleteevery timerequest(n)was called.FileSubscriberrequests the next element after each write, so when the async file write finished beforeonCompletewas processed,FileSubscriberrequested again and the mock delivered the same bytes a second time. This is a race between the write completion andonComplete, which is why it only failed intermittently.Modifications
Replaced the hand-written mock publisher with a spec-conformant publisher,
SdkPublisher.adapt(Flowable.just(...)), which emits the data exactly once and does not re-emit on later requests. This is the same pattern already used inFileAsyncResponseTransformerTest(itstestPublisherhelper) for the sameFileSubscriberwrite path. Updated both helpers in the test,createMockPublisherWithDataandcreateMockPublisher.License