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
18 changes: 9 additions & 9 deletions .github/workflows/instrumented.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
api-level: [ 29 ]
shard: [ 0, 1, 2, 3 ]
shard: [ 0, 1, 2, 3, 4, 5 ]

steps:
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: checkout
uses: actions/checkout@v4

Expand All @@ -40,12 +46,6 @@ jobs:
~/.android/adb*
key: avd-${{ matrix.api-level }}

- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
Expand All @@ -65,4 +65,4 @@ jobs:
with:
api-level: ${{ matrix.api-level }}
profile: Galaxy Nexus
script: ./gradlew connectedCheck --continue -Pandroid.testInstrumentationRunnerArguments.numShards=4 -Pandroid.testInstrumentationRunnerArguments.shardIndex=${{ matrix.shard }}
script: ./gradlew connectedCheck --continue -Pandroid.testInstrumentationRunnerArguments.numShards=6 -Pandroid.testInstrumentationRunnerArguments.shardIndex=${{ matrix.shard }}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private List<Impression> generateImpressions(long count) {
System.currentTimeMillis(),
(i % 2 == 0) ? "in segment all" : "whitelisted",
i * i,
null,
null);
imps.add(imp);
}
Expand All @@ -61,6 +62,7 @@ public void testBasicFunctionality() {
"on", System.currentTimeMillis(),
"in segment all",
1234L,
null,
null);

// Add 5 new impressions so that the old one is evicted and re-try the test.
Expand All @@ -80,13 +82,14 @@ public void testValuesArePersistedAcrossInstances() throws InterruptedException
"on", System.currentTimeMillis(),
"in segment all",
1234L,
null,
null);
Impression imp2 = new Impression("someOtherKey",
null, "someOtherFeature",
"on", System.currentTimeMillis(),
"in segment all",
1234L,
null);
null, null);

// These are not in the cache, so they should return null
Long firstImp = observer.testAndSet(imp);
Expand Down Expand Up @@ -177,6 +180,7 @@ private void caller(ImpressionsObserver o, int count, ConcurrentLinkedQueue<Impr
System.currentTimeMillis(),
"label" + mRandom.nextInt(5),
1234567L,
null,
null);

i = i.withPreviousTime(o.testAndSet(i));
Expand Down
78 changes: 0 additions & 78 deletions src/androidTest/java/tests/database/ExclusiveTransactionTest.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public EventsTrackerImpl(@NonNull EventValidator eventValidator,
public void enableTracking(boolean enable) {
isTrackingEnabled.set(enable);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i love this change

public boolean track(String key, String trafficType, String eventType,
double value, Map<String, Object> properties, boolean isSdkReady) {

Expand Down
14 changes: 12 additions & 2 deletions src/main/java/io/split/android/client/impressions/Impression.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.split.android.client.impressions;

import androidx.annotation.Nullable;

import java.util.Map;

public class Impression {
Expand All @@ -13,17 +15,20 @@ public class Impression {
private final Long _changeNumber;
private Long _previousTime;
private final Map<String, Object> _attributes;
@Nullable
private final String _propertiesJson;


public Impression(String key, String bucketingKey, String split, String treatment, long time, String appliedRule, Long changeNumber, Map<String, Object> atributes) {
public Impression(String key, String bucketingKey, String split, String treatment, long time, String appliedRule, Long changeNumber, Map<String, Object> attributes, String propertiesJson) {
_key = key;
_bucketingKey = bucketingKey;
_split = split;
_treatment = treatment;
_time = time;
_appliedRule = appliedRule;
_changeNumber = changeNumber;
_attributes = atributes;
_attributes = attributes;
_propertiesJson = propertiesJson;
}

public String key() {
Expand Down Expand Up @@ -58,6 +63,11 @@ public Map<String, Object> attributes() {
return _attributes;
}

@Nullable
public String properties() {
return _propertiesJson;
}

public Long previousTime() {
return _previousTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.split.android.client.utils.logger.Logger;
import io.split.android.client.validators.FlagSetsValidatorImpl;
import io.split.android.client.validators.KeyValidatorImpl;
import io.split.android.client.validators.PropertyValidatorImpl;
import io.split.android.client.validators.SplitValidatorImpl;
import io.split.android.client.validators.TreatmentManager;
import io.split.android.client.validators.TreatmentManagerImpl;
Expand Down Expand Up @@ -75,7 +76,8 @@ public LocalhostSplitClient(@NonNull LocalhostSplitFactory container,
new EvaluatorImpl(splitsStorage, splitParser), new KeyValidatorImpl(),
new SplitValidatorImpl(), getImpressionsListener(splitClientConfig),
splitClientConfig.labelsEnabled(), eventsManager, attributesManager, attributesMerger,
telemetryStorageProducer, flagSetsFilter, splitsStorage, new ValidationMessageLoggerImpl(), new FlagSetsValidatorImpl());
telemetryStorageProducer, flagSetsFilter, splitsStorage, new ValidationMessageLoggerImpl(), new FlagSetsValidatorImpl(),
new PropertyValidatorImpl());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public void submitOnMainThread(SplitTask splitTask) {
}

public void pause() {
long start = System.currentTimeMillis();
while (!mScheduledTasks.isEmpty() && (System.currentTimeMillis() - start) < 500L) {
try { Thread.sleep(50); } catch (InterruptedException e) { break; }
}
Comment on lines +128 to +131
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the app goes to background we pause the task executor and sometimes tasks could end up not completing. This adds a small grace period to give them a chance to finish.

mScheduler.pause();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class SplitTaskExecutorImpl extends SplitBaseTaskExecutor {

private static final int MIN_THREAD_POOL_SIZE_WHEN_IDLE = 2;
private static final int MIN_THREAD_POOL_SIZE_WHEN_IDLE = 6;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was originally 6, it was reduced to 2 in the last rc but I'm restoring it.

private static final String THREAD_NAME_FORMAT = "split-taskExecutor-%d";

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.split.android.client.SplitClientFactoryImpl;
import io.split.android.client.SplitFactoryImpl;
import io.split.android.client.utils.logger.Logger;

public class SplitQueryDaoImpl implements SplitQueryDao {
Expand Down Expand Up @@ -55,13 +51,13 @@ int getColumnIndexOrThrow(@NonNull Cursor c, @NonNull String name) {

public Map<String, SplitEntity> getAllAsMap() {
// Fast path - if the map is already initialized, return it immediately
if (mIsInitialized) {
if (mIsInitialized && !mCachedSplitsMap.isEmpty()) {
return new HashMap<>(mCachedSplitsMap);
}

// Wait for initialization to complete if it's in progress
synchronized (mLock) {
if (mIsInitialized) {
if (mIsInitialized && !mCachedSplitsMap.isEmpty()) {
return new HashMap<>(mCachedSplitsMap);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package io.split.android.client.validators;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.Map;

public interface PropertyValidator {

Result validate(Map<String, Object> properties);

Result validate(Map<String, Object> properties, int initialSizeInBytes, String validationTag);

class Result {

private final boolean mIsValid;
@Nullable
private final Map<String, Object> mValidatedProperties;
private final int mSizeInBytes;
@Nullable
private final String mErrorMessage;

private Result(boolean isValid, Map<String, Object> properties, int sizeInBytes, String errorMessage) {
mIsValid = isValid;
mValidatedProperties = properties;
mSizeInBytes = sizeInBytes;
mErrorMessage = errorMessage;
}

public boolean isValid() {
return mIsValid;
}

@Nullable
public Map<String, Object> getValidatedProperties() {
return mValidatedProperties;
}

public int getSizeInBytes() {
return mSizeInBytes;
}

@Nullable
public String getErrorMessage() {
return mErrorMessage;
}

@NonNull
public static Result valid(Map<String, Object> properties, int sizeInBytes) {
return new Result(true, properties, sizeInBytes, null);
}

@NonNull
public static Result invalid(String errorMessage, int sizeInBytes) {
return new Result(false, null, sizeInBytes, errorMessage);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.split.android.client.validators;

import java.util.Map;

public class PropertyValidatorImpl implements PropertyValidator {

@Override
public Result validate(Map<String, Object> properties) {
return Result.valid(properties, 0); // TODO implement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is missing this implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in #756

}

@Override
public Result validate(Map<String, Object> properties, int initialSizeInBytes, String validationTag) {
return Result.valid(properties, initialSizeInBytes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,6 @@

public interface TreatmentManager {

String getTreatment(String split, Map<String, Object> attributes, boolean isClientDestroyed);

SplitResult getTreatmentWithConfig(String split, Map<String, Object> attributes, boolean isClientDestroyed);

Map<String, String> getTreatments(List<String> splits, Map<String, Object> attributes, boolean isClientDestroyed);

Map<String, SplitResult> getTreatmentsWithConfig(List<String> splits, Map<String, Object> attributes, boolean isClientDestroyed);

Map<String, String> getTreatmentsByFlagSet(@NonNull String flagSet, @Nullable Map<String, Object> attributes, boolean isClientDestroyed);

Map<String, String> getTreatmentsByFlagSets(@NonNull List<String> flagSets, @Nullable Map<String, Object> attributes, boolean isClientDestroyed);

Map<String, SplitResult> getTreatmentsWithConfigByFlagSet(@NonNull String flagSet, @Nullable Map<String, Object> attributes, boolean isClientDestroyed);

Map<String, SplitResult> getTreatmentsWithConfigByFlagSets(@NonNull List<String> flagSets, @Nullable Map<String, Object> attributes, boolean isClientDestroyed);


// temporary methods to reduce changes in this iteration
Comment on lines -14 to -31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you removing all this methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added new ones. This is internal, no changes to the API.

String getTreatment(String split, Map<String, Object> attributes, EvaluationOptions evaluationOptions, boolean isClientDestroyed);

SplitResult getTreatmentWithConfig(String split, Map<String, Object> attributes, EvaluationOptions evaluationOptions, boolean isClientDestroyed);
Expand Down
Loading
Loading