Skip to content

Firestore: Disable bloom filter integration tests when using Firestore emulator #5168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,15 @@ public void testMultipleUpdatesWhileOffline() {

@Test
public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Exception {
// TODO(b/291365820): Stop skipping this test when running against the Firestore emulator once
// the emulator is improved to include a bloom filter in the existence filter "messages that it
// sends.
assumeFalse(
"Skip this test when running against the Firestore emulator because the emulator does not "
+ "include a bloom filter when it sends existence filter messages, making it "
+ "impossible for this test to verify the correctness of the bloom filter.",
isRunningAgainstEmulator());

// Prepare the names and contents of the 100 documents to create.
Map<String, Map<String, Object>> testData = new HashMap<>();
for (int i = 0; i < 100; i++) {
Expand Down Expand Up @@ -1103,33 +1112,19 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except

// Verify that the snapshot from the resumed query contains the expected documents; that is,
// that it contains the 50 documents that were _not_ deleted.
// TODO(b/270731363): Remove the "if" condition below once the Firestore Emulator is fixed to
// send an existence filter. At the time of writing, the Firestore emulator fails to send an
// existence filter, resulting in the client including the deleted documents in the snapshot
// of the resumed query.
if (!(isRunningAgainstEmulator() && snapshot2.size() == 100)) {
HashSet<String> actualDocumentIds = new HashSet<>();
for (DocumentSnapshot documentSnapshot : snapshot2.getDocuments()) {
actualDocumentIds.add(documentSnapshot.getId());
}
HashSet<String> expectedDocumentIds = new HashSet<>();
for (DocumentReference documentRef : createdDocuments) {
if (!deletedDocumentIds.contains(documentRef.getId())) {
expectedDocumentIds.add(documentRef.getId());
}
}
assertWithMessage("snapshot2.docs")
.that(actualDocumentIds)
.containsExactlyElementsIn(expectedDocumentIds);
HashSet<String> actualDocumentIds = new HashSet<>();
for (DocumentSnapshot documentSnapshot : snapshot2.getDocuments()) {
actualDocumentIds.add(documentSnapshot.getId());
}

// Skip the verification of the existence filter mismatch when testing against the Firestore
// emulator because the Firestore emulator does not include the `unchanged_names` bloom filter
// when it sends ExistenceFilter messages. Some day the emulator _may_ implement this logic,
// at which time this short-circuit can be removed.
if (isRunningAgainstEmulator()) {
return;
HashSet<String> expectedDocumentIds = new HashSet<>();
for (DocumentReference documentRef : createdDocuments) {
if (!deletedDocumentIds.contains(documentRef.getId())) {
expectedDocumentIds.add(documentRef.getId());
}
}
assertWithMessage("snapshot2.docs")
.that(actualDocumentIds)
.containsExactlyElementsIn(expectedDocumentIds);

// Verify that Watch sent an existence filter with the correct counts when the query was
// resumed.
Expand Down Expand Up @@ -1178,10 +1173,13 @@ private static String unicodeNormalize(String s) {

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

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