From 81aebe8efa47c989593a22643685804cf63bb90c Mon Sep 17 00:00:00 2001 From: Lamont Nelson Date: Wed, 18 Dec 2019 23:01:33 +0000 Subject: SERVER-44375 fix merge_with_drop_shard.js when the curop command fails due to ShardNotFound (cherry picked from commit 33ac9f8ff5e9bae67592bc24cce55743306a52fb) --- jstests/sharding/merge_with_drop_shard.js | 28 +++++++++++++++++++--------- 1 file 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); -- cgit v1.2.1