summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorNick Zolnierz <nicholas.zolnierz@mongodb.com>2020-04-13 16:30:46 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-17 15:18:47 +0000
commit35eaeffc84f58e12764844f83bd8ee6de710e8eb (patch)
tree328105a9fe164a13f918f66bfcd204461932129d /jstests
parente10ed5174e56ecdb93009d7983896daa76211efd (diff)
downloadmongo-35eaeffc84f58e12764844f83bd8ee6de710e8eb.tar.gz
SERVER-47513 Modify killop.js to search for op by 'comment' in currentOp output
(cherry picked from commit 27c9e2a978009f6fb3d23d0327e2126bb6e662d6)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthrough/killop.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/jstests/noPassthrough/killop.js b/jstests/noPassthrough/killop.js
index 50445470323..f66ffe22611 100644
--- a/jstests/noPassthrough/killop.js
+++ b/jstests/noPassthrough/killop.js
@@ -11,22 +11,26 @@ const collName = "test";
// a sharded cluster. 'shardConn' is a connection to the mongod we enable failpoints on.
function runTest(conn, shardConn) {
const db = conn.getDB(dbName);
- assert.commandWorked(db.dropDatabase());
- assert.commandWorked(db.getCollection(collName).insert({x: 1}));
assert.commandWorked(
shardConn.adminCommand({setParameter: 1, internalQueryExecYieldIterations: 1}));
assert.commandWorked(
shardConn.adminCommand({"configureFailPoint": "setYieldAllLocksHang", "mode": "alwaysOn"}));
+ const findComment = "unique_find_comment";
const queryToKill = "assert.commandWorked(db.getSiblingDB('" + dbName +
- "').runCommand({find: '" + collName + "', filter: {x: 1}}));";
+ "').runCommand({find: '" + collName + "', filter: {x: 1}, comment: '" + findComment +
+ "'}));";
const awaitShell = startParallelShell(queryToKill, conn.port);
let opId;
+ const curOpFilter = {
+ "ns": dbName + "." + collName,
+ "command.comment": findComment,
+ };
assert.soon(
function() {
- const result = db.currentOp({"ns": dbName + "." + collName, "command.filter": {x: 1}});
+ const result = db.currentOp(curOpFilter);
assert.commandWorked(result);
if (result.inprog.length === 1 && result.inprog[0].numYields > 0) {
opId = result.inprog[0].opid;
@@ -42,7 +46,7 @@ function runTest(conn, shardConn) {
assert.commandWorked(db.killOp(opId));
- let result = db.currentOp({"ns": dbName + "." + collName, "command.filter": {x: 1}});
+ let result = db.currentOp(curOpFilter);
assert.commandWorked(result);
assert(result.inprog.length === 1, tojson(db.currentOp()));
assert(result.inprog[0].hasOwnProperty("killPending"));
@@ -54,7 +58,7 @@ function runTest(conn, shardConn) {
const exitCode = awaitShell({checkExitSuccess: false});
assert.neq(0, exitCode, "Expected shell to exit with failure due to operation kill");
- result = db.currentOp({"ns": dbName + "." + collName, "query.filter": {x: 1}});
+ result = db.currentOp(curOpFilter);
assert.commandWorked(result);
assert(result.inprog.length === 0, tojson(db.currentOp()));
}
@@ -62,6 +66,9 @@ function runTest(conn, shardConn) {
const st = new ShardingTest({shards: 1, rs: {nodes: 1}, mongos: 1});
const shardConn = st.rs0.getPrimary();
+// Create the unsharded collection.
+assert.commandWorked(st.s.getDB(dbName).getCollection(collName).insert({x: 1}));
+
// Test killOp against mongod.
runTest(shardConn, shardConn);