Skip to content

Commit f3f1b17

Browse files
Use gcEnabled instead of durable persistence (#3061)
1 parent 0804217 commit f3f1b17

File tree

1 file changed

+130
-138
lines changed

1 file changed

+130
-138
lines changed

packages/firestore/test/unit/specs/recovery_spec.test.ts

Lines changed: 130 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -221,98 +221,92 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
221221
.expectEvents(query2, {});
222222
});
223223

224-
specTest(
225-
'Recovers when watch update cannot be persisted',
226-
['durable-persistence'],
227-
() => {
228-
const query = Query.atPath(path('collection'));
229-
const doc1 = doc('collection/key1', 1000, { foo: 'a' });
230-
const doc2 = doc('collection/key2', 2000, { foo: 'b' });
231-
return (
232-
spec()
233-
.userListens(query)
234-
.watchAcksFull(query, 1000, doc1)
235-
.expectEvents(query, {
236-
added: [doc1]
237-
})
238-
.watchSends({ affects: [query] }, doc2)
239-
.failDatabaseTransactions({
240-
'Get last remote snapshot version': true,
241-
'Release target': true
242-
})
243-
.watchSnapshots(1500)
244-
// `failDatabase()` causes us to go offline.
245-
.expectActiveTargets()
246-
.expectEvents(query, { fromCache: true })
247-
.recoverDatabase()
248-
.runTimer(TimerId.AsyncQueueRetry)
249-
.expectActiveTargets({ query, resumeToken: 'resume-token-1000' })
250-
.watchAcksFull(query, 2000, doc2)
251-
.expectEvents(query, {
252-
added: [doc2]
253-
})
254-
);
255-
}
256-
);
224+
specTest('Recovers when watch update cannot be persisted', [], () => {
225+
const query = Query.atPath(path('collection'));
226+
const doc1 = doc('collection/key1', 1000, { foo: 'a' });
227+
const doc2 = doc('collection/key2', 2000, { foo: 'b' });
228+
return (
229+
spec()
230+
.withGCEnabled(false)
231+
.userListens(query)
232+
.watchAcksFull(query, 1000, doc1)
233+
.expectEvents(query, {
234+
added: [doc1]
235+
})
236+
.watchSends({ affects: [query] }, doc2)
237+
.failDatabaseTransactions({
238+
'Get last remote snapshot version': true,
239+
'Release target': true
240+
})
241+
.watchSnapshots(1500)
242+
// `failDatabase()` causes us to go offline.
243+
.expectActiveTargets()
244+
.expectEvents(query, { fromCache: true })
245+
.recoverDatabase()
246+
.runTimer(TimerId.AsyncQueueRetry)
247+
.expectActiveTargets({ query, resumeToken: 'resume-token-1000' })
248+
.watchAcksFull(query, 2000, doc2)
249+
.expectEvents(query, {
250+
added: [doc2]
251+
})
252+
);
253+
});
257254

258-
specTest(
259-
'Recovers when watch rejection cannot be persisted',
260-
['durable-persistence'],
261-
() => {
262-
const doc1Query = Query.atPath(path('collection/key1'));
263-
const doc2Query = Query.atPath(path('collection/key2'));
264-
const doc1a = doc('collection/key1', 1000, { foo: 'a' });
265-
const doc1b = doc('collection/key1', 4000, { foo: 'a', updated: true });
266-
const doc2 = doc('collection/key2', 2000, { foo: 'b' });
267-
return (
268-
spec()
269-
.userListens(doc1Query)
270-
.watchAcksFull(doc1Query, 1000, doc1a)
271-
.expectEvents(doc1Query, {
272-
added: [doc1a]
273-
})
274-
.userListens(doc2Query)
275-
.watchAcksFull(doc2Query, 2000, doc2)
276-
.expectEvents(doc2Query, {
277-
added: [doc2]
278-
})
279-
.failDatabaseTransactions({
280-
'Get last remote snapshot version': true,
281-
'Release target': true
282-
})
283-
.watchRemoves(
284-
doc1Query,
285-
new RpcError(Code.PERMISSION_DENIED, 'Simulated target error')
286-
)
287-
// `failDatabase()` causes us to go offline.
288-
.expectActiveTargets()
289-
.expectEvents(doc1Query, { fromCache: true })
290-
.expectEvents(doc2Query, { fromCache: true })
291-
.recoverDatabase()
292-
.runTimer(TimerId.AsyncQueueRetry)
293-
.expectActiveTargets(
294-
{ query: doc1Query, resumeToken: 'resume-token-1000' },
295-
{ query: doc2Query, resumeToken: 'resume-token-2000' }
296-
)
297-
.watchAcksFull(doc1Query, 3000)
298-
.expectEvents(doc1Query, {})
299-
.watchRemoves(
300-
doc2Query,
301-
new RpcError(Code.PERMISSION_DENIED, 'Simulated target error')
302-
)
303-
.expectEvents(doc2Query, { errorCode: Code.PERMISSION_DENIED })
304-
.watchSends({ affects: [doc1Query] }, doc1b)
305-
.watchSnapshots(4000)
306-
.expectEvents(doc1Query, {
307-
modified: [doc1b]
308-
})
309-
);
310-
}
311-
);
255+
specTest('Recovers when watch rejection cannot be persisted', [], () => {
256+
const doc1Query = Query.atPath(path('collection/key1'));
257+
const doc2Query = Query.atPath(path('collection/key2'));
258+
const doc1a = doc('collection/key1', 1000, { foo: 'a' });
259+
const doc1b = doc('collection/key1', 4000, { foo: 'a', updated: true });
260+
const doc2 = doc('collection/key2', 2000, { foo: 'b' });
261+
return (
262+
spec()
263+
.withGCEnabled(false)
264+
.userListens(doc1Query)
265+
.watchAcksFull(doc1Query, 1000, doc1a)
266+
.expectEvents(doc1Query, {
267+
added: [doc1a]
268+
})
269+
.userListens(doc2Query)
270+
.watchAcksFull(doc2Query, 2000, doc2)
271+
.expectEvents(doc2Query, {
272+
added: [doc2]
273+
})
274+
.failDatabaseTransactions({
275+
'Get last remote snapshot version': true,
276+
'Release target': true
277+
})
278+
.watchRemoves(
279+
doc1Query,
280+
new RpcError(Code.PERMISSION_DENIED, 'Simulated target error')
281+
)
282+
// `failDatabase()` causes us to go offline.
283+
.expectActiveTargets()
284+
.expectEvents(doc1Query, { fromCache: true })
285+
.expectEvents(doc2Query, { fromCache: true })
286+
.recoverDatabase()
287+
.runTimer(TimerId.AsyncQueueRetry)
288+
.expectActiveTargets(
289+
{ query: doc1Query, resumeToken: 'resume-token-1000' },
290+
{ query: doc2Query, resumeToken: 'resume-token-2000' }
291+
)
292+
.watchAcksFull(doc1Query, 3000)
293+
.expectEvents(doc1Query, {})
294+
.watchRemoves(
295+
doc2Query,
296+
new RpcError(Code.PERMISSION_DENIED, 'Simulated target error')
297+
)
298+
.expectEvents(doc2Query, { errorCode: Code.PERMISSION_DENIED })
299+
.watchSends({ affects: [doc1Query] }, doc1b)
300+
.watchSnapshots(4000)
301+
.expectEvents(doc1Query, {
302+
modified: [doc1b]
303+
})
304+
);
305+
});
312306

313307
specTest(
314308
'Recovers when Limbo acknowledgement cannot be persisted',
315-
['durable-persistence'],
309+
[],
316310
() => {
317311
const fullQuery = Query.atPath(path('collection'));
318312
const filteredQuery = Query.atPath(path('collection')).addFilter(
@@ -322,6 +316,7 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
322316
const doc1b = doc('collection/key1', 1500, { included: false });
323317
const limboQuery = Query.atPath(doc1a.key.path);
324318
return spec()
319+
.withGCEnabled(false)
325320
.userListens(fullQuery)
326321
.watchAcksFull(fullQuery, 1000, doc1a)
327322
.expectEvents(fullQuery, {
@@ -356,54 +351,51 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
356351
}
357352
);
358353

359-
specTest(
360-
'Recovers when Limbo rejection cannot be persisted',
361-
['durable-persistence'],
362-
() => {
363-
const fullQuery = Query.atPath(path('collection'));
364-
const filteredQuery = Query.atPath(path('collection')).addFilter(
365-
filter('included', '==', true)
366-
);
367-
const doc1 = doc('collection/key1', 1, { included: true });
368-
const limboQuery = Query.atPath(doc1.key.path);
369-
return spec()
370-
.userListens(fullQuery)
371-
.watchAcksFull(fullQuery, 1000, doc1)
372-
.expectEvents(fullQuery, {
373-
added: [doc1]
374-
})
375-
.userUnlistens(fullQuery)
376-
.userListens(filteredQuery)
377-
.expectEvents(filteredQuery, {
378-
added: [doc1],
379-
fromCache: true
380-
})
381-
.watchAcksFull(filteredQuery, 2000)
382-
.expectLimboDocs(doc1.key)
383-
.failDatabaseTransactions({
384-
'Apply remote event': true,
385-
'Get last remote snapshot version': true
386-
})
387-
.watchRemoves(
388-
limboQuery,
389-
new RpcError(Code.PERMISSION_DENIED, 'Test error')
390-
)
391-
.expectActiveTargets()
392-
.recoverDatabase()
393-
.runTimer(TimerId.AsyncQueueRetry)
394-
.expectActiveTargets(
395-
{ query: filteredQuery, resumeToken: 'resume-token-2000' },
396-
{ query: limboQuery }
397-
)
398-
.watchAcksFull(filteredQuery, 3000)
399-
.watchRemoves(
400-
limboQuery,
401-
new RpcError(Code.PERMISSION_DENIED, 'Test error')
402-
)
403-
.expectLimboDocs()
404-
.expectEvents(filteredQuery, {
405-
removed: [doc1]
406-
});
407-
}
408-
);
354+
specTest('Recovers when Limbo rejection cannot be persisted', [], () => {
355+
const fullQuery = Query.atPath(path('collection'));
356+
const filteredQuery = Query.atPath(path('collection')).addFilter(
357+
filter('included', '==', true)
358+
);
359+
const doc1 = doc('collection/key1', 1, { included: true });
360+
const limboQuery = Query.atPath(doc1.key.path);
361+
return spec()
362+
.withGCEnabled(false)
363+
.userListens(fullQuery)
364+
.watchAcksFull(fullQuery, 1000, doc1)
365+
.expectEvents(fullQuery, {
366+
added: [doc1]
367+
})
368+
.userUnlistens(fullQuery)
369+
.userListens(filteredQuery)
370+
.expectEvents(filteredQuery, {
371+
added: [doc1],
372+
fromCache: true
373+
})
374+
.watchAcksFull(filteredQuery, 2000)
375+
.expectLimboDocs(doc1.key)
376+
.failDatabaseTransactions({
377+
'Apply remote event': true,
378+
'Get last remote snapshot version': true
379+
})
380+
.watchRemoves(
381+
limboQuery,
382+
new RpcError(Code.PERMISSION_DENIED, 'Test error')
383+
)
384+
.expectActiveTargets()
385+
.recoverDatabase()
386+
.runTimer(TimerId.AsyncQueueRetry)
387+
.expectActiveTargets(
388+
{ query: filteredQuery, resumeToken: 'resume-token-2000' },
389+
{ query: limboQuery }
390+
)
391+
.watchAcksFull(filteredQuery, 3000)
392+
.watchRemoves(
393+
limboQuery,
394+
new RpcError(Code.PERMISSION_DENIED, 'Test error')
395+
)
396+
.expectLimboDocs()
397+
.expectEvents(filteredQuery, {
398+
removed: [doc1]
399+
});
400+
});
409401
});

0 commit comments

Comments
 (0)