{ "Two sequential writes to different documents smoke test.": { "describeName": "Writes:", "itName": "Two sequential writes to different documents smoke test.", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } }, { "key": "collection/b", "version": 500, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } }, { "key": "collection/b", "version": 500, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userSet": [ "collection/a", { "v": 2 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/a", "version": 1000, "value": { "v": 2 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 2000, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 2000, "targetIds": [] } }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a", "version": 2000, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userSet": [ "collection/b", { "v": 2 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/b", "version": 500, "value": { "v": 2 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "watchEntity": { "docs": [ { "key": "collection/b", "version": 2500, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 3000, "targetIds": [] } }, { "writeAck": { "version": 2500 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/b" ], "rejectedDocs": [] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/b", "version": 2500, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Event is raised for a local set before and after the write ack": { "describeName": "Writes:", "itName": "Event is raised for a local set before and after the write ack", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userSet": [ "collection/key", { "v": 2 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/key", "version": 1000, "value": { "v": 2 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 2000, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 2000, "targetIds": [] } }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/key", "version": 2000, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Raises snapshot with 'hasPendingWrites' for unacknowledged write": { "describeName": "Writes:", "itName": "Raises snapshot with 'hasPendingWrites' for unacknowledged write", "tags": [], "config": { "useGarbageCollection": false, "numClients": 1 }, "steps": [ { "userSet": [ "collection/doc", { "v": 1 } ] }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/doc", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] } ] }, "Doesn't raise 'hasPendingWrites' for committed write and new listen": { "describeName": "Writes:", "itName": "Doesn't raise 'hasPendingWrites' for committed write and new listen", "tags": [], "config": { "useGarbageCollection": false, "numClients": 1 }, "steps": [ { "userSet": [ "collection/doc", { "v": 1 } ] }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/doc" ], "rejectedDocs": [] } } }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/doc", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": true } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Doesn't raise event for document with pending patch": { "describeName": "Writes:", "itName": "Doesn't raise event for document with pending patch", "tags": [], "config": { "useGarbageCollection": false, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-250" ] }, { "watchSnapshot": { "version": 250, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userPatch": [ "collection/doc", { "v": 2 } ] }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/doc" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/doc", "version": 500, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 500, "targetIds": [] } }, { "watchEntity": { "docs": [ { "key": "collection/doc", "version": 1000, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/doc", "version": 1000, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Cache will not keep data for an outdated write ack": { "describeName": "Writes:", "itName": "Cache will not keep data for an outdated write ack", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userSet": [ "collection/key", { "v": 2 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/key", "version": 1000, "value": { "v": 2 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 10000, "value": { "v": 3 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 10000, "targetIds": [] } }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/key", "version": 10000, "value": { "v": 3 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Cache raises correct event if write is acked before watch delivers it": { "describeName": "Writes:", "itName": "Cache raises correct event if write is acked before watch delivers it", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userSet": [ "collection/key", { "v": 2 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/key", "version": 1000, "value": { "v": 2 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 2000, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 2000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/key", "version": 2000, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Cache will hold local write until watch catches up": { "describeName": "Writes:", "itName": "Cache will hold local write until watch catches up", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userSet": [ "collection/key", { "v": 3 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/key", "version": 1000, "value": { "v": 3 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 3000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 2000, "value": { "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 2000, "targetIds": [] } }, { "watchEntity": { "docs": [ { "key": "collection/b", "version": 3000, "value": { "doc": "b" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } }, { "key": "collection/key", "version": 3000, "value": { "v": 3 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 3000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/b", "version": 3000, "value": { "doc": "b" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "metadata": [ { "key": "collection/key", "version": 3000, "value": { "v": 3 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Local patch is applied to query until watch catches up": { "describeName": "Writes:", "itName": "Local patch is applied to query until watch catches up", "tags": [], "config": { "useGarbageCollection": false, "numClients": 1 }, "steps": [ { "userSet": [ "collection/doc", { "local": 1 } ] }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/doc", "version": 0, "value": { "local": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/doc" ], "rejectedDocs": [] } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/doc", "version": 2000, "value": { "local": 1, "remote": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-2000" ] }, { "watchSnapshot": { "version": 2000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/doc", "version": 2000, "value": { "local": 1, "remote": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userPatch": [ "collection/doc", { "local": 5 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/doc", "version": 2000, "value": { "local": 5, "remote": 2 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 5000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/doc" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/doc", "version": 3000, "value": { "local": 1, "remote": 3 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": true } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 3000, "targetIds": [] } }, { "watchEntity": { "docs": [ { "key": "collection/doc", "version": 4000, "value": { "local": 1, "remote": 4 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": true } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 4000, "targetIds": [] } }, { "watchEntity": { "docs": [ { "key": "collection/doc", "version": 5000, "value": { "local": 5, "remote": 5 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 5000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/doc", "version": 5000, "value": { "local": 5, "remote": 5 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes are pipelined": { "describeName": "Writes:", "itName": "Writes are pipelined", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchCurrent": [ [ 2 ], "resume-token" ] }, { "userSet": [ "collection/a0", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a0", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a1", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a1", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a2", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a2", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a3", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a3", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a4", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a4", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a5", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a5", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a6", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a6", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a7", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a7", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a8", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a8", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a9", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a9", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a10", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a10", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a11", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a11", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a12", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a12", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a13", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a13", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a14", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a14", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "expectedState": { "numOutstandingWrites": 10 } }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a0" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a0", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a0", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a1" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a1", "version": 2000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 2000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a1", "version": 2000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 3000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a2" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a2", "version": 3000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 3000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a2", "version": 3000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 4000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a3" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a3", "version": 4000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 4000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a3", "version": 4000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 5000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a4" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a4", "version": 5000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 5000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a4", "version": 5000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 6000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a5" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a5", "version": 6000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 6000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a5", "version": 6000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 7000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a6" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a6", "version": 7000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 7000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a6", "version": 7000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 8000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a7" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a7", "version": 8000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 8000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a7", "version": 8000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 9000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a8" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a8", "version": 9000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 9000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a8", "version": 9000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 10000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a9" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a9", "version": 10000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 10000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a9", "version": 10000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 11000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a10" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a10", "version": 11000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 11000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a10", "version": 11000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 12000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a11" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a11", "version": 12000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 12000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a11", "version": 12000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 13000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a12" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a12", "version": 13000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 13000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a12", "version": 13000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 14000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a13" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a13", "version": 14000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 14000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a13", "version": 14000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 15000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a14" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a14", "version": 15000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 15000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a14", "version": 15000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Pipelined writes can fail": { "describeName": "Writes:", "itName": "Pipelined writes can fail", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/a0", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a0", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a1", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a1", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a2", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a2", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a3", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a3", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a4", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a4", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a5", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a5", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a6", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a6", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a7", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a7", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a8", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a8", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a9", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a9", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a10", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a10", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a11", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a11", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a12", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a12", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a13", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a13", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "userSet": [ "collection/a14", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a14", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "expectedState": { "numOutstandingWrites": 10 } }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a0" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a0", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a1" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a1", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a2" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a2", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a3" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a3", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a4" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a4", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a5" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a5", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a6" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a6", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a7" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a7", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a8" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a8", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a9" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a9", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a10" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a10", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a11" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a11", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a12" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a12", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a13" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a13", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a14" ] }, "numOutstandingWrites": 0 }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a14", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Failed writes are released immediately.": { "describeName": "Writes:", "itName": "Failed writes are released immediately.", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userSet": [ "collection/b", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/b", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/b" ], "rejectedDocs": [] } } }, { "userSet": [ "collection/a", { "v": 2 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/a", "version": 1000, "value": { "v": 2 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "watchEntity": { "docs": [ { "key": "collection/b", "version": 2000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 2000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/b", "version": 2000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes are not re-sent.": { "describeName": "Writes:", "itName": "Writes are not re-sent.", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-500" ] }, { "watchSnapshot": { "version": 500, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userSet": [ "collection/a", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } } }, { "userSet": [ "collection/b", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/b", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/b" ], "rejectedDocs": [] } } }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } }, { "key": "collection/b", "version": 2000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 2000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } }, { "key": "collection/b", "version": 2000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes are not re-sent after disable/enable network.": { "describeName": "Writes:", "itName": "Writes are not re-sent after disable/enable network.", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-500" ] }, { "watchSnapshot": { "version": 500, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userSet": [ "collection/a", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] }, "writeStreamRequestCount": 2 } }, { "enableNetwork": false, "expectedState": { "activeTargets": {}, "limboDocs": [], "writeStreamRequestCount": 3 }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "enableNetwork": true, "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "resume-token-500" } }, "writeStreamRequestCount": 3 } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-2000" ] }, { "watchSnapshot": { "version": 2000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes are released when there are no queries left": { "describeName": "Writes:", "itName": "Writes are released when there are no queries left", "tags": [ "eager-gc" ], "comment": "This test verifies that committed mutations are eligible for garbage collection on target removal", "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-500" ] }, { "watchSnapshot": { "version": 500, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userSet": [ "collection/a", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } } }, { "userUnlisten": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": {} } }, { "userListen": [ 4, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "4": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } } ] }, "Writes that fail with code invalid-argument are rejected": { "describeName": "Writes:", "itName": "Writes that fail with code invalid-argument are rejected", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 3 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/key" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Writes that fail with code not-found are rejected": { "describeName": "Writes:", "itName": "Writes that fail with code not-found are rejected", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 5 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/key" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Writes that fail with code already-exists are rejected": { "describeName": "Writes:", "itName": "Writes that fail with code already-exists are rejected", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 6 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/key" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Writes that fail with code permission-denied are rejected": { "describeName": "Writes:", "itName": "Writes that fail with code permission-denied are rejected", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 7 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/key" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Writes that fail with code failed-precondition are rejected": { "describeName": "Writes:", "itName": "Writes that fail with code failed-precondition are rejected", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 9 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/key" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Writes that fail with code out-of-range are rejected": { "describeName": "Writes:", "itName": "Writes that fail with code out-of-range are rejected", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 11 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/key" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Writes that fail with code unimplemented are rejected": { "describeName": "Writes:", "itName": "Writes that fail with code unimplemented are rejected", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 12 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/key" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Writes that fail with code data-loss are rejected": { "describeName": "Writes:", "itName": "Writes that fail with code data-loss are rejected", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 15 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/key" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ] } ] }, "Writes that fail with code resource_exhausted are not rejected": { "describeName": "Writes:", "itName": "Writes that fail with code resource_exhausted are not rejected", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 8 }, "keepInQueue": true } } ] }, "Writes that fail with code aborted are retried": { "describeName": "Writes:", "itName": "Writes that fail with code aborted are retried", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 10 }, "keepInQueue": true } }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes that fail with code cancelled are retried": { "describeName": "Writes:", "itName": "Writes that fail with code cancelled are retried", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 1 }, "keepInQueue": true } }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes that fail with code unknown are retried": { "describeName": "Writes:", "itName": "Writes that fail with code unknown are retried", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 2 }, "keepInQueue": true } }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes that fail with code deadline-exceeded are retried": { "describeName": "Writes:", "itName": "Writes that fail with code deadline-exceeded are retried", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 4 }, "keepInQueue": true } }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes that fail with code internal are retried": { "describeName": "Writes:", "itName": "Writes that fail with code internal are retried", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 13 }, "keepInQueue": true } }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes that fail with code unavailable are retried": { "describeName": "Writes:", "itName": "Writes that fail with code unavailable are retried", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 14 }, "keepInQueue": true } }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes that fail with code unauthenticated are retried": { "describeName": "Writes:", "itName": "Writes that fail with code unauthenticated are retried", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/key", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/key", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/key", "version": 0, "value": { "foo": "bar" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ] }, { "failWrite": { "error": { "code": 16 }, "keepInQueue": true } }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/key", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/key", "version": 1000, "value": { "foo": "bar" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Ensure correct events after patching a doc (including a delete) and getting watcher events.": { "describeName": "Writes:", "itName": "Ensure correct events after patching a doc (including a delete) and getting watcher events.", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userListen": [ 2, { "path": "collection/doc", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection/doc", "filters": [], "orderBys": [] } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "key": "collection/doc", "version": 1000, "value": { "a": { "b": 2 }, "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-500" ] }, { "watchSnapshot": { "version": 500, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/doc", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/doc", "version": 1000, "value": { "a": { "b": 2 }, "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] }, { "userPatch": [ "collection/doc", { "v": 2, "a.c": "" } ], "expectedSnapshotEvents": [ { "query": { "path": "collection/doc", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/doc", "version": 1000, "value": { "a": { "b": 2 }, "v": 2 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ] }, { "watchEntity": { "docs": [ { "key": "collection/doc", "version": 2000, "value": { "a": { "b": 2 }, "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] } }, { "watchSnapshot": { "version": 2000, "targetIds": [] } }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/doc" ], "rejectedDocs": [] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/doc", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/doc", "version": 2000, "value": { "a": { "b": 2 }, "v": 2 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ] } ] }, "Writes are resent after network disconnect": { "describeName": "Writes:", "itName": "Writes are resent after network disconnect", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userSet": [ "collection/key", { "foo": "bar" } ], "expectedState": { "numOutstandingWrites": 1 } }, { "enableNetwork": false, "expectedState": { "activeTargets": {}, "limboDocs": [], "writeStreamRequestCount": 3 } }, { "enableNetwork": true, "expectedState": { "writeStreamRequestCount": 5, "numOutstandingWrites": 1 } }, { "writeAck": { "version": 1 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/key" ], "rejectedDocs": [] }, "numOutstandingWrites": 0 } } ] }, "New writes are sent after write failure": { "describeName": "Writes:", "itName": "New writes are sent after write failure", "tags": [], "config": { "useGarbageCollection": true, "numClients": 1 }, "steps": [ { "userSet": [ "collection/a", { "v": 1 } ] }, { "failWrite": { "error": { "code": 9 } }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a" ] } } }, { "userSet": [ "collection/b", { "v": 1 } ] }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/b" ], "rejectedDocs": [] } } } ] }, "Primary client acknowledges write": { "describeName": "Writes:", "itName": "Primary client acknowledges write", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "applyClientState": { "visibility": "visible" }, "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userSet": [ "collection/a", { "v": 1 } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 0 }, { "writeAck": { "version": 1000 }, "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "clientIndex": 1 } ] }, "Primary client rejects write": { "describeName": "Writes:", "itName": "Primary client rejects write", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "applyClientState": { "visibility": "visible" }, "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userSet": [ "collection/a", { "v": 1 } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 0 }, { "failWrite": { "error": { "code": 9 } }, "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a" ] } }, "clientIndex": 1 } ] }, "Pending writes are shared between clients": { "describeName": "Writes:", "itName": "Pending writes are shared between clients", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "clientIndex": 0 }, { "watchAck": [ 2 ], "clientIndex": 0 }, { "watchEntity": { "docs": [], "targets": [ 2 ] }, "clientIndex": 0 }, { "watchCurrent": [ [ 2 ], "resume-token-500" ], "clientIndex": 0 }, { "watchSnapshot": { "version": 500, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 0 }, { "userSet": [ "collection/a", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 0 }, { "userSet": [ "collection/a", { "v": 2 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/a", "version": 0, "value": { "v": 2 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 0 }, { "drainQueue": true, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/a", "version": 0, "value": { "v": 2 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 1 }, { "userSet": [ "collection/a", { "v": 3 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/a", "version": 0, "value": { "v": 3 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 1 }, { "drainQueue": true, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "modified": [ { "key": "collection/a", "version": 0, "value": { "v": 3 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 0 } ] }, "Pending write is acknowledged by primary client": { "describeName": "Writes:", "itName": "Pending write is acknowledged by primary client", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "applyClientState": { "visibility": "visible" }, "clientIndex": 0 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "clientIndex": 0 }, { "watchAck": [ 2 ], "clientIndex": 0 }, { "watchEntity": { "docs": [], "targets": [ 2 ] }, "clientIndex": 0 }, { "watchCurrent": [ [ 2 ], "resume-token-500" ], "clientIndex": 0 }, { "watchSnapshot": { "version": 500, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 1 }, { "userSet": [ "collection/a", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 1 }, { "drainQueue": true, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 0 }, { "writeAck": { "version": 1000 }, "clientIndex": 0 }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] }, "clientIndex": 0 }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 1 } ] }, "Pending write is rejected by primary client": { "describeName": "Writes:", "itName": "Pending write is rejected by primary client", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "clientIndex": 0 }, { "watchAck": [ 2 ], "clientIndex": 0 }, { "watchEntity": { "docs": [], "targets": [ 2 ] }, "clientIndex": 0 }, { "watchCurrent": [ [ 2 ], "resume-token-500" ], "clientIndex": 0 }, { "watchSnapshot": { "version": 500, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 1 }, { "userSet": [ "collection/a", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 1 }, { "drainQueue": true, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 0 }, { "failWrite": { "error": { "code": 9 } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/a" ] } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 1 } ] }, "Writes are released by primary client": { "describeName": "Writes:", "itName": "Writes are released by primary client", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "clientIndex": 0 }, { "watchAck": [ 2 ], "clientIndex": 0 }, { "watchEntity": { "docs": [], "targets": [ 2 ] }, "clientIndex": 0 }, { "watchCurrent": [ [ 2 ], "resume-token-500" ], "clientIndex": 0 }, { "watchSnapshot": { "version": 500, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userSet": [ "collection/a", { "v": 1 } ], "clientIndex": 1 }, { "drainQueue": true, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 0 }, { "writeAck": { "version": 1000 }, "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 0 }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] }, "clientIndex": 0 }, { "watchSnapshot": { "version": 2000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a", "version": 1000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 0 } ] }, "Writes are held during primary failover": { "describeName": "Writes:", "itName": "Writes are held during primary failover", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "clientIndex": 0 }, { "userSet": [ "collection/doc", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/doc", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 0 }, { "watchAck": [ 2 ], "clientIndex": 0 }, { "watchEntity": { "docs": [], "targets": [ 2 ] }, "clientIndex": 0 }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ], "clientIndex": 0 }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": true } ], "clientIndex": 0 }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/doc" ], "rejectedDocs": [] } }, "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "applyClientState": { "primary": true }, "expectedState": { "isPrimary": true, "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "resume-token-1000" } } }, "clientIndex": 1 }, { "userListen": [ 4, { "path": "collection/doc", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "resume-token-1000" }, "4": { "queries": [ { "path": "collection/doc", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection/doc", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/doc", "version": 2000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": true } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ], "clientIndex": 1 }, { "watchAck": [ 2 ], "clientIndex": 1 }, { "watchAck": [ 4 ], "clientIndex": 1 }, { "watchEntity": { "docs": [ { "key": "collection/doc", "version": 2000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2, 4 ] }, "clientIndex": 1 }, { "watchCurrent": [ [ 2 ], "resume-token-2000" ], "clientIndex": 1 }, { "watchCurrent": [ [ 4 ], "resume-token-2000" ], "clientIndex": 1 }, { "watchSnapshot": { "version": 2000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection/doc", "filters": [], "orderBys": [] }, "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 1 }, { "drainQueue": true, "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" }, "4": { "queries": [ { "path": "collection/doc", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "clientIndex": 0 }, { "runTimer": "client_metadata_refresh", "expectedState": { "isPrimary": false }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/doc", "version": 2000, "value": { "v": 1 }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 0 } ] }, "Write are sequenced by multiple clients": { "describeName": "Writes:", "itName": "Write are sequenced by multiple clients", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 4 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "userSet": [ "collection/a", { "v": 1 } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userSet": [ "collection/b", { "v": 1 } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 2 }, { "userSet": [ "collection/c", { "v": 1 } ], "clientIndex": 2 }, { "drainQueue": true, "clientIndex": 3 }, { "userSet": [ "collection/d", { "v": 1 } ], "clientIndex": 3 }, { "drainQueue": true, "clientIndex": 0 }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "clientIndex": 0 }, { "writeAck": { "version": 2000 }, "clientIndex": 0 }, { "writeAck": { "version": 3000 }, "clientIndex": 0 }, { "failWrite": { "error": { "code": 9 } }, "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/b" ], "rejectedDocs": [] } }, "clientIndex": 1 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/c" ], "rejectedDocs": [] } }, "clientIndex": 2 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/d" ] } }, "clientIndex": 3 }, { "drainQueue": true, "clientIndex": 0 }, { "userSet": [ "collection/f", { "v": 1 } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userSet": [ "collection/g", { "v": 1 } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 2 }, { "userSet": [ "collection/h", { "v": 1 } ], "clientIndex": 2 }, { "drainQueue": true, "clientIndex": 3 }, { "userSet": [ "collection/i", { "v": 1 } ], "clientIndex": 3 }, { "drainQueue": true, "clientIndex": 0 }, { "writeAck": { "version": 4000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/f" ], "rejectedDocs": [] } }, "clientIndex": 0 }, { "writeAck": { "version": 5000 }, "clientIndex": 0 }, { "writeAck": { "version": 6000 }, "clientIndex": 0 }, { "failWrite": { "error": { "code": 9 } }, "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/g" ], "rejectedDocs": [] } }, "clientIndex": 1 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/h" ], "rejectedDocs": [] } }, "clientIndex": 2 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/i" ] } }, "clientIndex": 3 }, { "drainQueue": true, "clientIndex": 3 }, { "userSet": [ "collection/j", { "v": 1 } ], "clientIndex": 3 }, { "userSet": [ "collection/k", { "v": 1 } ], "clientIndex": 3 }, { "userSet": [ "collection/l", { "v": 1 } ], "clientIndex": 3 }, { "drainQueue": true, "clientIndex": 0 }, { "writeAck": { "version": 7000 }, "clientIndex": 0 }, { "failWrite": { "error": { "code": 9 } }, "clientIndex": 0 }, { "writeAck": { "version": 8000 }, "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/j", "collection/l" ], "rejectedDocs": [ "collection/k" ] } }, "clientIndex": 3 } ] }, "Write is executed after primary tab failover": { "describeName": "Writes:", "itName": "Write is executed after primary tab failover", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "applyClientState": { "visibility": "visible" }, "expectedState": { "isPrimary": true }, "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "isPrimary": false }, "clientIndex": 1 }, { "userSet": [ "collection/a", { "v": 1 } ], "clientIndex": 1 }, { "userSet": [ "collection/b", { "v": 1 } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 0 }, { "writeAck": { "version": 1000 }, "clientIndex": 0 }, { "shutdown": true, "expectedState": { "activeTargets": {}, "limboDocs": [] }, "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "clientIndex": 1 }, { "runTimer": "client_metadata_refresh", "expectedState": { "isPrimary": true }, "clientIndex": 1 }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/b" ], "rejectedDocs": [] } }, "clientIndex": 1 } ] }, "Secondary tabs handle user change": { "describeName": "Writes:", "itName": "Secondary tabs handle user change", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "clientIndex": 0 }, { "changeUser": "user1", "clientIndex": 0 }, { "userSet": [ "collection/a", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "changeUser": "user1", "clientIndex": 1 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 1 }, { "userSet": [ "collection/b", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/b", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 1 }, { "drainQueue": true, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/b", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 0 }, { "changeUser": "user2", "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "removed": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } }, { "key": "collection/b", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ], "clientIndex": 0 }, { "userSet": [ "collection/c", { "v": 1 } ], "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/c", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "changeUser": "user2", "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/c", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "removed": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } }, { "key": "collection/b", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 1 }, { "changeUser": "user1", "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } }, { "key": "collection/b", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "removed": [ { "key": "collection/c", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 0 }, { "changeUser": "user1", "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } }, { "key": "collection/b", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "removed": [ { "key": "collection/c", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 0 } ] }, "Mutations are scoped by user": { "describeName": "Writes:", "itName": "Mutations are scoped by user", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "clientIndex": 0 }, { "changeUser": "user1", "clientIndex": 0 }, { "userSet": [ "collection/a", { "v": 1 } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "changeUser": "user2", "clientIndex": 1 }, { "userSet": [ "collection/b", { "v": 1 } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 0 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/b", "version": 0, "value": { "v": 1 }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 1 } ] }, "Mutation recovers after primary takeover": { "describeName": "Writes:", "itName": "Mutation recovers after primary takeover", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "expectedState": { "isPrimary": true }, "clientIndex": 0 }, { "userSet": [ "collection/a", { "k": "a" } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 0, "value": { "k": "a" }, "options": { "hasLocalMutations": true, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true } ], "clientIndex": 1 }, { "drainQueue": true, "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "applyClientState": { "primary": true }, "expectedState": { "isPrimary": true }, "clientIndex": 1 }, { "writeAck": { "version": 1000 }, "clientIndex": 1 }, { "watchAck": [ 2 ], "clientIndex": 1 }, { "watchEntity": { "docs": [ { "key": "collection/a", "version": 1000, "value": { "k": "a" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "targets": [ 2 ] }, "clientIndex": 1 }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ], "clientIndex": 1 }, { "watchSnapshot": { "version": 1000, "targetIds": [] }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "metadata": [ { "key": "collection/a", "version": 1000, "value": { "k": "a" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": false } } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false } ], "clientIndex": 1 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "clientIndex": 0 } ] }, "Write is sent by newly started primary": { "describeName": "Writes:", "itName": "Write is sent by newly started primary", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 3 }, "steps": [ { "drainQueue": true, "expectedState": { "isPrimary": true }, "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "isPrimary": false }, "clientIndex": 1 }, { "userSet": [ "collection/a", { "v": 1 } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 0 }, { "shutdown": true, "expectedState": { "activeTargets": {}, "limboDocs": [] }, "clientIndex": 0 }, { "drainQueue": true, "expectedState": { "isPrimary": true, "numOutstandingWrites": 1 }, "clientIndex": 2 }, { "writeAck": { "version": 1000 }, "clientIndex": 2 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "clientIndex": 1 } ] }, "Unresponsive primary ignores acknowledged write": { "describeName": "Writes:", "itName": "Unresponsive primary ignores acknowledged write", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 3 }, "steps": [ { "drainQueue": true, "expectedState": { "isPrimary": true }, "clientIndex": 0 }, { "userSet": [ "collection/a", { "k": "a" } ], "clientIndex": 0 }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userSet": [ "collection/b", { "k": "b" } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 2 }, { "applyClientState": { "primary": true }, "expectedState": { "isPrimary": true }, "clientIndex": 2 }, { "drainQueue": true, "clientIndex": 0 }, { "writeAck": { "version": 2000, "keepInQueue": true }, "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 2 }, { "writeAck": { "version": 2000 }, "clientIndex": 2 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/b" ], "rejectedDocs": [] } }, "clientIndex": 1 } ] }, "Unresponsive primary ignores rejected write": { "describeName": "Writes:", "itName": "Unresponsive primary ignores rejected write", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 3 }, "steps": [ { "drainQueue": true, "expectedState": { "isPrimary": true }, "clientIndex": 0 }, { "userSet": [ "collection/a", { "k": "a" } ], "clientIndex": 0 }, { "writeAck": { "version": 1000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "userSet": [ "collection/b", { "k": "b" } ], "clientIndex": 1 }, { "drainQueue": true, "clientIndex": 2 }, { "applyClientState": { "primary": true }, "expectedState": { "isPrimary": true }, "clientIndex": 2 }, { "drainQueue": true, "clientIndex": 0 }, { "failWrite": { "error": { "code": 9 }, "keepInQueue": true }, "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 2 }, { "failWrite": { "error": { "code": 9 } }, "clientIndex": 2 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [], "rejectedDocs": [ "collection/b" ] } }, "clientIndex": 1 } ] }, "Mutation are not sent twice after primary failover": { "describeName": "Writes:", "itName": "Mutation are not sent twice after primary failover", "tags": [ "multi-client" ], "config": { "useGarbageCollection": false, "numClients": 2 }, "steps": [ { "drainQueue": true, "expectedState": { "isPrimary": true }, "clientIndex": 0 }, { "userSet": [ "collection/a", { "k": "a" } ], "clientIndex": 0 }, { "userSet": [ "collection/b", { "k": "b" } ], "clientIndex": 0 }, { "drainQueue": true, "clientIndex": 1 }, { "applyClientState": { "primary": true }, "expectedState": { "isPrimary": true }, "clientIndex": 1 }, { "writeAck": { "version": 1000 }, "clientIndex": 1 }, { "drainQueue": true, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/a" ], "rejectedDocs": [] } }, "clientIndex": 0 }, { "applyClientState": { "primary": true }, "expectedState": { "isPrimary": true }, "clientIndex": 0 }, { "writeAck": { "version": 2000 }, "expectedState": { "userCallbacks": { "acknowledgedDocs": [ "collection/b" ], "rejectedDocs": [] } }, "clientIndex": 0 }, { "userListen": [ 2, { "path": "collection", "filters": [], "orderBys": [] } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "path": "collection", "filters": [], "orderBys": [] } ], "resumeToken": "" } } }, "expectedSnapshotEvents": [ { "query": { "path": "collection", "filters": [], "orderBys": [] }, "added": [ { "key": "collection/a", "version": 1000, "value": { "k": "a" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": true } }, { "key": "collection/b", "version": 2000, "value": { "k": "b" }, "options": { "hasLocalMutations": false, "hasCommittedMutations": true } } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false } ], "clientIndex": 0 } ] } }