From b0014456ddefaccf02016c1a89c514e865a099d6 Mon Sep 17 00:00:00 2001 From: Spencer T Brody Date: Tue, 23 Dec 2014 16:25:11 -0500 Subject: [PATCH] SERVER-16635 Make sharding/mongos_no_replica_set_refresh.js agnostic to who is elected primary (take 2) --- .../sharding/mongos_no_replica_set_refresh.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/jstests/sharding/mongos_no_replica_set_refresh.js b/jstests/sharding/mongos_no_replica_set_refresh.js index 99790909fb150..366e229803ef7 100644 --- a/jstests/sharding/mongos_no_replica_set_refresh.js +++ b/jstests/sharding/mongos_no_replica_set_refresh.js @@ -18,17 +18,21 @@ var rsObj = st._rs[0].test; var primary = rsObj.getPrimary(); var secondaries = rsObj.getSecondaries(); -var rsConfig = primary.getDB("local").system.replset.findOne(); - jsTestLog( "Reconfiguring replica set..." ); -var removedNode = rsConfig.members.pop(); +var rsConfig = primary.getDB("local").system.replset.findOne(); +// First, make sure the last node in the config is not the primary +rsConfig.members[0].priority = 10; rsConfig.version++; - -// Need to force in case the node being removed is the current primary -reconfig(rsObj, rsConfig, true); +reconfig(rsObj, rsConfig); +rsObj.waitForState(rsObj.nodes[0], rsObj.PRIMARY, 60* 1000); primary = rsObj.getPrimary(); +// Now remove the last node in the config. +var removedNode = rsConfig.members.pop(); +rsConfig.version++; +reconfig(rsObj, rsConfig); + var numRSHosts = function(){ var result = primary.getDB("admin").runCommand({ ismaster : 1 }); printjson( result ); @@ -62,7 +66,6 @@ jsTestLog( "Now test adding new replica set servers..." ); config.shards.update({ _id : rsObj.name }, { $set : { host : rsObj.name + "/" + primary.host } }); printjson( config.shards.find().toArray() ); -rsConfig = primary.getDB("local").system.replset.findOne(); rsConfig.members.push(removedNode); rsConfig.version++; reconfig(rsObj, rsConfig);