Skip to content

Add integration test for bloom filter #4696

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 6 commits into from
Feb 28, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
resolve comments
milaGGL committed Feb 23, 2023
commit 23e109f8307367eb8c23147f4cbd28dcd2d2b688
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
import com.google.firebase.firestore.testutil.EventAccumulator;
import com.google.firebase.firestore.testutil.IntegrationTestUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -1032,40 +1033,39 @@ public void testMultipleUpdatesWhileOffline() {
}

@Test
public void resumingQueryShouldRemoveDeletedDocumentsIndicatedByExistenceFilter() {
Map<String, Map<String, Object>> testDocs = new LinkedHashMap<>();
public void resumingQueryShouldRemoveDeletedDocumentsIndicatedByExistenceFilter()
throws InterruptedException {
Map<String, Map<String, Object>> testData = new HashMap<>();
for (int i = 1; i <= 100; i++) {
testDocs.put("doc" + i, map("key", i));
testData.put("doc" + i, map("key", i));
}

// Setup firestore with disabled persistence and populate a collection with testDocs.
FirebaseFirestore firestore = testFirestore();
firestore.setFirestoreSettings(
new FirebaseFirestoreSettings.Builder().setPersistenceEnabled(false).build());
CollectionReference collection = firestore.collection(autoId());
writeAllDocs(collection, testDocs);
writeAllDocs(collection, testData);

// Populate the cache and save the resume token.
QuerySnapshot snapshot1 = waitFor(collection.get());
assertEquals(snapshot1.size(), 100);
List<DocumentSnapshot> documents = snapshot1.getDocuments();

// Delete 50 docs in transaction so that it doesn't affect local cache.
waitFor(
firestore.runTransaction(
transaction -> {
for (int i = 1; i <= 50; i++) {
DocumentReference docRef = collection.document("doc" + i);
DocumentReference docRef = documents.get(i).getReference();
transaction.delete(docRef);
}
return null;
}));

// Wait 10 seconds, during which Watch will stop tracking the query
// and will send an existence filter rather than "delete" events.
try {
Thread.sleep(10000);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
Thread.sleep(10000);

QuerySnapshot snapshot2 = waitFor(collection.get());
assertEquals(snapshot2.size(), 50);