diff options
author | Eric Milkie <milkie@10gen.com> | 2014-02-03 11:48:16 -0500 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2014-03-21 06:17:18 -0400 |
commit | 67aadff82dc47bcfcba06aebc3b5a61eebf97658 (patch) | |
tree | 43d8c1a8be335f2693c01aa2767f7090d75336f7 | |
parent | b2c3b08b75892f25ca662d787b061070473d9ba5 (diff) | |
download | mongo-67aadff82dc47bcfcba06aebc3b5a61eebf97658.tar.gz |
improve replset_remove_node.js
(cherry picked from commit 38ba557b50281fa8e1680cbaf7681f06942f4130)
-rw-r--r-- | jstests/replsets/replset_remove_node.js | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/jstests/replsets/replset_remove_node.js b/jstests/replsets/replset_remove_node.js index bf99b1236fc..3294b226e27 100644 --- a/jstests/replsets/replset_remove_node.js +++ b/jstests/replsets/replset_remove_node.js @@ -1,9 +1,8 @@ -doTest = function( signal ) { +(function() { - // Make sure that we can manually shutdown a remove a - // slave from the configuration. + // Make sure that we can manually shutdown and remove a + // secondary from the configuration. - // Create a new replica set test. Specify set name and the number of nodes you want. var replTest = new ReplSetTest( {name: 'testSet', nodes: 3} ); // call startSet() to start each mongod in the replica set @@ -30,6 +29,10 @@ doTest = function( signal ) { // Shut down the unwanted node replTest.stop( slaveId ); + // Note: this will cause the PRIMARY to step down, which causes it to close all + // connections, including the one we're using from the shell to drive this test. + // The shell will attempt to reconnect once. + // Remove that node from the configuration replTest.remove( slaveId ); @@ -39,40 +42,44 @@ doTest = function( signal ) { var config = replTest.getReplSetConfig(); config.version = c.version + 1; config.members = [ { "_id" : 0, "host" : replTest.host + ":31000" }, - { "_id" : 2, "host" : replTest.host + ":31002" } ] + { "_id" : 2, "host" : replTest.host + ":31002" } ]; try { + // Note that this will cause the shell's connection to the primary to be disconnected again replTest.initiate( config , 'replSetReconfig' ); } catch(e) { print(e); } - // Make sure that a new master comes up master = replTest.getMaster(); slaves = replTest.liveNodes.slaves; + // Trigger a reconnect from the shell again, to be sure we're reconnected. + try { + master.getDB("local").system.replset.findOne(); + } + catch (e) { + print (e); + } + // Do a status check on each node // Master should be set to 1 (primary) assert.soon(function() { - stat = master.getDB("admin").runCommand({replSetGetStatus: 1}); + var stat = master.getDB("admin").runCommand({replSetGetStatus: 1}); printjson( stat ); return stat.myState == 1; }, "Master failed to come up as master.", 60000); // Slaves to be set to 2 (secondary) assert.soon(function() { - stat = slaves[0].getDB("admin").runCommand({replSetGetStatus: 1}); + var stat = slaves[0].getDB("admin").runCommand({replSetGetStatus: 1}); return stat.myState == 2; }, "Slave failed to come up as slave.", 60000); assert.soon(function() { - stat = slaves[0].getDB("admin").runCommand({replSetGetStatus: 1}); + var stat = slaves[0].getDB("admin").runCommand({replSetGetStatus: 1}); return stat.members.length == 2; }, "Wrong number of members", 60000); -}
-
-print("replset_remove_node.js");
-doTest(15);
-print("replset_remove_node SUCCESS");
+}()); |