Skip to content

Commit 9909c1f

Browse files
committed
add integration test for bloom filter
1 parent 3862731 commit 9909c1f

File tree

1 file changed

+42
-0
lines changed
  • firebase-firestore/src/androidTest/java/com/google/firebase/firestore

1 file changed

+42
-0
lines changed

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollectionWithDocs;
2222
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testFirestore;
2323
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
24+
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.writeAllDocs;
2425
import static com.google.firebase.firestore.testutil.TestUtil.expectError;
2526
import static com.google.firebase.firestore.testutil.TestUtil.map;
27+
import static com.google.firebase.firestore.util.Util.autoId;
2628
import static java.util.Arrays.asList;
2729
import static java.util.Collections.singletonList;
2830
import static org.junit.Assert.assertEquals;
@@ -1029,6 +1031,46 @@ public void testMultipleUpdatesWhileOffline() {
10291031
assertEquals(asList(map("foo", "zzyzx", "bar", "2")), querySnapshotToValues(snapshot2));
10301032
}
10311033

1034+
@Test
1035+
public void resumingQueryShouldRemoveDeletedDocumentsIndicatedByExistenceFilter() {
1036+
Map<String, Map<String, Object>> testDocs = new LinkedHashMap<>();
1037+
for (int i = 1; i <= 100; i++) {
1038+
testDocs.put("doc" + i, map("key", i));
1039+
}
1040+
1041+
// Setup firestore with disabled persistence and populate a collection with testDocs.
1042+
FirebaseFirestore firestore = testFirestore();
1043+
firestore.setFirestoreSettings(
1044+
new FirebaseFirestoreSettings.Builder().setPersistenceEnabled(false).build());
1045+
CollectionReference collection = firestore.collection(autoId());
1046+
writeAllDocs(collection, testDocs);
1047+
1048+
QuerySnapshot snapshot1 = waitFor(collection.get());
1049+
assertEquals(snapshot1.size(), 100);
1050+
1051+
// Delete 50 docs in transaction so that it doesn't affect local cache.
1052+
waitFor(
1053+
firestore.runTransaction(
1054+
transaction -> {
1055+
for (int i = 1; i <= 50; i++) {
1056+
DocumentReference docRef = collection.document("doc" + i);
1057+
transaction.delete(docRef);
1058+
}
1059+
return null;
1060+
}));
1061+
1062+
// Wait 10 seconds, during which Watch will stop tracking the query
1063+
// and will send an existence filter rather than "delete" events.
1064+
try {
1065+
Thread.sleep(10000);
1066+
} catch (InterruptedException ex) {
1067+
Thread.currentThread().interrupt();
1068+
}
1069+
1070+
QuerySnapshot snapshot2 = waitFor(collection.get());
1071+
assertEquals(snapshot2.size(), 50);
1072+
}
1073+
10321074
// TODO(orquery): Enable this test when prod supports OR queries.
10331075
@Ignore
10341076
@Test

0 commit comments

Comments
 (0)