Skip to content

Commit 013d869

Browse files
authored
Firestore: Disable bloom filter integration tests when using Firestore emulator (#11555)
1 parent 9205183 commit 013d869

File tree

1 file changed

+29
-35
lines changed

1 file changed

+29
-35
lines changed

Firestore/Example/Tests/Integration/API/FIRQueryTests.mm

+29-35
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,14 @@ - (void)testResumingAQueryShouldUseBloomFilterToAvoidFullRequery {
11961196
using firebase::firestore::testutil::CaptureExistenceFilterMismatches;
11971197
using firebase::firestore::util::TestingHooks;
11981198

1199+
// TODO(b/291365820): Stop skipping this test when running against the Firestore emulator once
1200+
// the emulator is improved to include a bloom filter in the existence filter messages that it
1201+
// sends.
1202+
XCTSkipIf([FSTIntegrationTestCase isRunningAgainstEmulator],
1203+
"Skip this test when running against the Firestore emulator because the emulator does "
1204+
"not include a bloom filter when it sends existence filter messages, making it "
1205+
"impossible for this test to verify the correctness of the bloom filter.");
1206+
11991207
// Set this test to stop when the first failure occurs because some test assertion failures make
12001208
// the rest of the test not applicable or will even crash.
12011209
[self setContinueAfterFailure:NO];
@@ -1261,44 +1269,30 @@ - (void)testResumingAQueryShouldUseBloomFilterToAvoidFullRequery {
12611269

12621270
// Verify that the snapshot from the resumed query contains the expected documents; that is,
12631271
// that it contains the 50 documents that were _not_ deleted.
1264-
// TODO(b/270731363): Remove the "if" condition below once the Firestore Emulator is fixed to
1265-
// send an existence filter. At the time of writing, the Firestore emulator fails to send an
1266-
// existence filter, resulting in the client including the deleted documents in the snapshot
1267-
// of the resumed query.
1268-
if (!([FSTIntegrationTestCase isRunningAgainstEmulator] && querySnapshot2.count == 100)) {
1269-
NSSet<NSString *> *actualDocumentIds =
1270-
[NSSet setWithArray:FIRQuerySnapshotGetIDs(querySnapshot2)];
1271-
NSSet<NSString *> *expectedDocumentIds;
1272-
{
1273-
NSMutableArray<NSString *> *expectedDocumentIdsAccumulator = [[NSMutableArray alloc] init];
1274-
for (FIRDocumentReference *documentRef in createdDocuments) {
1275-
if (![deletedDocumentIds containsObject:documentRef.documentID]) {
1276-
[expectedDocumentIdsAccumulator addObject:documentRef.documentID];
1277-
}
1272+
NSSet<NSString *> *actualDocumentIds =
1273+
[NSSet setWithArray:FIRQuerySnapshotGetIDs(querySnapshot2)];
1274+
NSSet<NSString *> *expectedDocumentIds;
1275+
{
1276+
NSMutableArray<NSString *> *expectedDocumentIdsAccumulator = [[NSMutableArray alloc] init];
1277+
for (FIRDocumentReference *documentRef in createdDocuments) {
1278+
if (![deletedDocumentIds containsObject:documentRef.documentID]) {
1279+
[expectedDocumentIdsAccumulator addObject:documentRef.documentID];
12781280
}
1279-
expectedDocumentIds = [NSSet setWithArray:expectedDocumentIdsAccumulator];
1280-
}
1281-
if (![actualDocumentIds isEqualToSet:expectedDocumentIds]) {
1282-
NSArray<NSString *> *unexpectedDocumentIds =
1283-
SortedStringsNotIn(actualDocumentIds, expectedDocumentIds);
1284-
NSArray<NSString *> *missingDocumentIds =
1285-
SortedStringsNotIn(expectedDocumentIds, actualDocumentIds);
1286-
XCTFail(@"querySnapshot2 contained %lu documents (expected %lu): "
1287-
@"%lu unexpected and %lu missing; "
1288-
@"unexpected documents: %@; missing documents: %@",
1289-
(unsigned long)actualDocumentIds.count, (unsigned long)expectedDocumentIds.count,
1290-
(unsigned long)unexpectedDocumentIds.count, (unsigned long)missingDocumentIds.count,
1291-
[unexpectedDocumentIds componentsJoinedByString:@", "],
1292-
[missingDocumentIds componentsJoinedByString:@", "]);
12931281
}
1282+
expectedDocumentIds = [NSSet setWithArray:expectedDocumentIdsAccumulator];
12941283
}
1295-
1296-
// Skip the verification of the existence filter mismatch when testing against the Firestore
1297-
// emulator because the Firestore emulator fails to to send an existence filter at all.
1298-
// TODO(b/270731363): Enable the verification of the existence filter mismatch once the
1299-
// Firestore emulator is fixed to send an existence filter.
1300-
if ([FSTIntegrationTestCase isRunningAgainstEmulator]) {
1301-
return;
1284+
if (![actualDocumentIds isEqualToSet:expectedDocumentIds]) {
1285+
NSArray<NSString *> *unexpectedDocumentIds =
1286+
SortedStringsNotIn(actualDocumentIds, expectedDocumentIds);
1287+
NSArray<NSString *> *missingDocumentIds =
1288+
SortedStringsNotIn(expectedDocumentIds, actualDocumentIds);
1289+
XCTFail(@"querySnapshot2 contained %lu documents (expected %lu): "
1290+
@"%lu unexpected and %lu missing; "
1291+
@"unexpected documents: %@; missing documents: %@",
1292+
(unsigned long)actualDocumentIds.count, (unsigned long)expectedDocumentIds.count,
1293+
(unsigned long)unexpectedDocumentIds.count, (unsigned long)missingDocumentIds.count,
1294+
[unexpectedDocumentIds componentsJoinedByString:@", "],
1295+
[missingDocumentIds componentsJoinedByString:@", "]);
13021296
}
13031297

13041298
// Verify that Watch sent an existence filter with the correct counts when the query was

0 commit comments

Comments
 (0)