From ece2e8f36cff8f996ae584708a9dab80b6419e63 Mon Sep 17 00:00:00 2001 From: Cheahuychou Mao Date: Fri, 13 Dec 2019 17:58:58 +0000 Subject: SERVER-45103 Sharded index commands shouldn't target primary shard if it doesn't own chunks --- jstests/sharding/create_idx_empty_primary.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'jstests/sharding/create_idx_empty_primary.js') diff --git a/jstests/sharding/create_idx_empty_primary.js b/jstests/sharding/create_idx_empty_primary.js index 86b81983a43..24dcca43700 100644 --- a/jstests/sharding/create_idx_empty_primary.js +++ b/jstests/sharding/create_idx_empty_primary.js @@ -1,5 +1,7 @@ /** - * Test to make sure that the createIndex command gets sent to all shards. + * Test to make sure that the createIndex command gets sent to all shards if the mongos + * version is last-stable, and to shards that own chunks only if the mongos version is + * latest. */ (function() { 'use strict'; @@ -20,14 +22,17 @@ assert.commandWorked(testDB.user.insert({_id: 0})); var res = testDB.user.ensureIndex({i: 1}); assert.commandWorked(res); +// TODO (SERVER-45017): Remove this check when v4.4 becomes last-stable. +const isLastStableMongos = (jsTestOptions().mongosBinVersion === "last-stable"); + var indexes = testDB.user.getIndexes(); -assert.eq(2, indexes.length); +assert.eq(isLastStableMongos ? 2 : 1, indexes.length); indexes = st.rs0.getPrimary().getDB('test').user.getIndexes(); assert.eq(2, indexes.length); indexes = st.rs1.getPrimary().getDB('test').user.getIndexes(); -assert.eq(2, indexes.length); +assert.eq(isLastStableMongos ? 2 : 1, indexes.length); st.stop(); })(); -- cgit v1.2.1