Skip to content

Commit

Permalink
SERVER-16635 Make sharding/mongos_no_replica_set_refresh.js agnostic …
Browse files Browse the repository at this point in the history
…to who is elected primary (take 2)
  • Loading branch information
stbrody committed Dec 24, 2014
1 parent 9d5ec8f commit b001445
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions jstests/sharding/mongos_no_replica_set_refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b001445

Please sign in to comment.