summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-11-12 05:59:00 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-12 11:24:14 +0000
commit2fb371beb62cb41ad9c0998424e64db48efff651 (patch)
tree06155fdd402cc03b46c40a5eb52c3aae64cd20f4 /jstests
parent9e3acea37779e6105c9445d6b4c4da070f87af77 (diff)
downloadmongo-2fb371beb62cb41ad9c0998424e64db48efff651.tar.gz
SERVER-61160 disallow dry run mode for collMod under applyOps
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/collmod_convert_to_unique_apply_ops.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/jstests/core/collmod_convert_to_unique_apply_ops.js b/jstests/core/collmod_convert_to_unique_apply_ops.js
index 3b272978c22..543648aebdb 100644
--- a/jstests/core/collmod_convert_to_unique_apply_ops.js
+++ b/jstests/core/collmod_convert_to_unique_apply_ops.js
@@ -73,6 +73,16 @@ jsTestLog('Duplicate key error from failed conversion: ' + tojson(duplicateKeyEr
assert.eq(1, duplicateKeyError.applied, tojson(duplicateKeyError));
assert.commandWorked(coll.remove({_id: 2}));
+// Dry run mode is not supported for running collMod through applyOps.
+// There should not be existing oplog entries with dryRun=true to route
+// through applyOps.
+const dryRunCmd = Object.extend({}, applyOpsCmd, true /* deep */);
+dryRunCmd.applyOps[0].o.dryRun = true;
+jsTestLog('Running collMod in dry run mode through applyOps: ' + tojson(dryRunCmd));
+const dryRunError =
+ assert.commandFailedWithCode(db.adminCommand(dryRunCmd), ErrorCodes.InvalidOptions);
+jsTestLog('Rejected dry run mode result: ' + tojson(dryRunError));
+
// Successfully converts to a unique index.
const result = assert.commandWorked(db.adminCommand(applyOpsCmd));