Skip to content

Keep a slow critical event log export from failing other tests - #2622

Merged
ps2 merged 1 commit into
next-devfrom
fix/export-tests-timing
Oct 28, 2026
Merged

ps2 merged 1 commit into
next-devfrom
fix/export-tests-timing

Conversation

@ps2

@ps2 ps2 commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

CriticalEventLogExportManagerTests.testExportPartial failed CircleCI runs 1320 and 1321 for LoopKit/LoopWorkspace#566, and the export tests failed the same way on 1310 and 1312.

The full export runs on a background queue. On CI it sometimes runs past the test's 10 s wait. On 1321 it finished about 18 s after it started, right after the LoopTests bundle ended. When that happens:

  • the late completion handler's asserts land on whichever test is running (the "couldn't be moved" failure under testExportPartial on 1310)
  • the handler reads self.fileManager, which tearDown has set to nil, and crashes the test process

The handlers now only record the error. Each test checks the result after its wait, and the wait is 60 s. A passing run still takes well under a second.

The slowness itself looks like thread starvation in the test host. In 1321's crash report, 6 threads are blocked on a semaphore in HealthStoreUnitCache.getHealthStoreUnitAndUpdateCache(for:), called from LiveActivityManager.update() tasks. Each waits up to 3 s for HealthKit preferred units. That's left for a separate change.

Tested on the simulator:

  • the export tests 20 times in a row, all passing
  • with the timeout forced to 1 ms so every completion arrives late: only the two slow tests fail, nothing crashes, and DeviceDataManagerTests, which runs next, passes

On CI the full export in testExportPartial sometimes runs past the 10 s
wait. Its completion handler then fires after tearDown, so its asserts land
on whichever test is running and the IUO properties it reads are nil, which
crashes the test process. In LoopKit/LoopWorkspace#566's runs 1320 and 1321
the export finished about 18 s in, right after the LoopTests bundle ended.

The handlers now only record the error; the checks run after the wait, and
the wait is 60 s.
@ps2
ps2 merged commit 3c4f8b0 into next-dev Oct 28, 2026
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.

1 participant