Skip to content

Commit b8dc203

Browse files
authored
Firestore: Disable bloom filter integration tests when using Firestore emulator (#5168)
1 parent 77ab6f7 commit b8dc203

File tree

1 file changed

+26
-28
lines changed
  • firebase-firestore/src/androidTest/java/com/google/firebase/firestore

1 file changed

+26
-28
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryTest.java

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,15 @@ public void testMultipleUpdatesWhileOffline() {
10421042

10431043
@Test
10441044
public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Exception {
1045+
// TODO(b/291365820): Stop skipping this test when running against the Firestore emulator once
1046+
// the emulator is improved to include a bloom filter in the existence filter "messages that it
1047+
// sends.
1048+
assumeFalse(
1049+
"Skip this test when running against the Firestore emulator because the emulator does not "
1050+
+ "include a bloom filter when it sends existence filter messages, making it "
1051+
+ "impossible for this test to verify the correctness of the bloom filter.",
1052+
isRunningAgainstEmulator());
1053+
10451054
// Prepare the names and contents of the 100 documents to create.
10461055
Map<String, Map<String, Object>> testData = new HashMap<>();
10471056
for (int i = 0; i < 100; i++) {
@@ -1100,33 +1109,19 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
11001109

11011110
// Verify that the snapshot from the resumed query contains the expected documents; that is,
11021111
// that it contains the 50 documents that were _not_ deleted.
1103-
// TODO(b/270731363): Remove the "if" condition below once the Firestore Emulator is fixed to
1104-
// send an existence filter. At the time of writing, the Firestore emulator fails to send an
1105-
// existence filter, resulting in the client including the deleted documents in the snapshot
1106-
// of the resumed query.
1107-
if (!(isRunningAgainstEmulator() && snapshot2.size() == 100)) {
1108-
HashSet<String> actualDocumentIds = new HashSet<>();
1109-
for (DocumentSnapshot documentSnapshot : snapshot2.getDocuments()) {
1110-
actualDocumentIds.add(documentSnapshot.getId());
1111-
}
1112-
HashSet<String> expectedDocumentIds = new HashSet<>();
1113-
for (DocumentReference documentRef : createdDocuments) {
1114-
if (!deletedDocumentIds.contains(documentRef.getId())) {
1115-
expectedDocumentIds.add(documentRef.getId());
1116-
}
1117-
}
1118-
assertWithMessage("snapshot2.docs")
1119-
.that(actualDocumentIds)
1120-
.containsExactlyElementsIn(expectedDocumentIds);
1112+
HashSet<String> actualDocumentIds = new HashSet<>();
1113+
for (DocumentSnapshot documentSnapshot : snapshot2.getDocuments()) {
1114+
actualDocumentIds.add(documentSnapshot.getId());
11211115
}
1122-
1123-
// Skip the verification of the existence filter mismatch when testing against the Firestore
1124-
// emulator because the Firestore emulator does not include the `unchanged_names` bloom filter
1125-
// when it sends ExistenceFilter messages. Some day the emulator _may_ implement this logic,
1126-
// at which time this short-circuit can be removed.
1127-
if (isRunningAgainstEmulator()) {
1128-
return;
1116+
HashSet<String> expectedDocumentIds = new HashSet<>();
1117+
for (DocumentReference documentRef : createdDocuments) {
1118+
if (!deletedDocumentIds.contains(documentRef.getId())) {
1119+
expectedDocumentIds.add(documentRef.getId());
1120+
}
11291121
}
1122+
assertWithMessage("snapshot2.docs")
1123+
.that(actualDocumentIds)
1124+
.containsExactlyElementsIn(expectedDocumentIds);
11301125

11311126
// Verify that Watch sent an existence filter with the correct counts when the query was
11321127
// resumed.
@@ -1175,10 +1170,13 @@ private static String unicodeNormalize(String s) {
11751170

11761171
@Test
11771172
public void bloomFilterShouldCorrectlyEncodeComplexUnicodeCharacters() throws Exception {
1173+
// TODO(b/291365820): Stop skipping this test when running against the Firestore emulator once
1174+
// the emulator is improved to include a bloom filter in the existence filter "messages that it
1175+
// sends.
11781176
assumeFalse(
1179-
"Skip this test when running against the Firestore emulator because the Firestore emulator "
1180-
+ "fails to send existence filters when queries are resumed (b/270731363), and even "
1181-
+ "if it did send an existence filter it probably wouldn't include a bloom filter.",
1177+
"Skip this test when running against the Firestore emulator because the emulator does not "
1178+
+ "include a bloom filter when it sends existence filter messages, making it "
1179+
+ "impossible for this test to verify the correctness of the bloom filter.",
11821180
isRunningAgainstEmulator());
11831181

11841182
// Firestore does not do any Unicode normalization on the document IDs. Therefore, two document

0 commit comments

Comments
 (0)