test(android): Stabilize InternalSentrySdk session persistence tests - #6082
Closed
buenaflor wants to merge 2 commits into
Closed
test(android): Stabilize InternalSentrySdk session persistence tests#6082buenaflor wants to merge 2 commits into
buenaflor wants to merge 2 commits into
Conversation
📲 Install BuildsAndroid
|
buenaflor
marked this pull request as ready for review
September 9, 2026 13:31
buenaflor
requested review from
0xadam-brown,
adinauer,
markushi,
romtsn and
runningcode
as code owners
September 9, 2026 13:31
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is test-only and low risk, and the stabilization approach aligns with the described flake root cause.
Pull request overview
This PR stabilizes InternalSentrySdkTest session persistence behavior by making SDK startup/session-rotation work deterministic in the tests that read session.json, and re-enables the previously ignored flaky test.
Changes:
- Make the test fixture’s executor configurable so tests can force synchronous startup work when needed.
- Re-enable the previously
@Ignored dropped-unhandled-error session persistence test by removing the timing dependency. - Use
ImmediateExecutorServiceonly for the tests that read the persisted session file.
File summaries
| File | Description |
|---|---|
| sentry-android-core/src/test/java/io/sentry/android/core/InternalSentrySdkTest.kt | Adds executor override to fixture init and applies ImmediateExecutorService to persisted-session-reading tests to prevent flaky FileNotFoundExceptions. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
489
to
491
| val fixture = Fixture() | ||
| fixture.init(context) | ||
| fixture.init(context, executorService = ImmediateExecutorService()) | ||
|
|
buenaflor
marked this pull request as draft
September 9, 2026 13:37
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
Re-enable the ignored
InternalSentrySdkTestfor dropped unhandled errors. Make the fixture's executor configurable and opt intoImmediateExecutorServiceonly in the three tests that read the persisted session. Other tests keep the default executor.💡 Motivation and Context
The test added in #5990 was disabled in #6078 after intermittent
FileNotFoundExceptionfailures. SDK initialization queuesMovePreviousSessionasynchronously; if it runs after the test persists its live session, it renamessession.jsontoprevious_session.jsonbefore the test reads it. Completing startup work synchronously in the affected tests removes that timing dependency.💚 How did you test it?
:sentry-android-core:testReleaseUnitTest --tests='*InternalSentrySdkTest*' --rerun --no-daemon --no-configuration-cacheon commit13c17fac5700048893de0dd4af5f7e90e47c95d410 consecutive times, forcing fresh executions: all 24 tests passed in every run (240 test executions total), with zero failures, errors, or skips.spotlessApply apiDump: passed.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Follow up separately on the SDK's runtime ordering between startup session rotation and synchronous session persistence.
#skip-changelog