{ "Contents of active query are kept while inactive results are removed after GC": { "describeName": "Garbage Collection:", "itName": "Contents of active query are kept while inactive results are removed after GC", "tags": [ ], "config": { "numClients": 1, "useEagerGCForMemory": false }, "steps": [ { "userListen": { "query": { "filters": [ ], "orderBys": [ ], "path": "collection" }, "targetId": 2 }, "expectedState": { "activeTargets": { "2": { "queries": [ { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 }, { "createTime": 0, "key": "collection/b", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "b" }, "version": 1000 }, { "createTime": 0, "key": "collection/c", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "c" }, "version": 1000 }, { "createTime": 0, "key": "collection/d", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "d" }, "version": 1000 } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "targetIds": [ ], "version": 1000 }, "expectedSnapshotEvents": [ { "added": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 }, { "createTime": 0, "key": "collection/b", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "b" }, "version": 1000 }, { "createTime": 0, "key": "collection/c", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "c" }, "version": 1000 }, { "createTime": 0, "key": "collection/d", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "d" }, "version": 1000 } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false, "query": { "filters": [ ], "orderBys": [ ], "path": "collection" } } ] }, { "userUnlisten": [ 2, { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "expectedState": { "activeTargets": { } } }, { "userListen": { "query": { "filters": [ [ "key", "==", "a" ] ], "orderBys": [ ], "path": "collection" }, "targetId": 4 }, "expectedSnapshotEvents": [ { "added": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false, "query": { "filters": [ [ "key", "==", "a" ] ], "orderBys": [ ], "path": "collection" } } ], "expectedState": { "activeTargets": { "4": { "queries": [ { "filters": [ [ "key", "==", "a" ] ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "" } } } }, { "watchAck": [ 4 ] }, { "watchEntity": { "docs": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "targets": [ 4 ] } }, { "watchCurrent": [ [ 4 ], "resume-token-1500" ] }, { "watchSnapshot": { "targetIds": [ ], "version": 1500 }, "expectedSnapshotEvents": [ { "errorCode": 0, "fromCache": false, "hasPendingWrites": false, "query": { "filters": [ [ "key", "==", "a" ] ], "orderBys": [ ], "path": "collection" } } ] }, { "userSet": [ "collection/c", { "extra": "extra", "key": "c" } ] }, { "triggerLruGC": 1 }, { "userUnlisten": [ 4, { "filters": [ [ "key", "==", "a" ] ], "orderBys": [ ], "path": "collection" } ], "expectedState": { "activeTargets": { } } }, { "userListen": { "query": { "filters": [ ], "orderBys": [ ], "path": "collection" }, "targetId": 6 }, "expectedSnapshotEvents": [ { "added": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 }, { "createTime": 0, "key": "collection/c", "options": { "hasCommittedMutations": false, "hasLocalMutations": true }, "value": { "extra": "extra", "key": "c" }, "version": 0 } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": true, "query": { "filters": [ ], "orderBys": [ ], "path": "collection" } } ], "expectedState": { "activeTargets": { "6": { "queries": [ { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "" } } } } ] }, "Contents of query are cleared when listen is removed.": { "comment": "Explicitly tests eager GC behavior", "describeName": "Garbage Collection:", "itName": "Contents of query are cleared when listen is removed.", "tags": [ "eager-gc" ], "config": { "numClients": 1, "useEagerGCForMemory": true }, "steps": [ { "userListen": { "query": { "filters": [ ], "orderBys": [ ], "path": "collection" }, "targetId": 2 }, "expectedState": { "activeTargets": { "2": { "queries": [ { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "targetIds": [ ], "version": 1000 }, "expectedSnapshotEvents": [ { "added": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false, "query": { "filters": [ ], "orderBys": [ ], "path": "collection" } } ] }, { "userUnlisten": [ 2, { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "expectedState": { "activeTargets": { } } }, { "userListen": { "query": { "filters": [ ], "orderBys": [ ], "path": "collection" }, "targetId": 4 }, "expectedState": { "activeTargets": { "4": { "queries": [ { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "" } } } } ] }, "Contents of query are kept after listen is removed, and GC threshold is not reached": { "describeName": "Garbage Collection:", "itName": "Contents of query are kept after listen is removed, and GC threshold is not reached", "tags": [ ], "config": { "numClients": 1, "useEagerGCForMemory": false }, "steps": [ { "userListen": { "query": { "filters": [ ], "orderBys": [ ], "path": "collection" }, "targetId": 2 }, "expectedState": { "activeTargets": { "2": { "queries": [ { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "targetIds": [ ], "version": 1000 }, "expectedSnapshotEvents": [ { "added": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false, "query": { "filters": [ ], "orderBys": [ ], "path": "collection" } } ] }, { "userUnlisten": [ 2, { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "expectedState": { "activeTargets": { } } }, { "triggerLruGC": 1000000000 }, { "userListen": { "query": { "filters": [ ], "orderBys": [ ], "path": "collection" }, "targetId": 2 }, "expectedSnapshotEvents": [ { "added": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false, "query": { "filters": [ ], "orderBys": [ ], "path": "collection" } } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "resume-token-1000" } } } } ] }, "Contents of query are kept after listen is removed.": { "describeName": "Garbage Collection:", "itName": "Contents of query are kept after listen is removed.", "tags": [ ], "config": { "numClients": 1, "useEagerGCForMemory": false }, "steps": [ { "userListen": { "query": { "filters": [ ], "orderBys": [ ], "path": "collection" }, "targetId": 2 }, "expectedState": { "activeTargets": { "2": { "queries": [ { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "targetIds": [ ], "version": 1000 }, "expectedSnapshotEvents": [ { "added": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false, "query": { "filters": [ ], "orderBys": [ ], "path": "collection" } } ] }, { "userUnlisten": [ 2, { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "expectedState": { "activeTargets": { } } }, { "userListen": { "query": { "filters": [ ], "orderBys": [ ], "path": "collection" }, "targetId": 2 }, "expectedSnapshotEvents": [ { "added": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "errorCode": 0, "fromCache": true, "hasPendingWrites": false, "query": { "filters": [ ], "orderBys": [ ], "path": "collection" } } ], "expectedState": { "activeTargets": { "2": { "queries": [ { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "resume-token-1000" } } } } ] }, "Contents of query are removed after listen is removed, and GC threshold is reached": { "describeName": "Garbage Collection:", "itName": "Contents of query are removed after listen is removed, and GC threshold is reached", "tags": [ ], "config": { "numClients": 1, "useEagerGCForMemory": false }, "steps": [ { "userListen": { "query": { "filters": [ ], "orderBys": [ ], "path": "collection" }, "targetId": 2 }, "expectedState": { "activeTargets": { "2": { "queries": [ { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "" } } } }, { "watchAck": [ 2 ] }, { "watchEntity": { "docs": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "targets": [ 2 ] } }, { "watchCurrent": [ [ 2 ], "resume-token-1000" ] }, { "watchSnapshot": { "targetIds": [ ], "version": 1000 }, "expectedSnapshotEvents": [ { "added": [ { "createTime": 0, "key": "collection/a", "options": { "hasCommittedMutations": false, "hasLocalMutations": false }, "value": { "key": "a" }, "version": 1000 } ], "errorCode": 0, "fromCache": false, "hasPendingWrites": false, "query": { "filters": [ ], "orderBys": [ ], "path": "collection" } } ] }, { "userUnlisten": [ 2, { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "expectedState": { "activeTargets": { } } }, { "triggerLruGC": 1 }, { "userListen": { "query": { "filters": [ ], "orderBys": [ ], "path": "collection" }, "targetId": 4 }, "expectedState": { "activeTargets": { "4": { "queries": [ { "filters": [ ], "orderBys": [ ], "path": "collection" } ], "resumeToken": "" } } } } ] } }