summaryrefslogtreecommitdiff
path: root/jstests/replsets/apply_ops_idempotency.js
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@mongodb.com>2019-08-30 18:25:22 +0000
committerevergreen <evergreen@mongodb.com>2019-08-30 18:25:22 +0000
commitfca8f46ebfb94eebb5784ab54eb4bb774101e947 (patch)
tree87c93b1299e3150a29ee49bf14b0fea9b179aea9 /jstests/replsets/apply_ops_idempotency.js
parent31960610ac664d0f8cd026ab8481dc7a78edb957 (diff)
downloadmongo-fca8f46ebfb94eebb5784ab54eb4bb774101e947.tar.gz
SERVER-43043 Test applyOps on missing nested fields
Diffstat (limited to 'jstests/replsets/apply_ops_idempotency.js')
-rw-r--r--jstests/replsets/apply_ops_idempotency.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/jstests/replsets/apply_ops_idempotency.js b/jstests/replsets/apply_ops_idempotency.js
index 0b19267c6f5..6fa187c31b7 100644
--- a/jstests/replsets/apply_ops_idempotency.js
+++ b/jstests/replsets/apply_ops_idempotency.js
@@ -93,6 +93,18 @@ var tests = {
assert.commandWorked(z.insert({_id: 1}));
assert.commandWorked(z.insert({_id: 2, z: 2}));
},
+ arrayAndSubdocumentFields: (mydb) => {
+ let [x, y] = getCollections(mydb, ['x', 'y']);
+ // Array field.
+ assert.commandWorked(x.insert({_id: 1, x: 1, y: [0]}));
+ assert.commandWorked(x.update({_id: 1}, {$set: {x: 2, 'y.0': 2}}));
+ assert.commandWorked(x.update({_id: 1}, {$set: {y: 3}}));
+
+ // Subdocument field.
+ assert.commandWorked(y.insert({_id: 1, x: 1, y: {field: 0}}));
+ assert.commandWorked(y.update({_id: 1}, {$set: {x: 2, 'y.field': 2}}));
+ assert.commandWorked(y.update({_id: 1}, {$set: {y: 3}}));
+ },
renameCollectionWithinDatabase: (mydb) => {
let [x, y, z] = getCollections(mydb, ['x', 'y', 'z']);
assert.commandWorked(x.insert({_id: 1, x: 1}));
@@ -183,6 +195,7 @@ var tests = {
* additional databases, it should return an array with all databases to check.
*/
function testIdempotency(primary, testFun, testName) {
+ jsTestLog(`Execute ${testName}`);
// Create a new database name, so it's easier to filter out our oplog records later.
let dbname = (new Date()).toISOString().match(/[-0-9T]/g).join(''); // 2017-05-30T155055713
let mydb = primary.getDB(dbname);