Skip to content

Commit 04f0226

Browse files
runningcodeclaude
andauthored
test(android): Stop memory limiter tests waiting on flush timeouts (#6211)
MemoryLimiterIntegrationTest and ApplicationExitInfoCrossIntegrationTest kept the default 15s flush and session flush timeouts. Nothing in these tests releases those latches, so every integration registration and every captured event blocked for the full timeout. The two classes took about 8 minutes combined and now take under 2 seconds. Also drop the manual cache dir cleanup in these two tests and in AnrV2IntegrationTest. The TemporaryFolder rule already deletes it after each test. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 46c9604 commit 04f0226

3 files changed

Lines changed: 6 additions & 18 deletions

File tree

‎sentry-android-core/src/test/java/io/sentry/android/core/AnrV2IntegrationTest.kt‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import java.io.File
1212
import kotlin.test.Test
1313
import kotlin.test.assertEquals
1414
import kotlin.test.assertNotNull
15-
import org.junit.After
1615
import org.junit.runner.RunWith
1716
import org.mockito.kotlin.any
1817
import org.mockito.kotlin.anyOrNull
@@ -163,11 +162,6 @@ class AnrV2IntegrationTest : ApplicationExitIntegrationTestBase<AnrV2Hint>() {
163162
assertEquals("/apex/com.android.runtime/lib64/bionic/libc.so", image.codeFile)
164163
}
165164

166-
@After
167-
fun cleanup() {
168-
fixture.options.cacheDirPath?.let { File(it).deleteRecursively() }
169-
}
170-
171165
@Test
172166
fun `when latest ANR has foreground importance, sets abnormal mechanism to anr_foreground`() {
173167
val integration =

‎sentry-android-core/src/test/java/io/sentry/android/core/ApplicationExitInfoCrossIntegrationTest.kt‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import io.sentry.protocol.SentryId
1414
import io.sentry.test.ImmediateExecutorService
1515
import java.io.File
1616
import java.util.zip.GZIPInputStream
17-
import kotlin.test.AfterTest
1817
import kotlin.test.BeforeTest
1918
import kotlin.test.Test
2019
import org.junit.Rule
@@ -63,6 +62,9 @@ class ApplicationExitInfoCrossIntegrationTest {
6362
setLogger(logger)
6463
isDebug = true
6564
cacheDirPath = dir.absolutePath
65+
// Nothing ever releases these latches here, so every wait would run to its timeout.
66+
flushTimeoutMillis = 0L
67+
sessionFlushTimeoutMillis = 0L
6668
executorService = ImmediateExecutorService()
6769
setEnvelopeDiskCache(EnvelopeCache.create(this))
6870
addInAppInclude("io.sentry.samples")
@@ -151,11 +153,6 @@ class ApplicationExitInfoCrossIntegrationTest {
151153
fixture.init(ApplicationProvider.getApplicationContext())
152154
}
153155

154-
@AfterTest
155-
fun `tear down`() {
156-
tmpDir.root.deleteRecursively()
157-
}
158-
159156
@Test
160157
fun `memory limiter and anr integrations each capture only their own exits from shared history`() {
161158
val memoryLimiterTimestamp = System.currentTimeMillis() - 1_000

‎sentry-android-core/src/test/java/io/sentry/android/core/MemoryLimiterIntegrationTest.kt‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import io.sentry.test.ImmediateExecutorService
1818
import io.sentry.transport.CurrentDateProvider
1919
import io.sentry.util.HintUtils
2020
import java.io.File
21-
import kotlin.test.AfterTest
2221
import kotlin.test.BeforeTest
2322
import kotlin.test.Test
2423
import kotlin.test.assertEquals
@@ -78,6 +77,9 @@ class MemoryLimiterIntegrationTest {
7877
setLogger(this@Fixture.logger)
7978
isDebug = true
8079
cacheDirPath = dir?.newFolder()?.absolutePath
80+
// Nothing ever releases these latches here, so every wait would run to its timeout.
81+
flushTimeoutMillis = 0L
82+
sessionFlushTimeoutMillis = 0L
8183
executorService = if (useImmediateExecutorService) ImmediateExecutorService() else mock()
8284
isMemoryLimiterEnabled = memoryLimiterEnabled
8385
isReportHistoricalMemoryLimiterExits = reportHistoricalMemoryLimiterExits
@@ -134,11 +136,6 @@ class MemoryLimiterIntegrationTest {
134136
fixture.init(context)
135137
}
136138

137-
@AfterTest
138-
fun `tear down`() {
139-
fixture.options.cacheDirPath?.let { File(it).deleteRecursively() }
140-
}
141-
142139
@Test
143140
fun `does not process MemoryLimiter exits when integration is disabled`() {
144141
val integration =

0 commit comments

Comments
 (0)