summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2020-03-24 11:29:28 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-24 15:58:51 +0000
commit80ebcc52a6ec27834a286ab1ab342db0d7f63756 (patch)
treee30f02e0dfd02a9f69769c841f447d6eeab681c0 /jstests/noPassthroughWithMongod
parentb6e4ebfeff3fb4e4158fba14eec841f510199d92 (diff)
downloadmongo-80ebcc52a6ec27834a286ab1ab342db0d7f63756.tar.gz
SERVER-46865 Make collMod not take database MODE_X lock
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r--jstests/noPassthroughWithMongod/collMod_no_conflicts.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/collMod_no_conflicts.js b/jstests/noPassthroughWithMongod/collMod_no_conflicts.js
new file mode 100644
index 00000000000..130582d2f61
--- /dev/null
+++ b/jstests/noPassthroughWithMongod/collMod_no_conflicts.js
@@ -0,0 +1,42 @@
+/**
+ * Tests that collMod does not conflict with a database MODE_IX lock.
+ */
+(function() {
+"use strict";
+
+load("jstests/libs/parallel_shell_helpers.js");
+load("jstests/libs/wait_for_command.js");
+
+const collName = "collMod_no_conflicts";
+const viewName = "testView";
+const testDB = db.getSiblingDB("test");
+testDB.dropDatabase();
+
+const sleepFunction = function(sleepDB) {
+ // If collMod calls need to wait on this lock, holding this lock for 4 hours will
+ // trigger a test timeout.
+ assert.commandFailedWithCode(
+ db.getSiblingDB("test").adminCommand(
+ {sleep: 1, secs: 18000, lockTarget: sleepDB, lock: "iw", $comment: "Lock sleep"}),
+ ErrorCodes.Interrupted);
+};
+
+const sleepCommand = startParallelShell(funWithArgs(sleepFunction, "test"), testDB.getMongo().port);
+const sleepID =
+ waitForCommand("sleepCmd",
+ op => (op["ns"] == "admin.$cmd" && op["command"]["$comment"] == "Lock sleep"),
+ testDB.getSiblingDB("admin"));
+
+assert.commandWorked(testDB.createView(viewName, collName, [{$match: {a: 1}}]));
+const collModPipeline = [{$match: {a: 2}}];
+assert.commandWorked(
+ testDB.runCommand({collMod: viewName, viewOn: collName, pipeline: collModPipeline}));
+
+const res = db.getCollectionInfos({name: viewName});
+assert.eq(res.length, 1);
+assert.eq(res[0].options.pipeline, collModPipeline);
+
+// Interrupt the sleep command.
+assert.commandWorked(testDB.getSiblingDB("admin").killOp(sleepID));
+sleepCommand();
+})(); \ No newline at end of file