Skip to content

Commit 1beedef

Browse files
committed
RUM-9917 improve speed of running core-it suite
1 parent 60a1945 commit 1beedef

File tree

6 files changed

+54
-50
lines changed

6 files changed

+54
-50
lines changed

reliability/core-it/src/androidTest/kotlin/com/datadog/android/core/integration/tests/BaseTest.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ import java.util.concurrent.TimeUnit
1212
abstract class BaseTest {
1313

1414
companion object {
15-
internal val LONG_WAIT_MS = TimeUnit.SECONDS.toMillis(60)
16-
internal val MEDIUM_WAIT_MS = TimeUnit.SECONDS.toMillis(30)
17-
18-
// TODO RUM-9917 Avoid using unconditional wait locks
19-
// to align with UploadFrequency max value + 1s for async execution
20-
internal val UPLOAD_CYCLE_MAX_WAIT_MS = TimeUnit.SECONDS.toMillis(6)
21-
internal const val SHORT_WAIT_MS = 500L
15+
internal val MEDIUM_WAIT_MS = TimeUnit.SECONDS.toMillis(10)
16+
internal const val SHORT_WAIT_MS = 100L
2217
}
2318
}

reliability/core-it/src/androidTest/kotlin/com/datadog/android/core/integration/tests/FeatureScopeTest.kt

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class FeatureScopeTest : MockServerTest() {
120120
.withTrackingConsent(trackingConsent)
121121
.receivedData(fakeBatchData, fakeBatchMetadata)
122122
true
123-
}.doWait(LONG_WAIT_MS)
123+
}.doWait(MEDIUM_WAIT_MS)
124124
}
125125

126126
@Test
@@ -155,7 +155,7 @@ class FeatureScopeTest : MockServerTest() {
155155
.withTrackingConsent(trackingConsent)
156156
.receivedData(fakeBatchData, fakeBatchMetadata)
157157
true
158-
}.doWait(LONG_WAIT_MS)
158+
}.doWait(MEDIUM_WAIT_MS)
159159
}
160160

161161
@Test
@@ -189,7 +189,7 @@ class FeatureScopeTest : MockServerTest() {
189189
.withTrackingConsent(trackingConsent)
190190
.receivedData(fakeBatchData, null)
191191
true
192-
}.doWait(LONG_WAIT_MS)
192+
}.doWait(MEDIUM_WAIT_MS)
193193
}
194194

195195
// endregion
@@ -224,12 +224,13 @@ class FeatureScopeTest : MockServerTest() {
224224

225225
// Then
226226
countDownLatch.await(MEDIUM_WAIT_MS, TimeUnit.MILLISECONDS)
227-
// TODO RUM-9917 Avoid using unconditional wait locks
228-
Thread.sleep(UPLOAD_CYCLE_MAX_WAIT_MS)
229-
MockWebServerAssert.assertThat(getMockServerWrapper())
230-
.withConfiguration(fakeConfiguration)
231-
.withTrackingConsent(trackingConsent)
232-
.didNotReceiveData(fakeBatchData, fakeBatchMetadata)
227+
ConditionWatcher {
228+
MockWebServerAssert.assertThat(getMockServerWrapper())
229+
.withConfiguration(fakeConfiguration)
230+
.withTrackingConsent(trackingConsent)
231+
.didNotReceiveData(fakeBatchData, fakeBatchMetadata)
232+
true
233+
}.doWait(MEDIUM_WAIT_MS)
233234
}
234235

235236
// endregion
@@ -264,12 +265,13 @@ class FeatureScopeTest : MockServerTest() {
264265

265266
// Then
266267
countDownLatch.await(MEDIUM_WAIT_MS, TimeUnit.MILLISECONDS)
267-
// TODO RUM-9917 Avoid using unconditional wait locks
268-
Thread.sleep(UPLOAD_CYCLE_MAX_WAIT_MS)
269-
MockWebServerAssert.assertThat(getMockServerWrapper())
270-
.withConfiguration(fakeConfiguration)
271-
.withTrackingConsent(trackingConsent)
272-
.didNotReceiveData(fakeBatchData, fakeBatchMetadata)
268+
ConditionWatcher {
269+
MockWebServerAssert.assertThat(getMockServerWrapper())
270+
.withConfiguration(fakeConfiguration)
271+
.withTrackingConsent(trackingConsent)
272+
.didNotReceiveData(fakeBatchData, fakeBatchMetadata)
273+
true
274+
}.doWait(MEDIUM_WAIT_MS)
273275
}
274276

275277
@Test
@@ -305,12 +307,13 @@ class FeatureScopeTest : MockServerTest() {
305307
shutdown()
306308
awaitTermination(MEDIUM_WAIT_MS, TimeUnit.MILLISECONDS)
307309
}
308-
// TODO RUM-9917 Avoid using unconditional wait locks
309-
Thread.sleep(UPLOAD_CYCLE_MAX_WAIT_MS)
310-
MockWebServerAssert.assertThat(getMockServerWrapper())
311-
.withConfiguration(fakeConfiguration)
312-
.withTrackingConsent(trackingConsent)
313-
.didNotReceiveData(fakeBatchData, fakeBatchMetadata)
310+
ConditionWatcher {
311+
MockWebServerAssert.assertThat(getMockServerWrapper())
312+
.withConfiguration(fakeConfiguration)
313+
.withTrackingConsent(trackingConsent)
314+
.didNotReceiveData(fakeBatchData, fakeBatchMetadata)
315+
true
316+
}.doWait(MEDIUM_WAIT_MS)
314317
}
315318

316319
// endregion
@@ -351,12 +354,13 @@ class FeatureScopeTest : MockServerTest() {
351354
shutdown()
352355
awaitTermination(MEDIUM_WAIT_MS, TimeUnit.MILLISECONDS)
353356
}
354-
// TODO RUM-9917 Avoid using unconditional wait locks
355-
Thread.sleep(UPLOAD_CYCLE_MAX_WAIT_MS)
356-
MockWebServerAssert.assertThat(getMockServerWrapper())
357-
.withConfiguration(fakeConfiguration)
358-
.withTrackingConsent(trackingConsent)
359-
.didNotReceiveData(fakeBatchData, fakeBatchMetadata)
357+
ConditionWatcher {
358+
MockWebServerAssert.assertThat(getMockServerWrapper())
359+
.withConfiguration(fakeConfiguration)
360+
.withTrackingConsent(trackingConsent)
361+
.didNotReceiveData(fakeBatchData, fakeBatchMetadata)
362+
true
363+
}.doWait(MEDIUM_WAIT_MS)
360364
}
361365

362366
// endregion
@@ -392,12 +396,13 @@ class FeatureScopeTest : MockServerTest() {
392396

393397
// Then
394398
countDownLatch.await(MEDIUM_WAIT_MS, TimeUnit.MILLISECONDS)
395-
// TODO RUM-9917 Avoid using unconditional wait locks
396-
Thread.sleep(UPLOAD_CYCLE_MAX_WAIT_MS)
397-
MockWebServerAssert.assertThat(getMockServerWrapper())
398-
.withConfiguration(fakeConfiguration)
399-
.withTrackingConsent(trackingConsent)
400-
.didNotReceiveData(fakeBatchData, fakeBatchMetadata)
399+
ConditionWatcher {
400+
MockWebServerAssert.assertThat(getMockServerWrapper())
401+
.withConfiguration(fakeConfiguration)
402+
.withTrackingConsent(trackingConsent)
403+
.didNotReceiveData(fakeBatchData, fakeBatchMetadata)
404+
true
405+
}.doWait(MEDIUM_WAIT_MS)
401406
}
402407

403408
// endregion

reliability/core-it/src/androidTest/kotlin/com/datadog/android/core/integration/tests/InternalSdkCoreTest.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import com.datadog.android.api.context.DeviceType
2121
import com.datadog.android.api.feature.Feature
2222
import com.datadog.android.api.feature.stub.StubStorageBackedFeature
2323
import com.datadog.android.core.InternalSdkCore
24+
import com.datadog.android.core.configuration.BatchProcessingLevel
25+
import com.datadog.android.core.configuration.BatchSize
2426
import com.datadog.android.core.configuration.Configuration
27+
import com.datadog.android.core.configuration.UploadFrequency
2528
import com.datadog.android.core.integration.tests.forge.factories.ConfigurationCoreForgeryFactory
2629
import com.datadog.android.core.integration.tests.utils.clientToken
2730
import com.datadog.android.core.integration.tests.utils.env
@@ -406,8 +409,9 @@ class InternalSdkCoreTest : MockServerTest() {
406409
.apply {
407410
_InternalProxy.allowClearTextHttp(this)
408411
}
409-
.setBatchSize(forge.getForgery())
410-
.setUploadFrequency(forge.getForgery())
412+
.setBatchSize(BatchSize.SMALL)
413+
.setUploadFrequency(UploadFrequency.FREQUENT)
414+
.setBatchProcessingLevel(BatchProcessingLevel.HIGH)
411415
.useSite(forge.aValueFrom(DatadogSite::class.java))
412416
.build()
413417

reliability/core-it/src/androidTest/kotlin/com/datadog/android/core/integration/tests/PendingToGrantedAsyncTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class PendingToGrantedAsyncTest(
118118
.withTrackingConsent(TrackingConsent.GRANTED)
119119
.receivedData(fakeBatchData, fakeBatchMetadata)
120120
true
121-
}.doWait(LONG_WAIT_MS)
121+
}.doWait(MEDIUM_WAIT_MS)
122122
}
123123

124124
// region Internal

reliability/core-it/src/androidTest/kotlin/com/datadog/android/core/integration/tests/PendingToGrantedCustomPersistenceAsyncTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class PendingToGrantedCustomPersistenceAsyncTest(
128128
.withTrackingConsent(TrackingConsent.GRANTED)
129129
.receivedData(fakeBatchData, fakeBatchMetadata)
130130
true
131-
}.doWait(LONG_WAIT_MS)
131+
}.doWait(MEDIUM_WAIT_MS)
132132
}
133133

134134
// region Internal
@@ -169,9 +169,9 @@ class PendingToGrantedCustomPersistenceAsyncTest(
169169
.apply {
170170
_InternalProxy.allowClearTextHttp(this)
171171
}
172-
.setBatchSize(aValueFrom(BatchSize::class.java))
173-
.setUploadFrequency(aValueFrom(UploadFrequency::class.java))
174-
.setBatchProcessingLevel(aValueFrom(BatchProcessingLevel::class.java))
172+
.setBatchSize(BatchSize.SMALL)
173+
.setUploadFrequency(UploadFrequency.FREQUENT)
174+
.setBatchProcessingLevel(BatchProcessingLevel.HIGH)
175175
.setPersistenceStrategyFactory(object : PersistenceStrategy.Factory {
176176
override fun create(
177177
identifier: String,

reliability/core-it/src/androidTest/kotlin/com/datadog/android/core/integration/tests/forge/factories/ConfigurationCoreForgeryFactory.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ internal class ConfigurationCoreForgeryFactory :
4444
.apply {
4545
_InternalProxy.allowClearTextHttp(this)
4646
}
47-
.setBatchSize(forge.aValueFrom(BatchSize::class.java))
48-
.setUploadFrequency(forge.aValueFrom(UploadFrequency::class.java))
49-
.setBatchProcessingLevel(forge.aValueFrom(BatchProcessingLevel::class.java))
47+
.setBatchSize(BatchSize.SMALL)
48+
.setUploadFrequency(UploadFrequency.FREQUENT)
49+
.setBatchProcessingLevel(BatchProcessingLevel.HIGH)
5050
.build()
5151
}
5252
}

0 commit comments

Comments
 (0)