Repository navigation
test: [SDK-5663] fix flaky User and Core unit tests - #1794
Merged
Merged
Conversation
- MockOneSignalClient: record a request and choose its response in one locked step, and lock all shared state read from the test thread. - Read OSUserExecutor's request queue through its dispatch queue in tests. - UserJwtLifecycleTests: wait for the 401 to be fully handled before supplying the replacement token. - OSConsistencyManagerTests: drop fixed delays from the multi-key test. - CI: save the xcresult, print failure messages, and upload it on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nan-li
approved these changes
Nov 6, 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.
Description
One Line Summary
Fix the data races and timing assumptions behind the intermittent User and Core unit test failures on CI, and make CI print test failure messages.
Details
Motivation
The "Build and Test using any available iPhone simulator" job failed intermittently on tests unrelated to the PR under test. With all cores loaded locally,
UserJwtLifecycleTests.testUpdateUserJwtSendsTheCreateUserThatARejectedTokenHeldfailed 3/15 runs, and another JWT test crashed with heap corruption. Causes:MockOneSignalClientrecorded a request as executed before choosing its mock response. A test that saw "executed" and then registered the retry's success response could turn the first attempt's 401 into a success, so nothing was re-sent.OSUserExecutor.userRequestQueuedirectly while the executor mutated it on its own queue (likely source of the heap corruption).OSConsistencyManagerTests.testMultipleConditionsWithDifferentKeysrelied on fixed 1.0s + 0.1s delays fitting inside a 3s wait.CI ran with
-quietand only listed failing test names, so none of this was visible.Scope
MockOneSignalClient: record and pick the response in one locked step; all shared state behind the lock.snapshotUserRequestQueue()reads the queue on the executor's queue (same pattern assnapshotDeltaQueue()).OSUserExecutor.dispatchQueuegoes fromprivateto internal for this; no other production change.testUpdateUserJwt...waits for the 401 to be fully handled before supplying the new token..xcresult, prints failures as error annotations, and uploads the bundle on failure.Not covered: the
SwitchUserIntegrationTestsandFileLogStoreRecordDatingTestsfailures did not reproduce locally. The new CI output will show their messages if they recur. The iOS 27 scene lifecycle crash is separate.Testing
Unit testing
Temporary iOS 26.5 simulator, all 14 cores loaded with
yes,-maximum-parallel-testing-workers 1like CI:Manual testing
Not applicable, test and CI only.
Affected code checklist
Checklist
Overview
Testing
Final pass
🤖 Generated with Claude Code