diff options
Diffstat (limited to 'jstests/change_streams/lookup_post_image.js')
-rw-r--r-- | jstests/change_streams/lookup_post_image.js | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/jstests/change_streams/lookup_post_image.js b/jstests/change_streams/lookup_post_image.js index fa2658ed6f8..c918fd22110 100644 --- a/jstests/change_streams/lookup_post_image.js +++ b/jstests/change_streams/lookup_post_image.js @@ -20,22 +20,22 @@ jsTestLog("Testing change streams without 'fullDocument' specified"); // Test that not specifying 'fullDocument' does include a 'fullDocument' in the result for // an insert. let cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: coll}); -assert.writeOK(coll.insert({_id: "fullDocument not specified"})); +assert.commandWorked(coll.insert({_id: "fullDocument not specified"})); let latestChange = cst.getOneChange(cursor); assert.eq(latestChange.operationType, "insert"); assert.eq(latestChange.fullDocument, {_id: "fullDocument not specified"}); // Test that not specifying 'fullDocument' does include a 'fullDocument' in the result for a // replacement-style update. -assert.writeOK(coll.update({_id: "fullDocument not specified"}, - {_id: "fullDocument not specified", replaced: true})); +assert.commandWorked(coll.update({_id: "fullDocument not specified"}, + {_id: "fullDocument not specified", replaced: true})); latestChange = cst.getOneChange(cursor); assert.eq(latestChange.operationType, "replace"); assert.eq(latestChange.fullDocument, {_id: "fullDocument not specified", replaced: true}); // Test that not specifying 'fullDocument' does not include a 'fullDocument' in the result // for a non-replacement update. -assert.writeOK(coll.update({_id: "fullDocument not specified"}, {$set: {updated: true}})); +assert.commandWorked(coll.update({_id: "fullDocument not specified"}, {$set: {updated: true}})); latestChange = cst.getOneChange(cursor); assert.eq(latestChange.operationType, "update"); assert(!latestChange.hasOwnProperty("fullDocument")); @@ -46,22 +46,22 @@ jsTestLog("Testing change streams with 'fullDocument' specified as 'default'"); // result for an insert. cursor = cst.startWatchingChanges( {collection: coll, pipeline: [{$changeStream: {fullDocument: "default"}}]}); -assert.writeOK(coll.insert({_id: "fullDocument is default"})); +assert.commandWorked(coll.insert({_id: "fullDocument is default"})); latestChange = cst.getOneChange(cursor); assert.eq(latestChange.operationType, "insert"); assert.eq(latestChange.fullDocument, {_id: "fullDocument is default"}); // Test that specifying 'fullDocument' as 'default' does include a 'fullDocument' in the // result for a replacement-style update. -assert.writeOK(coll.update({_id: "fullDocument is default"}, - {_id: "fullDocument is default", replaced: true})); +assert.commandWorked(coll.update({_id: "fullDocument is default"}, + {_id: "fullDocument is default", replaced: true})); latestChange = cst.getOneChange(cursor); assert.eq(latestChange.operationType, "replace"); assert.eq(latestChange.fullDocument, {_id: "fullDocument is default", replaced: true}); // Test that specifying 'fullDocument' as 'default' does not include a 'fullDocument' in the // result for a non-replacement update. -assert.writeOK(coll.update({_id: "fullDocument is default"}, {$set: {updated: true}})); +assert.commandWorked(coll.update({_id: "fullDocument is default"}, {$set: {updated: true}})); latestChange = cst.getOneChange(cursor); assert.eq(latestChange.operationType, "update"); assert(!latestChange.hasOwnProperty("fullDocument")); @@ -72,14 +72,14 @@ jsTestLog("Testing change streams with 'fullDocument' specified as 'updateLookup // the result for an insert. cursor = cst.startWatchingChanges( {collection: coll, pipeline: [{$changeStream: {fullDocument: "updateLookup"}}]}); -assert.writeOK(coll.insert({_id: "fullDocument is lookup"})); +assert.commandWorked(coll.insert({_id: "fullDocument is lookup"})); latestChange = cst.getOneChange(cursor); assert.eq(latestChange.operationType, "insert"); assert.eq(latestChange.fullDocument, {_id: "fullDocument is lookup"}); // Test that specifying 'fullDocument' as 'updateLookup' does include a 'fullDocument' in // the result for a replacement-style update. -assert.writeOK( +assert.commandWorked( coll.update({_id: "fullDocument is lookup"}, {_id: "fullDocument is lookup", replaced: true})); latestChange = cst.getOneChange(cursor); assert.eq(latestChange.operationType, "replace"); @@ -87,7 +87,7 @@ assert.eq(latestChange.fullDocument, {_id: "fullDocument is lookup", replaced: t // Test that specifying 'fullDocument' as 'updateLookup' does include a 'fullDocument' in // the result for a non-replacement update. -assert.writeOK(coll.update({_id: "fullDocument is lookup"}, {$set: {updated: true}})); +assert.commandWorked(coll.update({_id: "fullDocument is lookup"}, {$set: {updated: true}})); latestChange = cst.getOneChange(cursor); assert.eq(latestChange.operationType, "update"); assert.eq(latestChange.fullDocument, @@ -99,8 +99,8 @@ cursor = cst.startWatchingChanges({ collection: coll, pipeline: [{$changeStream: {fullDocument: "updateLookup"}}, {$match: {operationType: "update"}}] }); -assert.writeOK(coll.update({_id: "fullDocument is lookup"}, {$set: {updatedAgain: true}})); -assert.writeOK(coll.remove({_id: "fullDocument is lookup"})); +assert.commandWorked(coll.update({_id: "fullDocument is lookup"}, {$set: {updatedAgain: true}})); +assert.commandWorked(coll.remove({_id: "fullDocument is lookup"})); // If this test is running with secondary read preference, it's necessary for the remove // to propagate to all secondary nodes and be available for majority reads before we can // assume looking up the document will fail. @@ -115,8 +115,8 @@ const deleteDocResumePoint = latestChange._id; // Test that looking up the post image of an update after the collection has been dropped // will result in 'fullDocument' with a value of null. This must be done using getMore // because new cursors cannot be established after a collection drop. -assert.writeOK(coll.insert({_id: "fullDocument is lookup 2"})); -assert.writeOK(coll.update({_id: "fullDocument is lookup 2"}, {$set: {updated: true}})); +assert.commandWorked(coll.insert({_id: "fullDocument is lookup 2"})); +assert.commandWorked(coll.update({_id: "fullDocument is lookup 2"}, {$set: {updated: true}})); // Open a $changeStream cursor with batchSize 0, so that no oplog entries are retrieved yet. cursor = cst.startWatchingChanges({ @@ -200,7 +200,7 @@ assert.eq(latestChange.fullDocument, null); // Insert a document with the same _id, verify the change stream won't return it due to // different UUID. assertCreateCollection(db, coll.getName()); -assert.writeOK(coll.insert({_id: "fullDocument is lookup 2"})); +assert.commandWorked(coll.insert({_id: "fullDocument is lookup 2"})); // Confirm that the next entry's post-image is null since new collection has a different // UUID. @@ -210,13 +210,13 @@ assert(latestChange.hasOwnProperty("fullDocument")); assert.eq(latestChange.fullDocument, null); jsTestLog("Testing full document lookup with a real getMore"); -assert.writeOK(coll.insert({_id: "getMoreEnabled"})); +assert.commandWorked(coll.insert({_id: "getMoreEnabled"})); cursor = cst.startWatchingChanges({ collection: coll, pipeline: [{$changeStream: {fullDocument: "updateLookup"}}], }); -assert.writeOK(coll.update({_id: "getMoreEnabled"}, {$set: {updated: true}})); +assert.commandWorked(coll.update({_id: "getMoreEnabled"}, {$set: {updated: true}})); const doc = cst.getOneChange(cursor); assert.docEq(doc["fullDocument"], {_id: "getMoreEnabled", updated: true}); @@ -228,7 +228,7 @@ cursor = cst.startWatchingChanges({ pipeline: [{$changeStream: {fullDocument: "updateLookup"}}], aggregateOptions: {cursor: {batchSize: 0}} }); -assert.writeOK(coll.insert({_id: "testing invalidate"})); +assert.commandWorked(coll.insert({_id: "testing invalidate"})); assertDropCollection(db, coll.getName()); // Wait until two-phase drop finishes. assert.soon(function() { |