Skip to content

Commit

Permalink
ci: enabling ci tests after fixing test race condition (#260)
Browse files Browse the repository at this point in the history
**Related issues**

236700

**Describe the solution you've provided**

Eliminated recording of evaluation GET command which was leading to race
condition in unit tests.
  • Loading branch information
tanderson-ld authored Mar 15, 2024
1 parent 28e5977 commit aad01e7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 40 deletions.
42 changes: 21 additions & 21 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ runs:
id: build
run: ./gradlew build jar

# - name: Run Unit Tests
# if: inputs.run_tests == 'true'
# shell: bash
# run: ./gradlew test
#
# - name: Build contract tests
# shell: bash
# run: make build-contract-tests
#
# - name: Perform Instrumented Tests
# uses: reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 #2.30.1
# with:
# api-level: ${{ inputs.android_api_level }}
# target: google_apis
# emulator-boot-timeout: 900
# emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# disable-animations: true
# script: |
# make start-contract-test-service
# make run-contract-tests
# ./gradlew connectedDebugAndroidTest
- name: Run Unit Tests
if: inputs.run_tests == 'true'
shell: bash
run: ./gradlew test

- name: Build contract tests
shell: bash
run: make build-contract-tests

- name: Perform Instrumented Tests
uses: reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 #2.30.1
with:
api-level: ${{ inputs.android_api_level }}
target: google_apis
emulator-boot-timeout: 900
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
make start-contract-test-service
make run-contract-tests
./gradlew connectedDebugAndroidTest
- name: Build documentation
uses: ./.github/actions/build-docs
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,16 @@ public void testEventContainsAutoEnvAttributesWhenEnabled() throws Exception {
.diagnosticOptOut(true)
.serviceEndpoints(Components.serviceEndpoints()
.events(baseUrl.uri())
.streaming(baseUrl.uri())
.polling(baseUrl.uri())
)
.build();

// Don't wait as we are not set offline
try (LDClient ldClient = LDClient.init(application, ldConfig, ldContext, 0)){
ldClient.track("test-event");
ldClient.blockingFlush();

LDValue[] events = getEventsFromLastRequest(mockEventsServer, 2);
LDValue identifyEvent = events[0], customEvent = events[1];
assertIdentifyEvent(identifyEvent, ldContext);
assertTrue(customEvent.get("contextKeys").toString().contains("ld_application"));
assertTrue(customEvent.get("contextKeys").toString().contains("ld_device"));
LDValue[] events = getEventsFromLastRequest(mockEventsServer, 1);
LDValue identifyEvent = events[0];
assertTrue(identifyEvent.get("context").toString().contains("ld_application"));
assertTrue(identifyEvent.get("context").toString().contains("ld_device"));
}
}
}
Expand All @@ -289,21 +284,16 @@ public void testEventDoesNotContainAutoEnvAttributesWhenDisabled() throws Except
.diagnosticOptOut(true)
.serviceEndpoints(Components.serviceEndpoints()
.events(baseUrl.uri())
.streaming(baseUrl.uri())
.polling(baseUrl.uri())
)
.build();

// Don't wait as we are not set offline
try (LDClient ldClient = LDClient.init(application, ldConfig, ldContext, 0)){
ldClient.track("test-event");
ldClient.blockingFlush();

LDValue[] events = getEventsFromLastRequest(mockEventsServer, 2);
LDValue identifyEvent = events[0], customEvent = events[1];
assertIdentifyEvent(identifyEvent, ldContext);
assertFalse(customEvent.get("contextKeys").toString().contains("ld_application"));
assertFalse(customEvent.get("contextKeys").toString().contains("ld_device"));
LDValue[] events = getEventsFromLastRequest(mockEventsServer, 1);
LDValue identifyEvent = events[0];
assertFalse(identifyEvent.get("context").toString().contains("ld_application"));
assertFalse(identifyEvent.get("context").toString().contains("ld_device"));
}
}
}
Expand Down Expand Up @@ -345,7 +335,6 @@ private void assertContextKeys(LDValue event, LDContext context) {

private void assertFeatureEvent(LDValue event, LDContext context) {
assertEquals("feature", event.get("kind").stringValue());
assertContextKeys(event, context);
}

private void assertCustomEvent(LDValue event, LDContext context, String eventKey) {
Expand Down

0 comments on commit aad01e7

Please sign in to comment.