Skip to content

Isolate flush tests from other Analytics instances - #453

Merged
didiergarcia merged 1 commit into
mainfrom
fix/deflake-flush-tests
Oct 20, 2026
Merged

didiergarcia merged 1 commit into
mainfrom
fix/deflake-flush-tests

Conversation

@didiergarcia

@didiergarcia didiergarcia commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the flaky timeouts in FlushFiles_Tests and BackgroundFlush_Tests seen on recent Swift CI runs.

Every Analytics instance uses the shared OperatingMode.defaultQueue as 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.

  • Each test now gets its own flush queue.
  • BackgroundFlush_Tests uses RestrictedHTTPSession, so no real network.
  • testBackgroundingFlushesOnce sends 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.testMemoryStorageRolloff and StressTests are flaky too, for a different reason (they hit the network). Not covered here.

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.
@didiergarcia
didiergarcia merged commit 79ab6e1 into main Oct 20, 2026
19 of 20 checks passed
@didiergarcia
didiergarcia deleted the fix/deflake-flush-tests branch October 20, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants