summaryrefslogtreecommitdiff
path: root/jstests/replsets
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2013-07-22 16:33:35 -0400
committerScott Hernandez <scotthernandez@gmail.com>2013-07-22 16:33:35 -0400
commit3cf081b971bc0bc8efccf1b9591e95ec71a42d7c (patch)
tree54f1558c50a0d4eb44ca8461f6a66b421d2d5e10 /jstests/replsets
parent0ba6f77490f2814ed0772e52385e2a124f05f7a9 (diff)
downloadmongo-3cf081b971bc0bc8efccf1b9591e95ec71a42d7c.tar.gz
SERVER-8748: only consider electable members during stepdown
Diffstat (limited to 'jstests/replsets')
-rw-r--r--jstests/replsets/stepdown_wrt_electable.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/jstests/replsets/stepdown_wrt_electable.js b/jstests/replsets/stepdown_wrt_electable.js
new file mode 100644
index 00000000000..e47b6ab09c6
--- /dev/null
+++ b/jstests/replsets/stepdown_wrt_electable.js
@@ -0,0 +1,37 @@
+// Test that replSetStepDown filters out non-electable nodes
+var replTest = new ReplSetTest({ name: 'testSet', nodes: 2 });
+var nodes = replTest.startSet();
+
+
+// setup config
+var c = replTest.getReplSetConfig();
+c.members[1].priority = 0; // not electable
+replTest.initiate(c);
+
+var master = replTest.getMaster();
+var testDB = master.getDB('test');
+var firstPrimary = testDB.isMaster().primary
+
+// do a write to allow stepping down of the primary;
+// otherwise, the primary will refuse to step down
+testDB.foo.insert({x:1});
+replTest.awaitReplication();
+
+// stepdown should fail since there is no-one to elect within 10 secs
+testDB.adminCommand({replSetStepDown:5});
+assert(new Mongo(firstPrimary).getDB("a").isMaster().ismaster, "not master")
+
+// step down the primary asyncronously so it doesn't kill this test
+var command = "tojson(db.adminCommand({replSetStepDown:1000, force:true}));"
+// set db so startParallelShell works
+db = testDB;
+var waitfunc = startParallelShell(command);
+sleep(100) // startParallelShell doesn't block
+
+// check that the old primary is no longer master
+var isMaster = new Mongo(firstPrimary).getDB("a").isMaster();
+printjson(isMaster);
+assert(!(isMaster.ismaster), "is master")
+
+// stop
+replTest.stopSet();