Skip to content

Commit c8cc6f8

Browse files
Spec tests for updateClientMetadataAndTryBecomePrimary and 'Lookup mutation documents' recovery
1 parent 4b037f4 commit c8cc6f8

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
5757
}
5858
);
5959

60+
specTest(
61+
'Clients fail to lookup mutations (with recovery)',
62+
['multi-client'],
63+
() => {
64+
return client(0)
65+
.expectPrimaryState(true)
66+
.failDatabaseTransactions('Lookup mutation documents')
67+
.client(1)
68+
.expectPrimaryState(false)
69+
.userSets('collection/a', { v: 1 })
70+
.failDatabaseTransactions('Lookup mutation documents')
71+
.client(0)
72+
.recoverDatabase()
73+
.runTimer(TimerId.AsyncQueueRetry)
74+
.writeAcks('collection/a', 1, { expectUserCallback: false })
75+
.client(1)
76+
.recoverDatabase()
77+
.runTimer(TimerId.AsyncQueueRetry)
78+
.expectUserCallbacks({ acknowledged: ['collection/a'] });
79+
}
80+
);
81+
6082
specTest(
6183
'Query raises events in secondary client (with recovery)',
6284
['multi-client'],
@@ -114,6 +136,31 @@ describeSpec('Persistence Recovery', ['no-ios', 'no-android'], () => {
114136
}
115137
);
116138

139+
specTest(
140+
'Ignores intermittent lease refresh failures (with recovery)',
141+
['multi-client'],
142+
() => {
143+
return client(0)
144+
.expectPrimaryState(true)
145+
.client(1)
146+
.expectPrimaryState(false)
147+
.client(0)
148+
.failDatabaseTransactions('updateClientMetadataAndTryBecomePrimary')
149+
.runTimer(TimerId.ClientMetadataRefresh)
150+
.client(1)
151+
.failDatabaseTransactions('updateClientMetadataAndTryBecomePrimary')
152+
.runTimer(TimerId.ClientMetadataRefresh)
153+
.client(0)
154+
.recoverDatabase()
155+
.runTimer(TimerId.ClientMetadataRefresh)
156+
.expectPrimaryState(true)
157+
.client(1)
158+
.recoverDatabase()
159+
.runTimer(TimerId.ClientMetadataRefresh)
160+
.expectPrimaryState(false);
161+
}
162+
);
163+
117164
specTest('Recovers when write cannot be persisted', [], () => {
118165
return (
119166
spec()

0 commit comments

Comments
 (0)