diff --git a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/CompositeIndexTestHelper.java b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/CompositeIndexTestHelper.java index 527db4c2807..23b949c96d4 100644 --- a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/CompositeIndexTestHelper.java +++ b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/CompositeIndexTestHelper.java @@ -125,7 +125,11 @@ public void assertOnlineAndOfflineResultsMatch( @NonNull CollectionReference collection, @NonNull Query query, @NonNull String... expectedDocs) { - checkOnlineAndOfflineResultsMatch(collection, query, toHashedIds(expectedDocs)); + // `checkOnlineAndOfflineResultsMatch` first makes sure all documents needed for + // `query` are in the cache. It does so making a `get` on the first argument. + // Since *all* composite index tests use the same collection, this is very inefficient to do. + // Therefore, we should only do so for tests where `TEST_ID_FIELD` matches the current test. + checkOnlineAndOfflineResultsMatch(this.query(collection), query, toHashedIds(expectedDocs)); } // Asserts that the IDs in the query snapshot matches the expected Ids. The expected document diff --git a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java index 32dbaf8f076..dd676b5f0ab 100644 --- a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java +++ b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java @@ -535,7 +535,7 @@ public static List nullList() { * @param expectedDocs Ordered list of document keys that are expected to match the query */ public static void checkOnlineAndOfflineResultsMatch( - CollectionReference collection, Query query, String... expectedDocs) { + Query collection, Query query, String... expectedDocs) { // Note: Order matters. The following has to be done in the specific order: // 1- Pre-populate the cache with the entire collection.