Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apply plugin: 'kotlin-android'
apply from: 'spec.gradle'

ext {
splitVersion = '5.1.0-alpha.2'
splitVersion = '5.1.0-alpha.3'
}

android {
Expand Down
124 changes: 124 additions & 0 deletions src/androidTest/assets/split_changes_imp_toggle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"splits": [
{
"trafficTypeName": "user",
"name": "tracked",
"trafficAllocation": 100,
"trafficAllocationSeed": -285565213,
"seed": -1992295819,
"status": "ACTIVE",
"killed": false,
"defaultTreatment": "off",
"changeNumber": 1506703262916,
"algo": 2,
"impressionsDisabled": false,
"conditions": [
{
"conditionType": "ROLLOUT",
"matcherGroup": {
"combiner": "AND",
"matchers": [
{
"keySelector": {
"trafficType": "client",
"attribute": null
},
"matcherType": "IN_SEGMENT",
"negate": false,
"userDefinedSegmentMatcherData": {
"segmentName": "new_segment"
},
"whitelistMatcherData": null,
"unaryNumericMatcherData": null,
"betweenMatcherData": null,
"booleanMatcherData": null,
"dependencyMatcherData": null,
"stringMatcherData": null
}
]
},
"partitions": [
{
"treatment": "on",
"size": 0
},
{
"treatment": "off",
"size": 0
},
{
"treatment": "free",
"size": 100
},
{
"treatment": "conta",
"size": 0
}
],
"label": "in segment new_segment"
}
]
},
{
"trafficTypeName": "user",
"name": "not_tracked",
"trafficAllocation": 100,
"trafficAllocationSeed": -285565213,
"seed": -1992295819,
"status": "ACTIVE",
"killed": false,
"defaultTreatment": "off",
"changeNumber": 1506703262916,
"algo": 2,
"impressionsDisabled": true,
"conditions": [
{
"conditionType": "ROLLOUT",
"matcherGroup": {
"combiner": "AND",
"matchers": [
{
"keySelector": {
"trafficType": "client",
"attribute": null
},
"matcherType": "IN_SEGMENT",
"negate": false,
"userDefinedSegmentMatcherData": {
"segmentName": "new_segment"
},
"whitelistMatcherData": null,
"unaryNumericMatcherData": null,
"betweenMatcherData": null,
"booleanMatcherData": null,
"dependencyMatcherData": null,
"stringMatcherData": null
}
]
},
"partitions": [
{
"treatment": "on",
"size": 0
},
{
"treatment": "off",
"size": 0
},
{
"treatment": "free",
"size": 100
},
{
"treatment": "conta",
"size": 0
}
],
"label": "in segment new_segment"
}
]
}
],
"since": 1506703262916,
"till": 1506703262916
}
9 changes: 7 additions & 2 deletions src/androidTest/java/fake/HttpClientMock.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
import io.split.android.client.network.HttpStreamRequest;
import io.split.android.client.network.HttpStreamResponse;

import static java.lang.Thread.sleep;

/**
* Prefer using {@link okhttp3.mockwebserver.MockWebServer} to mock / intercept responses.
* <p>
* That will ensure the SDK uses the default HTTP client.
*/
@Deprecated
public class HttpClientMock implements HttpClient {
HttpResponseMockDispatcher mResponseDispatcher;

public HttpClientMock(HttpResponseMockDispatcher responseDispatcher) throws IOException {
mResponseDispatcher = responseDispatcher;
}
Expand Down
4 changes: 2 additions & 2 deletions src/androidTest/java/fake/SyncManagerStub.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fake;

import io.split.android.client.dtos.Event;
import io.split.android.client.impressions.Impression;
import io.split.android.client.impressions.DecoratedImpression;
import io.split.android.client.service.synchronizer.SyncManager;
import io.split.android.client.shared.UserConsent;

Expand Down Expand Up @@ -42,6 +42,6 @@ public void pushEvent(Event event) {
}

@Override
public void pushImpression(Impression impression) {
public void pushImpression(DecoratedImpression impression) {
}
}
4 changes: 2 additions & 2 deletions src/androidTest/java/fake/SynchronizerSpyImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import io.split.android.client.api.Key;
import io.split.android.client.dtos.Event;
import io.split.android.client.impressions.Impression;
import io.split.android.client.impressions.DecoratedImpression;
import io.split.android.client.service.synchronizer.Synchronizer;
import io.split.android.client.service.synchronizer.SynchronizerSpy;
import io.split.android.client.service.synchronizer.attributes.AttributesSynchronizer;
Expand Down Expand Up @@ -88,7 +88,7 @@ public void pushEvent(Event event) {
}

@Override
public void pushImpression(Impression impression) {
public void pushImpression(DecoratedImpression impression) {
mSynchronizer.pushImpression(impression);
}

Expand Down
5 changes: 4 additions & 1 deletion src/androidTest/java/helper/DatabaseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ public static boolean removeDatabaseFile(String name) {
}

public static SplitRoomDatabase getTestDatabase(Context context) {
return Room.inMemoryDatabaseBuilder(context, SplitRoomDatabase.class)
SplitRoomDatabase database = Room.inMemoryDatabaseBuilder(context, SplitRoomDatabase.class)
.fallbackToDestructiveMigration()
.allowMainThreadQueries()
.build();

database.clearAllTables();
return database;
}
}
4 changes: 4 additions & 0 deletions src/androidTest/java/helper/IntegrationHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,5 +442,9 @@ public interface StreamingResponseClosure {
public static class ServicePath {
public static final String MEMBERSHIPS = "memberships";
public static final String SPLIT_CHANGES = "splitChanges";
public static final String EVENTS = "events";
public static final String UNIQUE_KEYS = "keys/cs";
public static final String COUNT = "testImpressions/count";
public static final String IMPRESSIONS = "testImpressions/bulk";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void onPostExecutionView(SplitClient client) {

assertTrue(latch.await(5, TimeUnit.SECONDS));
mLifecycleManager.simulateOnPause();
Thread.sleep(200);
Thread.sleep(500);
mLifecycleManager.simulateOnResume();
Thread.sleep(500);

Expand Down Expand Up @@ -327,11 +327,11 @@ private SplitFactory createFactory(
SplitClientConfig config = new TestableSplitConfigBuilder().ready(30000)
.trafficType("client")
.impressionsMode(impressionsMode)
.impressionsRefreshRate(1000)
.impressionsCountersRefreshRate(1000)
.impressionsRefreshRate(99999)
.impressionsCountersRefreshRate(99999)
.streamingEnabled(false)
.enableDebug()
.eventFlushInterval(1000)
.eventFlushInterval(99999)
.encryptionEnabled(encryptionEnabled)
.build();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package tests.integration.streaming;

import static java.lang.Thread.sleep;

import android.content.Context;

import androidx.core.util.Pair;
Expand Down Expand Up @@ -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();

Expand All @@ -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<UniqueKeyEntity> remainingKeys = mUniqueKeysDao.getBy(0, StorageRecordStatus.ACTIVE, 10);
remainingKeys.addAll(mUniqueKeysDao.getBy(0, StorageRecordStatus.DELETED, 10));

List<EventEntity> remainingEvents = mEventDao.getBy(0, StorageRecordStatus.ACTIVE, 10);
remainingEvents.addAll(mEventDao.getBy(0, StorageRecordStatus.DELETED, 10));

Expand All @@ -169,8 +168,6 @@ public void testCleanUp() throws IOException, InterruptedException {
List<ImpressionsCountEntity> remainingCounts = mImpressionsCountDao.getBy(0, StorageRecordStatus.ACTIVE, 10);
remainingCounts.addAll(mImpressionsCountDao.getBy(0, StorageRecordStatus.DELETED, 10));

List<UniqueKeyEntity> remainingKeys = mUniqueKeysDao.getBy(0, StorageRecordStatus.ACTIVE, 10);
remainingKeys.addAll(mUniqueKeysDao.getBy(0, StorageRecordStatus.DELETED, 10));

List<ImpressionsObserverCacheEntity> remainingImpressionsObserverCacheEntities = mImpressionsObserverCacheDao.getAll(3);

Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
}

Expand Down
Loading
Loading