Skip to content

test(sdk-core): Fix flaky test failures in FileAsyncResponseTransformerPublisherTest#7044

Merged
joviegas merged 2 commits into
masterfrom
joviegas/flaky_test_FileAsyncResponseTransformer
Jun 17, 2026
Merged

test(sdk-core): Fix flaky test failures in FileAsyncResponseTransformerPublisherTest#7044
joviegas merged 2 commits into
masterfrom
joviegas/flaky_test_FileAsyncResponseTransformer

Conversation

@joviegas

Copy link
Copy Markdown
Contributor

Use Flowable.just instead of hand-written mock publisher in FileAsyncResponseTransformerPublisherTest to prevent flaky test failures

Motivation and Context

Test FileAsyncResponseTransformerPublisherTest.requestManyTransformers_withResponseContainingDifferentContentRanges_shouldWriteToFileAtThoseRanges was 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 onComplete every time request(n) was called. FileSubscriber requests the next element after each write, so when the async file write finished before onComplete was processed, FileSubscriber requested again and the mock delivered the same bytes a second time. This is a race between the write completion and onComplete, 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 in FileAsyncResponseTransformerTest (its testPublisher helper) for the same FileSubscriber write path. Updated both helpers in the test, createMockPublisherWithData and createMockPublisher.

License

  • I confirm that this pull request can be released under the Apache 2 license

…her in FileAsyncResponseTransformerPublisherTest to prevent flaky test failures
@joviegas
joviegas requested a review from a team as a code owner June 17, 2026 16:12
@joviegas
joviegas enabled auto-merge June 17, 2026 16:45
@joviegas
joviegas added this pull request to the merge queue Jun 17, 2026
Merged via the queue into master with commit 34df128 Jun 17, 2026
12 of 13 checks passed
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants