Skip to content

Commit 6e70588

Browse files
committed
finish test
1 parent 0af81b1 commit 6e70588

File tree

1 file changed

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

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,10 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
10481048

10491049
// Each iteration of the "while" loop below runs a single iteration of the test. The test will
10501050
// be run multiple times only if a bloom filter false positive occurs.
1051+
int attemptNumber = 0;
10511052
while (true) {
1053+
attemptNumber++;
1054+
10521055
// Create 100 documents in a new collection.
10531056
CollectionReference collection = testCollectionWithDocs(testData);
10541057

@@ -1135,6 +1138,33 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
11351138
assertWithMessage("Watch should have sent an existence filter").that(existenceFilterMismatchInfo).isNotNull();
11361139
assertWithMessage("localCacheCount").that(existenceFilterMismatchInfo.localCacheCount()).isEqualTo(100);
11371140
assertWithMessage("existenceFilterCount").that(existenceFilterMismatchInfo.existenceFilterCount()).isEqualTo(50);
1141+
1142+
// Skip the verification of the bloom filter when testing against production because the bloom
1143+
// filter is only implemented in nightly.
1144+
// TODO(b/271949433) Remove this "if" block once the bloom filter logic is deployed to
1145+
// production.
1146+
if (IntegrationTestUtil.getTargetBackend() != IntegrationTestUtil.TargetBackend.NIGHTLY) {
1147+
return;
1148+
}
1149+
1150+
// Verify that Watch sent a valid bloom filter.
1151+
WatchChangeAggregatorTestingHooksAccessor.ExistenceFilterBloomFilterInfo bloomFilter = existenceFilterMismatchInfo.bloomFilter();
1152+
assertWithMessage("The bloom filter specified in the existence filter").that(bloomFilter).isNotNull();
1153+
assertWithMessage("hashCount").that(bloomFilter.hashCount()).isGreaterThan(0);
1154+
assertWithMessage("bitmapLength").that(bloomFilter.bitmapLength()).isGreaterThan(0);
1155+
assertWithMessage("padding").that(bloomFilter.padding()).isGreaterThan(0);
1156+
assertWithMessage("padding").that(bloomFilter.padding()).isLessThan(8);
1157+
1158+
// Verify that the bloom filter was successfully used to avert a full requery. If a false
1159+
// positive occurred then retry the entire test. Although statistically rare, false positives
1160+
// are expected to happen occasionally. When a false positive _does_ happen, just retry the
1161+
// test with a different set of documents. If that retry _also_ experiences a false positive,
1162+
// then fail the test because that is so improbable that something must have gone wrong.
1163+
if (attemptNumber == 1 && ! bloomFilter.applied()) {
1164+
continue;
1165+
}
1166+
1167+
assertWithMessage("bloom filter successfully applied with attemptNumber=" + attemptNumber).that(bloomFilter.applied()).isTrue();
11381168
}
11391169
}
11401170

0 commit comments

Comments
 (0)