diff options
author | Matthew Russotto <matthew.russotto@10gen.com> | 2017-10-03 16:22:37 -0400 |
---|---|---|
committer | Matthew Russotto <matthew.russotto@10gen.com> | 2017-10-05 10:20:35 -0400 |
commit | 316a341735b2ffd12ee203581ac0f736a6aaef88 (patch) | |
tree | 956dc9e0c0e6b2ee530182c18544af20f3cb887f /jstests/change_streams | |
parent | 47b62c3fdd712209dbe48fdf3928901304624320 (diff) | |
download | mongo-316a341735b2ffd12ee203581ac0f736a6aaef88.tar.gz |
SERVER-29716 Keystring-encode ResumeTokens to allow bytewise comparisons
Diffstat (limited to 'jstests/change_streams')
4 files changed, 14 insertions, 34 deletions
diff --git a/jstests/change_streams/change_stream.js b/jstests/change_streams/change_stream.js index 9ac347f406b..c1415a2a1f5 100644 --- a/jstests/change_streams/change_stream.js +++ b/jstests/change_streams/change_stream.js @@ -16,10 +16,6 @@ assert.writeOK(db.t1.insert({_id: 0, a: 1})); const t1Uuid = getUUIDFromListCollections(db, db.t1.getName()); let expected = { - _id: { - documentKey: {_id: 0}, - uuid: t1Uuid, - }, documentKey: {_id: 0}, fullDocument: {_id: 0, a: 1}, ns: {db: "test", coll: "t1"}, @@ -35,10 +31,6 @@ cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1}); assert.writeOK(db.t1.insert({_id: 1, a: 2})); expected = { - _id: { - documentKey: {_id: 1}, - uuid: t1Uuid, - }, documentKey: {_id: 1}, fullDocument: {_id: 1, a: 2}, ns: {db: "test", coll: "t1"}, @@ -50,7 +42,6 @@ cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1}); assert.writeOK(db.t1.update({_id: 0}, {a: 3})); expected = { - _id: {documentKey: {_id: 0}, uuid: t1Uuid}, documentKey: {_id: 0}, fullDocument: {_id: 0, a: 3}, ns: {db: "test", coll: "t1"}, @@ -62,7 +53,6 @@ cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1}); assert.writeOK(db.t1.update({_id: 0}, {b: 3})); expected = { - _id: {documentKey: {_id: 0}, uuid: t1Uuid}, documentKey: {_id: 0}, fullDocument: {_id: 0, b: 3}, ns: {db: "test", coll: "t1"}, @@ -74,10 +64,6 @@ cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1}); assert.writeOK(db.t1.update({_id: 2}, {a: 4}, {upsert: true})); expected = { - _id: { - documentKey: {_id: 2}, - uuid: t1Uuid, - }, documentKey: {_id: 2}, fullDocument: {_id: 2, a: 4}, ns: {db: "test", coll: "t1"}, @@ -90,7 +76,6 @@ cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1}); assert.writeOK(db.t1.update({_id: 3}, {$inc: {b: 2}})); expected = { - _id: {documentKey: {_id: 3}, uuid: t1Uuid}, documentKey: {_id: 3}, ns: {db: "test", coll: "t1"}, operationType: "update", @@ -102,7 +87,6 @@ cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1}); assert.writeOK(db.t1.remove({_id: 1})); expected = { - _id: {documentKey: {_id: 1}, uuid: t1Uuid}, documentKey: {_id: 1}, ns: {db: "test", coll: "t1"}, operationType: "delete", @@ -116,10 +100,6 @@ const t2Uuid = getUUIDFromListCollections(db, db.t2.getName()); cst.assertNextChangesEqual({cursor: cursor, expectedChanges: []}); expected = { - _id: { - documentKey: {_id: 100}, - uuid: t2Uuid, - }, documentKey: {_id: 100}, fullDocument: {_id: 100, c: 1}, ns: {db: "test", coll: "t2"}, @@ -136,7 +116,7 @@ db.t3.drop(); t2cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t2}); assert.writeOK(db.t2.renameCollection("t3")); - expected = {_id: {uuid: t2Uuid}, operationType: "invalidate"}; + expected = {operationType: "invalidate"}; cst.assertNextChangesEqual( {cursor: t2cursor, expectedChanges: [expected], expectInvalidate: true}); @@ -169,7 +149,7 @@ // Note we do not project away 'id.ts' as it is part of the resume token. let resumeCursor = cst.startWatchingChanges( - {pipeline: [{$changeStream: {}}], collection: db.resume1, includeTs: true}); + {pipeline: [{$changeStream: {}}], collection: db.resume1, includeToken: true}); // Insert a document and save the resulting change stream. assert.writeOK(db.resume1.insert({_id: 1})); @@ -180,7 +160,7 @@ resumeCursor = cst.startWatchingChanges({ pipeline: [{$changeStream: {resumeAfter: firstInsertChangeDoc._id}}], collection: db.resume1, - includeTs: true, + includeToken: true, aggregateOptions: {cursor: {batchSize: 0}}, }); @@ -196,7 +176,7 @@ resumeCursor = cst.startWatchingChanges({ pipeline: [{$changeStream: {resumeAfter: firstInsertChangeDoc._id}}], collection: db.resume1, - includeTs: true, + includeToken: true, aggregateOptions: {cursor: {batchSize: 0}}, }); assert.docEq(cst.getOneChange(resumeCursor), secondInsertChangeDoc); @@ -206,7 +186,7 @@ resumeCursor = cst.startWatchingChanges({ pipeline: [{$changeStream: {resumeAfter: secondInsertChangeDoc._id}}], collection: db.resume1, - includeTs: true, + includeToken: true, aggregateOptions: {cursor: {batchSize: 0}}, }); assert.docEq(cst.getOneChange(resumeCursor), thirdInsertChangeDoc); diff --git a/jstests/change_streams/change_stream_invalidation.js b/jstests/change_streams/change_stream_invalidation.js index d6aa05c57cb..8c4c1af2437 100644 --- a/jstests/change_streams/change_stream_invalidation.js +++ b/jstests/change_streams/change_stream_invalidation.js @@ -42,7 +42,7 @@ assert.eq(change.operationType, "delete", tojson(change)); cst.assertNextChangesEqual({ cursor: aggcursor, - expectedChanges: [{_id: {uuid: collGetMoreUuid}, operationType: "invalidate"}], + expectedChanges: [{operationType: "invalidate"}], expectInvalidate: true }); @@ -51,7 +51,8 @@ db.createCollection(collAgg.getName()); const collAggUuid = getUUIDFromListCollections(db, collAgg.getName()); // Get a valid resume token that the next aggregate command can use. - aggcursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: collAgg}); + aggcursor = cst.startWatchingChanges( + {pipeline: [{$changeStream: {}}], collection: collAgg, includeToken: true}); assert.writeOK(collAgg.insert({_id: 1}, {writeConcern: {w: "majority"}})); diff --git a/jstests/change_streams/lookup_post_image.js b/jstests/change_streams/lookup_post_image.js index ee5d90bf158..0f75ad073e9 100644 --- a/jstests/change_streams/lookup_post_image.js +++ b/jstests/change_streams/lookup_post_image.js @@ -17,7 +17,7 @@ // Test that not specifying 'fullDocument' does include a 'fullDocument' in the result for an // insert. let cursor = cst.startWatchingChanges( - {pipeline: [{$changeStream: {}}], collection: coll, includeTs: true}); + {pipeline: [{$changeStream: {}}], collection: coll, includeToken: true}); assert.writeOK(coll.insert({_id: "fullDocument not specified"})); let latestChange = cst.getOneChange(cursor); assert.eq(latestChange.operationType, "insert"); @@ -45,7 +45,7 @@ cursor = cst.startWatchingChanges({ collection: coll, pipeline: [{$changeStream: {fullDocument: "default"}}], - includeTs: true + includeToken: true }); assert.writeOK(coll.insert({_id: "fullDocument is default"})); latestChange = cst.getOneChange(cursor); @@ -74,7 +74,7 @@ cursor = cst.startWatchingChanges({ collection: coll, pipeline: [{$changeStream: {fullDocument: "updateLookup"}}], - includeTs: true + includeToken: true }); assert.writeOK(coll.insert({_id: "fullDocument is lookup"})); latestChange = cst.getOneChange(cursor); @@ -103,7 +103,7 @@ collection: coll, pipeline: [{$changeStream: {fullDocument: "updateLookup"}}, {$match: {operationType: "update"}}], - includeTs: true + includeToken: true }); assert.writeOK(coll.update({_id: "fullDocument is lookup"}, {$set: {updatedAgain: true}})); assert.writeOK(coll.remove({_id: "fullDocument is lookup"})); diff --git a/jstests/change_streams/only_wake_getmore_for_relevant_changes.js b/jstests/change_streams/only_wake_getmore_for_relevant_changes.js index 87c082199b7..f7d909f039f 100644 --- a/jstests/change_streams/only_wake_getmore_for_relevant_changes.js +++ b/jstests/change_streams/only_wake_getmore_for_relevant_changes.js @@ -112,8 +112,8 @@ eventFn();`, const wholeCollectionStreamComment = "change stream on entire collection"; let res = assert.commandWorked(db.runCommand({ aggregate: changesCollection.getName(), - // Project out the timestamp, since that's subject to change unpredictably. - pipeline: [{$changeStream: {}}, {$project: {"_id.clusterTime": 0}}], + // Project out the resume token, since that's subject to change unpredictably. + pipeline: [{$changeStream: {}}, {$project: {"_id": 0}}], cursor: {}, comment: wholeCollectionStreamComment })); @@ -132,7 +132,6 @@ eventFn();`, assert.eq(getMoreResponse.cursor.nextBatch.length, 1); const changesCollectionUuid = getUUIDFromListCollections(db, changesCollection.getName()); assert.docEq(getMoreResponse.cursor.nextBatch[0], { - _id: {documentKey: {_id: "wake up"}, uuid: changesCollectionUuid}, documentKey: {_id: "wake up"}, fullDocument: {_id: "wake up"}, ns: {db: db.getName(), coll: changesCollection.getName()}, |