diff options
author | Mickey. J Winters <mickey.winters@mongodb.com> | 2022-03-17 02:59:18 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-17 03:29:03 +0000 |
commit | 853ae19875607294030344ec9155ae8cd8b1bf00 (patch) | |
tree | 75183228d793b09d15601eacc0cdd2cd31d086eb | |
parent | 425aa6786b0dcda8bc68387d20437a83edaa6a03 (diff) | |
download | mongo-853ae19875607294030344ec9155ae8cd8b1bf00.tar.gz |
SERVER-64362 Add resume before invalidate regression test for per shard cursors
-rw-r--r-- | jstests/change_streams/report_post_batch_resume_token.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/jstests/change_streams/report_post_batch_resume_token.js b/jstests/change_streams/report_post_batch_resume_token.js index 37f5f6cea3f..219fd4078b9 100644 --- a/jstests/change_streams/report_post_batch_resume_token.js +++ b/jstests/change_streams/report_post_batch_resume_token.js @@ -224,4 +224,26 @@ assert.gt(bsonWoCompare(txnEvent3._id, previousGetMorePBRT), 0); // appear in the batch. Confirm that the postBatchResumeToken has been set correctly. getMorePBRT = csCursor.getResumeToken(); assert.gte(bsonWoCompare(getMorePBRT, txnEvent3._id), 0); + +// Watch a collection, drop it, and then resume before the invalidate but filter out all events +// This scenario means that we shouldn't get any events but the resume token should still be +// present. This way the pbrt can't come from a document in the batch, and even if there is an +// invalidate the pbrt should still be set. +csCursor = testCollection.watch([], {cursor: {batchSize: 0}}); +assert.eq(csCursor.objsLeftInBatch(), 0); +assert.neq(undefined, csCursor.getResumeToken()); +testCollection.drop(); + +csCursor = testCollection.watch([{$match: {dontMatchAnything: true}}], + {resumeAfter: previousGetMorePBRT, cursor: {batchSize: 0}}); +assert.eq(csCursor.objsLeftInBatch(), 0); +initialAggPBRT = csCursor.getResumeToken(); +assert.neq(undefined, initialAggPBRT); + +// Trigger a getMore and make sure we can get another PBRT. +assert.soon(() => { + csCursor.hasNext(); + assert.neq(undefined, csCursor.getResumeToken()); + return initialAggPBRT != csCursor.getResumeToken(); +}); })(); |