summaryrefslogtreecommitdiff
path: root/jstests/replsets/remove1.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/replsets/remove1.js')
-rw-r--r--jstests/replsets/remove1.js70
1 files changed, 34 insertions, 36 deletions
diff --git a/jstests/replsets/remove1.js b/jstests/replsets/remove1.js
index eab87207508..cde4974677a 100644
--- a/jstests/replsets/remove1.js
+++ b/jstests/replsets/remove1.js
@@ -13,14 +13,14 @@ var name = "removeNodes";
var host = getHostName();
print("Start set with two nodes");
-var replTest = new ReplSetTest( {name: name, nodes: 2} );
+var replTest = new ReplSetTest({name: name, nodes: 2});
var nodes = replTest.startSet();
replTest.initiate();
var master = replTest.getPrimary();
var secondary = replTest.getSecondary();
print("Initial sync");
-master.getDB("foo").bar.baz.insert({x:1});
+master.getDB("foo").bar.baz.insert({x: 1});
replTest.awaitReplication();
@@ -34,53 +34,53 @@ for (var i = 0; i < config.members.length; i++) {
}
config.version = 2;
-assert.eq(secondary.getDB("admin").runCommand({ping:1}).ok,
+assert.eq(secondary.getDB("admin").runCommand({ping: 1}).ok,
1,
"we should be connected to the secondary");
try {
- master.getDB("admin").runCommand({replSetReconfig:config});
-}
-catch(e) {
+ master.getDB("admin").runCommand({replSetReconfig: config});
+} catch (e) {
print(e);
}
// This tests that the secondary disconnects us when it picks up the new config.
-assert.soon(
- function() {
- try {
- secondary.getDB("admin").runCommand({ping:1});
- } catch (e) {
- return true;
- }
- return false;
+assert.soon(function() {
+ try {
+ secondary.getDB("admin").runCommand({ping: 1});
+ } catch (e) {
+ return true;
}
-);
+ return false;
+});
// Now we should successfully reconnect to the secondary.
-assert.eq(secondary.getDB("admin").runCommand({ping:1}).ok, 1,
+assert.eq(secondary.getDB("admin").runCommand({ping: 1}).ok,
+ 1,
"we aren't connected to the secondary");
reconnect(master);
assert.soon(function() {
- var c = master.getDB("local").system.replset.findOne();
- return c.version == 2;
+ var c = master.getDB("local").system.replset.findOne();
+ return c.version == 2;
});
print("Add it back as a secondary");
-config.members.push({_id:2, host : secondary.host});
+config.members.push({_id: 2, host: secondary.host});
config.version = 3;
// Need to keep retrying reconfig here, as it will not work at first due to the primary's
// perception that the secondary is still "down".
-assert.soon(function() { try {
- reconfig(replTest, config);
- return true;
-} catch (e) {
- return false;
-} });
+assert.soon(function() {
+ try {
+ reconfig(replTest, config);
+ return true;
+ } catch (e) {
+ return false;
+ }
+});
master = replTest.getPrimary();
-printjson(master.getDB("admin").runCommand({replSetGetStatus:1}));
+printjson(master.getDB("admin").runCommand({replSetGetStatus: 1}));
var newConfig = master.getDB("local").system.replset.findOne();
print("newConfig: " + tojson(newConfig));
assert.eq(newConfig.version, 3);
@@ -90,26 +90,24 @@ replTest.stop(secondary);
assert.soon(function() {
try {
- return master.getDB("admin").runCommand({isMaster : 1}).secondary;
- }
- catch(e) {
- print("trying to get master: "+e);
+ return master.getDB("admin").runCommand({isMaster: 1}).secondary;
+ } catch (e) {
+ print("trying to get master: " + e);
}
-},"waiting for primary to step down",(60*1000),1000);
+}, "waiting for primary to step down", (60 * 1000), 1000);
config.version = 4;
config.members.pop();
try {
- master.getDB("admin").runCommand({replSetReconfig : config, force : true});
-}
-catch(e) {
+ master.getDB("admin").runCommand({replSetReconfig: config, force: true});
+} catch (e) {
print(e);
}
reconnect(master);
assert.soon(function() {
- return master.getDB("admin").runCommand({isMaster : 1}).ismaster;
-},"waiting for old primary to accept reconfig and step up",(60*1000),1000);
+ return master.getDB("admin").runCommand({isMaster: 1}).ismaster;
+}, "waiting for old primary to accept reconfig and step up", (60 * 1000), 1000);
config = master.getDB("local").system.replset.findOne();
printjson(config);