summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Nelson <lamont.nelson@mongodb.com>2019-12-18 23:01:33 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-07 00:54:59 +0000
commit81aebe8efa47c989593a22643685804cf63bb90c (patch)
tree9b76a17b9ae6bc6771ca8067c3e18dfef7367a1f
parenta6a748f34037aec39a0d75d6082a9819031747fa (diff)
downloadmongo-81aebe8efa47c989593a22643685804cf63bb90c.tar.gz
SERVER-44375 fix merge_with_drop_shard.js when the curop command fails due to ShardNotFound
(cherry picked from commit 33ac9f8ff5e9bae67592bc24cce55743306a52fb)
-rw-r--r--jstests/sharding/merge_with_drop_shard.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/jstests/sharding/merge_with_drop_shard.js b/jstests/sharding/merge_with_drop_shard.js
index cc03ea31c42..068c050c117 100644
--- a/jstests/sharding/merge_with_drop_shard.js
+++ b/jstests/sharding/merge_with_drop_shard.js
@@ -48,6 +48,7 @@ function addShard(shard) {
assert.commandWorked(
st.s.adminCommand({moveChunk: sourceColl.getFullName(), find: {shardKey: 0}, to: shard}));
}
+
function runMergeWithMode(
whenMatchedMode, whenNotMatchedMode, shardedColl, dropShard, expectFailCode) {
// Set the failpoint to hang in the first call to DocumentSourceCursor's getNext().
@@ -79,15 +80,24 @@ function runMergeWithMode(
let mergeShell = startParallelShell(outFn, st.s.port);
// Wait for the parallel shell to hit the failpoint.
- assert.soon(() => mongosDB
- .currentOp({
- $or: [
- {op: "command", "command.comment": comment},
- {op: "getmore", "cursor.originatingCommand.comment": comment}
- ]
- })
- .inprog.length >= 1,
- () => tojson(mongosDB.currentOp().inprog));
+ // currentOp can fail with ShardNotFound since we remove
+ // the shard on some test runs.
+ assert.soon(
+ () => {
+ const response = assert.commandWorkedOrFailedWithCode(mongosDB.currentOp({
+ $or: [
+ {op: "command", "command.comment": comment},
+ {op: "getmore", "cursor.originatingCommand.comment": comment}
+ ]
+ }),
+ [ErrorCodes.ShardNotFound]);
+ return (response.ok) ? response.inprog.length >= 1 : false;
+ },
+ () => {
+ const msg = "Timeout waiting for parallel shell to hit the failpoint";
+ const response = mongosDB.currentOp();
+ return (response.ok) ? msg + ":\n" + tojson(response.inprog) : msg;
+ });
if (dropShard) {
removeShard(st.shard0);