Repository navigation
Isolate flush tests from other Analytics instances - #453
Merged
Merged
Conversation
BackgroundFlush_Tests and FlushFiles_Tests shared the default flush queue with every instance left alive by earlier tests, so a busy queue on CI could push flush completions past the 5s timeout. Give each test its own flush queue, block network in BackgroundFlush_Tests, and deliver the background notification to the instance under test only.
MichaelGHSeg
approved these changes
Oct 20, 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.
Fixes the flaky timeouts in
FlushFiles_TestsandBackgroundFlush_Testsseen on recent Swift CI runs.Every
Analyticsinstance uses the sharedOperatingMode.defaultQueueas its flush queue by default. Instances left alive by earlier tests keep queuing work there, and a flush completion is queued behind it, so on a slow runner the completion can miss the 5s expectation.BackgroundFlush_TestsusesRestrictedHTTPSession, so no real network.testBackgroundingFlushesOncesends the background notification to the instance under test only. Posting it globally made every live instance flush.Verified: with work injected onto the shared queue, the old tests fail with the same timeouts as CI and the new ones pass. Full suites pass locally on macOS (227), iOS (243), tvOS (239) and watchOS (222).
StorageTests.testMemoryStorageRolloffandStressTestsare flaky too, for a different reason (they hit the network). Not covered here.