diff --git a/jstests/sharding/move_chunk_find_and_modify_with_write_retryability.js b/jstests/sharding/move_chunk_find_and_modify_with_write_retryability.js index 55b8ccf3540..06802d65c61 100644 --- a/jstests/sharding/move_chunk_find_and_modify_with_write_retryability.js +++ b/jstests/sharding/move_chunk_find_and_modify_with_write_retryability.js @@ -105,7 +105,15 @@ load("jstests/sharding/move_chunk_with_session_helper.js"); }, ]; - var st = new ShardingTest({shards: {rs0: {nodes: 2}, rs1: {nodes: 2}}}); + // Prevent unnecessary elections in the first shard replica set. Shard 'rs1' shard will need its + // secondary to get elected, so we don't give it a zero priority. + var st = new ShardingTest({ + mongos: 2, + shards: { + rs0: {nodes: [{rsConfig: {}}, {rsConfig: {priority: 0}}]}, + rs1: {nodes: [{rsConfig: {}}, {rsConfig: {}}]} + } + }); assert.commandWorked(st.s.adminCommand({enableSharding: 'test'})); st.ensurePrimaryShard('test', st.shard0.shardName); diff --git a/jstests/sharding/move_chunk_insert_with_write_retryability.js b/jstests/sharding/move_chunk_insert_with_write_retryability.js index d0cbd8adc1d..0f755de41c4 100644 --- a/jstests/sharding/move_chunk_insert_with_write_retryability.js +++ b/jstests/sharding/move_chunk_insert_with_write_retryability.js @@ -10,7 +10,15 @@ load("jstests/sharding/move_chunk_with_session_helper.js"); return; } - var st = new ShardingTest({shards: {rs0: {nodes: 2}, rs1: {nodes: 2}}}); + // Prevent unnecessary elections in the first shard replica set. Shard 'rs1' shard will need its + // secondary to get elected, so we don't give it a zero priority. + var st = new ShardingTest({ + mongos: 2, + shards: { + rs0: {nodes: [{rsConfig: {}}, {rsConfig: {priority: 0}}]}, + rs1: {nodes: [{rsConfig: {}}, {rsConfig: {}}]} + } + }); assert.commandWorked(st.s.adminCommand({enableSharding: 'test'})); st.ensurePrimaryShard('test', st.shard0.shardName); diff --git a/jstests/sharding/move_chunk_remove_with_write_retryability.js b/jstests/sharding/move_chunk_remove_with_write_retryability.js index d47b44b5ca4..78c20ceddc6 100644 --- a/jstests/sharding/move_chunk_remove_with_write_retryability.js +++ b/jstests/sharding/move_chunk_remove_with_write_retryability.js @@ -10,7 +10,15 @@ load("jstests/sharding/move_chunk_with_session_helper.js"); return; } - var st = new ShardingTest({shards: {rs0: {nodes: 2}, rs1: {nodes: 2}}}); + // Prevent unnecessary elections in the first shard replica set. Shard 'rs1' shard will need its + // secondary to get elected, so we don't give it a zero priority. + var st = new ShardingTest({ + mongos: 2, + shards: { + rs0: {nodes: [{rsConfig: {}}, {rsConfig: {priority: 0}}]}, + rs1: {nodes: [{rsConfig: {}}, {rsConfig: {}}]} + } + }); assert.commandWorked(st.s.adminCommand({enableSharding: 'test'})); st.ensurePrimaryShard('test', st.shard0.shardName); diff --git a/jstests/sharding/move_chunk_update_with_write_retryability.js b/jstests/sharding/move_chunk_update_with_write_retryability.js index 779619a1fa8..03748a56c20 100644 --- a/jstests/sharding/move_chunk_update_with_write_retryability.js +++ b/jstests/sharding/move_chunk_update_with_write_retryability.js @@ -10,7 +10,15 @@ load("jstests/sharding/move_chunk_with_session_helper.js"); return; } - var st = new ShardingTest({shards: {rs0: {nodes: 2}, rs1: {nodes: 2}}}); + // Prevent unnecessary elections in the first shard replica set. Shard 'rs1' shard will need its + // secondary to get elected, so we don't give it a zero priority. + var st = new ShardingTest({ + mongos: 2, + shards: { + rs0: {nodes: [{rsConfig: {}}, {rsConfig: {priority: 0}}]}, + rs1: {nodes: [{rsConfig: {}}, {rsConfig: {}}]} + } + }); assert.commandWorked(st.s.adminCommand({enableSharding: 'test'})); st.ensurePrimaryShard('test', st.shard0.shardName);