summaryrefslogtreecommitdiff
path: root/jstests/change_streams
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-02-26 12:49:37 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-03-06 11:49:34 -0500
commit50f6bd4d6a9428a6f1df22db792d7b55d773762c (patch)
tree93be9c5351129cf44e8d8a82a323f4403a89cb63 /jstests/change_streams
parent9ef7f78e3cc33ca2cb0d8bd31fd71e954987e1ea (diff)
downloadmongo-50f6bd4d6a9428a6f1df22db792d7b55d773762c.tar.gz
SERVER-39495 Add more testing for multi:true/justOne:false updates and ChangeStreams
Diffstat (limited to 'jstests/change_streams')
-rw-r--r--jstests/change_streams/change_stream.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/jstests/change_streams/change_stream.js b/jstests/change_streams/change_stream.js
index 7c5688b0704..9f41255c599 100644
--- a/jstests/change_streams/change_stream.js
+++ b/jstests/change_streams/change_stream.js
@@ -132,6 +132,27 @@
};
cst.assertNextChangesEqual({cursor: cursor, expectedChanges: [expected]});
+ jsTestLog("Testing multi:true update");
+ assert.writeOK(db.t1.insert({_id: 4, a: 0, b: 1}));
+ assert.writeOK(db.t1.insert({_id: 5, a: 0, b: 1}));
+ cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1});
+ assert.writeOK(db.t1.update({a: 0}, {$set: {b: 2}}, {multi: true}));
+ expected = [
+ {
+ documentKey: {_id: 4},
+ ns: {db: "test", coll: "t1"},
+ operationType: "update",
+ updateDescription: {removedFields: [], updatedFields: {b: 2}}
+ },
+ {
+ documentKey: {_id: 5},
+ ns: {db: "test", coll: "t1"},
+ operationType: "update",
+ updateDescription: {removedFields: [], updatedFields: {b: 2}}
+ }
+ ];
+ cst.assertNextChangesEqual({cursor: cursor, expectedChanges: expected});
+
jsTestLog("Testing delete");
cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1});
assert.writeOK(db.t1.remove({_id: 1}));
@@ -142,6 +163,25 @@
};
cst.assertNextChangesEqual({cursor: cursor, expectedChanges: [expected]});
+ jsTestLog("Testing justOne:false delete");
+ assert.writeOK(db.t1.insert({_id: 6, a: 1, b: 1}));
+ assert.writeOK(db.t1.insert({_id: 7, a: 1, b: 1}));
+ cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1});
+ assert.writeOK(db.t1.remove({a: 1}, {justOne: false}));
+ expected = [
+ {
+ documentKey: {_id: 6},
+ ns: {db: "test", coll: "t1"},
+ operationType: "delete",
+ },
+ {
+ documentKey: {_id: 7},
+ ns: {db: "test", coll: "t1"},
+ operationType: "delete",
+ }
+ ];
+ cst.assertNextChangesEqual({cursor: cursor, expectedChanges: expected});
+
jsTestLog("Testing intervening write on another collection");
cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t1});
let t2cursor = cst.startWatchingChanges({pipeline: [{$changeStream: {}}], collection: db.t2});