diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/InternalSentrySdkTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/InternalSentrySdkTest.kt index ba0322c7a1..031df4c523 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/InternalSentrySdkTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/InternalSentrySdkTest.kt @@ -38,13 +38,13 @@ import java.io.ByteArrayOutputStream import java.io.InputStreamReader import java.util.concurrent.atomic.AtomicReference import kotlin.test.BeforeTest -import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotEquals import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue +import org.awaitility.kotlin.await import org.junit.runner.RunWith import org.mockito.kotlin.mock import org.mockito.kotlin.whenever @@ -87,6 +87,12 @@ class InternalSentrySdkTest { } } + // Sentry.init moves any leftover session.json to previous_session.json on the executor. Wait + // for that to finish, otherwise it can move the session a test has just persisted. Test + // options set sessionFlushTimeoutMillis to 0, so waitPreviousSessionFlush() only polls. + val cache = options.envelopeDiskCache as EnvelopeCache + await.until { cache.waitPreviousSessionFlush() } + capturedEnvelopes.clear() } @@ -634,14 +640,6 @@ class InternalSentrySdkTest { assertThat(activeSession.get().sessionId).isNotEqualTo(oldSid) } - // Flaky: intermittently fails with FileNotFoundException reading session.json at the - // `sessionFile.reader()` call below, i.e. persistCurrentSession() did not leave a session file - // on disk by the time this test reads it back. Seen across unrelated PRs, e.g.: - // https://scans.gradle.com/s/55fnn6xhtfyfq/tests/task/:sentry-android-core:testReleaseUnitTest/details/io.sentry.android.core.InternalSentrySdkTest/updateSessionForDroppedEventNonTerminating%20flags%20an%20unhandled%20error%20without%20sending%20an%20envelope?top-execution=1 - // https://scans.gradle.com/s/ojzzz4yxag7rw/tests/task/:sentry-android-core:testReleaseUnitTest/details/io.sentry.android.core.InternalSentrySdkTest/updateSessionForDroppedEventNonTerminating%20flags%20an%20unhandled%20error%20without%20sending%20an%20envelope?top-execution=1 - // Disabling until root-caused; see https://github.com/getsentry/sentry-java/pull/5990 for the - // code under test. - @Ignore("Flaky: intermittently fails to find the persisted session.json, needs root-causing") @Test fun `updateSessionForDroppedEventNonTerminating flags an unhandled error without sending an envelope`() { val fixture = Fixture()