diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8f5a946e..17c93763 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,8 +21,8 @@ on: required: false env: - SDK_BRANCH_NAME: ${{ inputs.sdk_branch || github.head_ref || github.ref_name }} - TEST_DATA_BRANCH_NAME: ${{ inputs.test_data_branch || 'main' }} + SDK_BRANCH: ${{ inputs.sdk_branch || github.head_ref || github.ref_name }} + TEST_DATA_BRANCH: ${{ inputs.test_data_branch || 'main' }} ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }} ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }} @@ -43,15 +43,15 @@ jobs: - name: Display Testing Details run: | echo "Running SDK Test using" - echo "Test Data: sdk-test-data@${TEST_DATA_BRANCH_NAME}" - echo "SDK Branch: android-sdk@${SDK_BRANCH_NAME}" + echo "Test Data: sdk-test-data@${TEST_DATA_BRANCH}" + echo "SDK Branch: android-sdk@${SDK_BRANCH}" echo "API Level: ${{ matrix.api-level }}" - name: Check out Java SDK uses: actions/checkout@v4 with: repository: Eppo-exp/android-sdk - ref: ${{ env.SDK_BRANCH_NAME}} + ref: ${{ env.SDK_BRANCH}} - name: Set up JDK 17 uses: actions/setup-java@v3 @@ -66,7 +66,7 @@ jobs: echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV - name: Set up test data - run: make test-data branchName=${{env.TEST_DATA_BRANCH_NAME}} + run: make test-data branchName=${{env.TEST_DATA_BRANCH}} - name: Wait for mock UFC DNS to resolve run: | @@ -131,7 +131,7 @@ jobs: touch app/emulator.log # create log file chmod 777 app/emulator.log # allow writing to log file adb logcat | grep EppoSDK >> app/emulator.log & # pipe all logcat messages into log file as a background process - ./gradlew connectedCheck --no-daemon # run tests + ./gradlew connectedCheck --no-daemon -Pandroid.testInstrumentationRunnerArguments.TEST_DATA_BRANCH=${{ env.TEST_DATA_BRANCH }} # run tests - name: Upload Emulator Logs if: always() diff --git a/eppo/src/androidTest/java/cloud/eppo/android/EppoClientTest.java b/eppo/src/androidTest/java/cloud/eppo/android/EppoClientTest.java index 146ad126..1d9ffdca 100644 --- a/eppo/src/androidTest/java/cloud/eppo/android/EppoClientTest.java +++ b/eppo/src/androidTest/java/cloud/eppo/android/EppoClientTest.java @@ -22,6 +22,7 @@ import android.util.Log; import androidx.annotation.Nullable; import androidx.test.core.app.ApplicationProvider; +import androidx.test.platform.app.InstrumentationRegistry; import cloud.eppo.BaseEppoClient; import cloud.eppo.EppoHttpClient; import cloud.eppo.android.cache.LRUAssignmentCache; @@ -68,8 +69,15 @@ public class EppoClientTest { private static final String TAG = logTag(EppoClient.class); private static final String DUMMY_API_KEY = "mock-api-key"; private static final String DUMMY_OTHER_API_KEY = "another-mock-api-key"; - private static final String TEST_HOST = + + // Use branch if specified by env variable `TEST_DATA_BRANCH`. + private static final String TEST_BRANCH = + InstrumentationRegistry.getArguments().getString("TEST_DATA_BRANCH"); + private static final String TEST_HOST_BASE = "https://us-central1-eppo-qa.cloudfunctions.net/serveGitHubRacTestFile"; + private static final String TEST_HOST = + TEST_HOST_BASE + (TEST_BRANCH != null ? "/b/" + TEST_BRANCH : ""); + private static final String INVALID_HOST = "https://thisisabaddomainforthistest.com"; private final ObjectMapper mapper = new ObjectMapper().registerModule(module()); @Mock AssignmentLogger mockAssignmentLogger; @@ -781,7 +789,7 @@ private void waitForPopulatedCache() { while (!cachePopulated) { if (System.currentTimeMillis() > waitEnd) { throw new InterruptedException( - "Cache file never populated; assuming configuration error"); + "Cache file never populated or smaller than expected 8000 bytes; assuming configuration error"); } long expectedMinimumSizeInBytes = 8000; // Last time this test was updated, cache size was 11,506 bytes