Skip to content

Conversation

@dconeybe
Copy link
Contributor

Many of the Firestore integration tests for Android need an instance of jni::Env. The usual solution is create an instance as a local variable by simply declaring jni::Env env. This is a bit annoying because it adds clutter to the source code. Additionally, jni::Env instances are not allowed to be shared between threads, and having a local variable makes it easy to accidentally share instances with other threads.

To fix this, FirestoreAndroidIntegrationTest gains a new static member function named env() that returns a reference to an instance of jni::Env. By using a thread_local variable, it ensures that each thread gets its own instance. Then, (almost) all occurrences of jni::Env env have been removed from the tests, and where an instance was needed it just calls the env() function.

@dconeybe dconeybe added api: firestore skip-release-notes Skip release notes check labels Jun 21, 2023
@dconeybe dconeybe self-assigned this Jun 21, 2023
@dconeybe dconeybe added the tests-requested: quick Trigger a quick set of integration tests. label Jun 21, 2023
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. and removed tests-requested: quick Trigger a quick set of integration tests. labels Jun 21, 2023
@github-actions
Copy link

github-actions bot commented Jun 21, 2023

Integration test with FLAKINESS (succeeded after retry)

Requested by @dconeybe on commit 99b39b0
Last updated: Fri Jun 23 12:11 PDT 2023
View integration test log & download artifacts

Failures Configs
gma [TEST] [FLAKINESS] [iOS] [macos] [1/2 ios_device: ios_target]
(1 failed tests)  FirebaseGmaTest.TestNativeAdLoadEmptyRequest
remote_config [TEST] [FLAKINESS] [Android] [1/3 os: macos] [1/2 android_device: android_target]
(1 failed tests)  FirebaseRemoteConfigTest.TestAddOnConfigUpdateListener

Add flaky tests to go/fpl-cpp-flake-tracker

@github-actions github-actions bot added the tests: succeeded This PR's integration tests succeeded. label Jun 21, 2023
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jun 21, 2023
@dconeybe dconeybe added tests-requested: quick Trigger a quick set of integration tests. and removed tests: succeeded This PR's integration tests succeeded. labels Jun 22, 2023
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. tests: succeeded This PR's integration tests succeeded. and removed tests-requested: quick Trigger a quick set of integration tests. labels Jun 22, 2023
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jun 22, 2023
@dconeybe dconeybe requested a review from wu-hui June 22, 2023 13:49
@dconeybe dconeybe added tests-requested: quick Trigger a quick set of integration tests. and removed tests: succeeded This PR's integration tests succeeded. labels Jun 22, 2023
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. tests: succeeded This PR's integration tests succeeded. and removed tests-requested: quick Trigger a quick set of integration tests. labels Jun 22, 2023
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jun 22, 2023
Copy link
Contributor

@wu-hui wu-hui left a comment

Choose a reason for hiding this comment

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

LGTM.

@dconeybe dconeybe merged commit 99b39b0 into main Jun 23, 2023
@dconeybe dconeybe deleted the dconeybe/EnvRawUsagesInTestsRemoved branch June 23, 2023 16:44
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. tests: succeeded This PR's integration tests succeeded. and removed tests: succeeded This PR's integration tests succeeded. labels Jun 23, 2023
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jun 23, 2023
@firebase firebase locked and limited conversation to collaborators Jul 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: firestore skip-release-notes Skip release notes check tests: succeeded This PR's integration tests succeeded.

2 participants