Skip to content

Port of fix for b/67042460 (retry more often before considering client offline) #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,10 @@ - (void)receiveWatchStreamError:(int)errorCode userInfo:(NSDictionary<NSString *
[NSError errorWithDomain:FIRFirestoreErrorDomain code:errorCode userInfo:userInfo];

[self.datastore failWatchStreamWithError:error];
// Unlike web, stream should re-open synchronously
FSTAssert(self.datastore.isWatchStreamOpen, @"Watch stream is open");
// Unlike web, stream should re-open synchronously (if we have any listeners)
if (self.queryListeners.count > 0) {
FSTAssert(self.datastore.isWatchStreamOpen, @"Watch stream is open");
}
}

- (NSDictionary<FSTDocumentKey *, FSTBoxedTargetID *> *)currentLimboDocuments {
Expand Down
147 changes: 147 additions & 0 deletions Firestore/Example/Tests/SpecTests/json/offline_spec_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
}
}
},
{
"watchStreamClose": {
"error": {
"code": 14,
"message": "Simulated Backend Error"
}
}
},
{
"watchStreamClose": {
"error": {
Expand Down Expand Up @@ -110,6 +118,14 @@
}
}
},
{
"watchStreamClose": {
"error": {
"code": 14,
"message": "Simulated Backend Error"
}
}
},
{
"watchStreamClose": {
"error": {
Expand Down Expand Up @@ -147,5 +163,136 @@
}
}
]
},
"Removing all listeners delays \"Offline\" status on next listen": {
"describeName": "Offline:",
"itName": "Removing all listeners delays \"Offline\" status on next listen",
"tags": [],
"config": {
"useGarbageCollection": true
},
"steps": [
{
"userListen": [
2,
{
"path": "collection",
"filters": [],
"orderBys": []
}
],
"stateExpect": {
"activeTargets": {
"2": {
"query": {
"path": "collection",
"filters": [],
"orderBys": []
},
"resumeToken": ""
}
}
}
},
{
"watchStreamClose": {
"error": {
"code": 14,
"message": "Simulated Backend Error"
}
}
},
{
"watchStreamClose": {
"error": {
"code": 14,
"message": "Simulated Backend Error"
}
},
"expect": [
{
"query": {
"path": "collection",
"filters": [],
"orderBys": []
},
"errorCode": 0,
"fromCache": true,
"hasPendingWrites": false
}
]
},
{
"userUnlisten": [
2,
{
"path": "collection",
"filters": [],
"orderBys": []
}
],
"stateExpect": {
"activeTargets": {}
}
},
{
"watchStreamClose": {
"error": {
"code": 14,
"message": "Simulated Backend Error"
}
}
},
{
"userListen": [
4,
{
"path": "collection",
"filters": [],
"orderBys": []
}
],
"stateExpect": {
"activeTargets": {
"4": {
"query": {
"path": "collection",
"filters": [],
"orderBys": []
},
"resumeToken": ""
}
}
}
},
{
"watchStreamClose": {
"error": {
"code": 14,
"message": "Simulated Backend Error"
}
}
},
{
"watchStreamClose": {
"error": {
"code": 14,
"message": "Simulated Backend Error"
}
},
"expect": [
{
"query": {
"path": "collection",
"filters": [],
"orderBys": []
},
"errorCode": 0,
"fromCache": true,
"hasPendingWrites": false
}
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -489,19 +489,7 @@
"code": 14,
"message": "Simulated Backend Error"
}
},
"expect": [
{
"query": {
"path": "collection",
"filters": [],
"orderBys": []
},
"errorCode": 0,
"fromCache": true,
"hasPendingWrites": false
}
]
}
},
{
"watchAck": [
Expand Down
81 changes: 12 additions & 69 deletions Firestore/Example/Tests/SpecTests/json/write_spec_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -4372,9 +4372,9 @@
}
]
},
"Writes that fail with code cancelled are retried": {
"Writes that fail with code resource_exhausted are not rejected": {
"describeName": "Writes:",
"itName": "Writes that fail with code cancelled are retried",
"itName": "Writes that fail with code resource_exhausted are not rejected",
"tags": [],
"config": {
"useGarbageCollection": true
Expand Down Expand Up @@ -4435,73 +4435,16 @@
{
"failWrite": {
"error": {
"code": 1
"code": 8
},
"expectUserCallback": false
}
},
{
"writeAck": {
"version": 1000,
"expectUserCallback": true
}
},
{
"watchAck": [
2
]
},
{
"watchEntity": {
"docs": [
[
"collection/key",
0,
{
"foo": "bar"
}
]
],
"targets": [
2
]
}
},
{
"watchCurrent": [
[
2
],
"resume-token-1000"
],
"watchSnapshot": 1000,
"expect": [
{
"query": {
"path": "collection/key",
"filters": [],
"orderBys": []
},
"metadata": [
[
"collection/key",
0,
{
"foo": "bar"
}
]
],
"errorCode": 0,
"fromCache": false,
"hasPendingWrites": false
}
]
}
]
},
"Writes that fail with code unknown are retried": {
"Writes that fail with code cancelled are retried": {
"describeName": "Writes:",
"itName": "Writes that fail with code unknown are retried",
"itName": "Writes that fail with code cancelled are retried",
"tags": [],
"config": {
"useGarbageCollection": true
Expand Down Expand Up @@ -4562,7 +4505,7 @@
{
"failWrite": {
"error": {
"code": 2
"code": 1
},
"expectUserCallback": false
}
Expand Down Expand Up @@ -4626,9 +4569,9 @@
}
]
},
"Writes that fail with code deadline-exceeded are retried": {
"Writes that fail with code unknown are retried": {
"describeName": "Writes:",
"itName": "Writes that fail with code deadline-exceeded are retried",
"itName": "Writes that fail with code unknown are retried",
"tags": [],
"config": {
"useGarbageCollection": true
Expand Down Expand Up @@ -4689,7 +4632,7 @@
{
"failWrite": {
"error": {
"code": 4
"code": 2
},
"expectUserCallback": false
}
Expand Down Expand Up @@ -4753,9 +4696,9 @@
}
]
},
"Writes that fail with code resource-exhausted are retried": {
"Writes that fail with code deadline-exceeded are retried": {
"describeName": "Writes:",
"itName": "Writes that fail with code resource-exhausted are retried",
"itName": "Writes that fail with code deadline-exceeded are retried",
"tags": [],
"config": {
"useGarbageCollection": true
Expand Down Expand Up @@ -4816,7 +4759,7 @@
{
"failWrite": {
"error": {
"code": 8
"code": 4
},
"expectUserCallback": false
}
Expand Down
Loading