diff --git a/src/androidTest/java/tests/integration/streaming/CleanUpDatabaseTest.java b/src/androidTest/java/tests/integration/streaming/CleanUpDatabaseTest.java index f7f9c6127..30b748d0d 100644 --- a/src/androidTest/java/tests/integration/streaming/CleanUpDatabaseTest.java +++ b/src/androidTest/java/tests/integration/streaming/CleanUpDatabaseTest.java @@ -1,7 +1,5 @@ package tests.integration.streaming; -import static java.lang.Thread.sleep; - import android.content.Context; import androidx.core.util.Pair; @@ -140,7 +138,7 @@ public void testCleanUp() throws IOException, InterruptedException { .streamingEnabled(true) .impressionsRefreshRate(999999999) .eventFlushInterval(99999999) - .logLevel(SplitLogLevel.DEBUG) + .logLevel(SplitLogLevel.VERBOSE) .trafficType("account") .build(); @@ -155,11 +153,12 @@ public void testCleanUp() throws IOException, InterruptedException { mClient.on(SplitEvent.SDK_READY, readyTask); latch.await(40, TimeUnit.SECONDS); - - // wait to allow cleanup to run - sleep(5000); + Thread.sleep(1000); // Load all records again after cleanup + List remainingKeys = mUniqueKeysDao.getBy(0, StorageRecordStatus.ACTIVE, 10); + remainingKeys.addAll(mUniqueKeysDao.getBy(0, StorageRecordStatus.DELETED, 10)); + List remainingEvents = mEventDao.getBy(0, StorageRecordStatus.ACTIVE, 10); remainingEvents.addAll(mEventDao.getBy(0, StorageRecordStatus.DELETED, 10)); @@ -169,8 +168,6 @@ public void testCleanUp() throws IOException, InterruptedException { List remainingCounts = mImpressionsCountDao.getBy(0, StorageRecordStatus.ACTIVE, 10); remainingCounts.addAll(mImpressionsCountDao.getBy(0, StorageRecordStatus.DELETED, 10)); - List remainingKeys = mUniqueKeysDao.getBy(0, StorageRecordStatus.ACTIVE, 10); - remainingKeys.addAll(mUniqueKeysDao.getBy(0, StorageRecordStatus.DELETED, 10)); List remainingImpressionsObserverCacheEntities = mImpressionsObserverCacheDao.getAll(3); @@ -184,7 +181,6 @@ public void testCleanUp() throws IOException, InterruptedException { Assert.assertEquals(1, remainingCounts.size()); Assert.assertEquals(1, remainingKeys.size()); Assert.assertEquals(1, remainingImpressionsObserverCacheEntities.size()); - } private EventEntity createEventEntity(long createdAt, int status, String name) { @@ -258,7 +254,7 @@ public HttpResponseMock getResponse(URI uri, HttpMethod method, String body) { } else if (uri.getPath().contains("/bulk")) { return createResponse(500, ""); } else { - return new HttpResponseMock(200); + return new HttpResponseMock(404); } } diff --git a/src/main/java/io/split/android/client/SplitFactoryImpl.java b/src/main/java/io/split/android/client/SplitFactoryImpl.java index 260af4d04..058c1139d 100644 --- a/src/main/java/io/split/android/client/SplitFactoryImpl.java +++ b/src/main/java/io/split/android/client/SplitFactoryImpl.java @@ -413,11 +413,6 @@ private void setupValidations(SplitClientConfig splitClientConfig) { ValidationConfig.getInstance().setTrackEventNamePattern(splitClientConfig.trackEventNamePattern()); } - private void cleanUpDabase(SplitTaskExecutor splitTaskExecutor, - SplitTaskFactory splitTaskFactory) { - splitTaskExecutor.submit(splitTaskFactory.createCleanUpDatabaseTask(System.currentTimeMillis() / 1000), null); - } - private EventsTracker buildEventsTracker() { EventValidator eventsValidator = new EventValidatorImpl(new KeyValidatorImpl(), mStorageContainer.getSplitsStorage()); return new EventsTrackerImpl(eventsValidator, new ValidationMessageLoggerImpl(), mStorageContainer.getTelemetryStorage(),