Skip to content

test(android): Stabilize InternalSentrySdk session persistence tests - #6082

Closed
buenaflor wants to merge 2 commits into
mainfrom
codex/stabilize-internal-sentry-sdk-test
Closed

test(android): Stabilize InternalSentrySdk session persistence tests#6082
buenaflor wants to merge 2 commits into
mainfrom
codex/stabilize-internal-sentry-sdk-test

Conversation

@buenaflor

@buenaflor buenaflor commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

📜 Description

Re-enable the ignored InternalSentrySdkTest for dropped unhandled errors. Make the fixture's executor configurable and opt into ImmediateExecutorService only 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 FileNotFoundException failures. SDK initialization queues MovePreviousSession asynchronously; if it runs after the test persists its live session, it renames session.json to previous_session.json before the test reads it. Completing startup work synchronously in the affected tests removes that timing dependency.

💚 How did you test it?

  • Ran :sentry-android-core:testReleaseUnitTest --tests='*InternalSentrySdkTest*' --rerun --no-daemon --no-configuration-cache on commit 13c17fac5700048893de0dd4af5f7e90e47c95d4 10 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.
  • During investigation, a deferred executor deterministically reproduced the missing-file exception by running queued startup work between the session write and read.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Follow up separately on the SDK's runtime ordering between startup session rotation and synchronous session persistence.

#skip-changelog

@sentry

sentry Bot commented Sep 9, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.55.0 (1) release

⚙️ sentry-android Build Distribution Settings

@buenaflor
buenaflor marked this pull request as ready for review September 9, 2026 13:31
Copilot AI lite review requested due to automatic review settings September 9, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 ImmediateExecutorService only 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
buenaflor marked this pull request as draft September 9, 2026 13:37
@buenaflor buenaflor closed this Sep 9, 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.

2 participants