@@ -2077,13 +2077,14 @@ apiDescribe('Queries', (persistence: boolean) => {
2077
2077
2078
2078
let attemptNumber = 0 ;
2079
2079
while ( true ) {
2080
+ type IterationResult = 'retry' | 'passed' ;
2080
2081
attemptNumber ++ ;
2081
- const bloomFilterApplied = await withTestCollection (
2082
+ const iterationResult = await withTestCollection < IterationResult > (
2082
2083
persistence ,
2083
2084
testDocs ,
2084
2085
async ( coll , db ) => {
2085
- // Run a query to populate the local cache with the 100 documents and
2086
- // a resume token.
2086
+ // Run a query to populate the local cache with the 100 documents
2087
+ // and a resume token.
2087
2088
const snapshot1 = await getDocs ( coll ) ;
2088
2089
expect ( snapshot1 . size ) . to . equal ( 100 ) ;
2089
2090
@@ -2096,23 +2097,23 @@ apiDescribe('Queries', (persistence: boolean) => {
2096
2097
} ) ;
2097
2098
2098
2099
// Wait for 10 seconds, during which Watch will stop tracking the
2099
- // query and will send an existence filter rather than "delete" events
2100
- // when the query is resumed.
2100
+ // query and will send an existence filter rather than "delete"
2101
+ // events when the query is resumed.
2101
2102
await new Promise ( resolve => setTimeout ( resolve , 10000 ) ) ;
2102
2103
2103
- // Resume the query and expect to get a snapshot with the 50 remaining
2104
- // documents. Use some internal testing hooks to "capture" the
2105
- // existence filter mismatches to later verify that Watch sent a bloom
2106
- // filter, and it was used to void the full requery.
2104
+ // Resume the query and expect to get a snapshot with the 50
2105
+ // remaining documents. Use some internal testing hooks to "capture"
2106
+ // the existence filter mismatches to later verify that Watch sent a
2107
+ // bloom filter, and it was used to avert a full requery.
2107
2108
const existenceFilterMismatches =
2108
2109
await captureExistenceFilterMismatches ( async ( ) => {
2109
2110
const snapshot2 = await getDocs ( coll ) ;
2110
2111
expect ( snapshot2 . size ) . to . equal ( 50 ) ;
2111
2112
} ) ;
2112
2113
2113
2114
// Verify that upon resuming the query that Watch sent an existence
2114
- // filter that included a bloom filter, and that that bloom filter was
2115
- // successfully used to avoid a full requery.
2115
+ // filter that included a bloom filter, and that that bloom filter
2116
+ // was successfully used to avoid a full requery.
2116
2117
// TODO(b/NNNNNNNN) Replace this "if" condition with !USE_EMULATOR
2117
2118
// once the feature has been deployed to production. Note that there
2118
2119
// are no plans to implement the bloom filter in the existence filter
@@ -2134,7 +2135,7 @@ apiDescribe('Queries', (persistence: boolean) => {
2134
2135
// fail if the retry _also_ experiences a false positive.
2135
2136
if ( ! bloomFilter . applied ) {
2136
2137
if ( attemptNumber < 2 ) {
2137
- return false ;
2138
+ return 'retry' ;
2138
2139
} else {
2139
2140
expect . fail (
2140
2141
'bloom filter false positive occurred ' +
@@ -2150,11 +2151,12 @@ apiDescribe('Queries', (persistence: boolean) => {
2150
2151
expect ( bloomFilter . padding ) . to . be . below ( 8 ) ;
2151
2152
}
2152
2153
2153
- return true ;
2154
+ return 'passed' ;
2154
2155
}
2155
2156
) ;
2156
2157
2157
- if ( bloomFilterApplied ) {
2158
+ // Break out of the retry loop if the test passed.
2159
+ if ( iterationResult === 'passed' ) {
2158
2160
break ;
2159
2161
}
2160
2162
}
0 commit comments