Permalink
Browse files

Merge branch 'master' of github.com:mongodb/mongo

  • Loading branch information...
erh committed Jul 30, 2010
2 parents 67f4da9 + 2c9fbfb commit 24d9585f9fc0b9056a0545ff961d998eccdcf57c
Showing with 58 additions and 1 deletion.
  1. +45 −0 jstests/replsets/replsetarb2.js
  2. +5 −1 jstests/replsets/sync1.js
  3. +8 −0 shell/servers.js
@@ -0,0 +1,45 @@
+// Election when master fails and remaining nodes are an arbiter and a slave.
+// Note that in this scenario, the arbiter needs two votes.
+
+doTest = function( signal ) {
+
+ var replTest = new ReplSetTest( {name: 'unicomplex', nodes: 3} );
+ var nodes = replTest.nodeList();
+
+ print(tojson(nodes));
+
+ var conns = replTest.startSet();
+ var r = replTest.initiate({"_id" : "unicomplex",
+ "members" : [
+ {"_id" : 0, "host" : nodes[0] },
+ {"_id" : 1, "host" : nodes[1], "arbiterOnly" : true, "votes": 2},
+ {"_id" : 2, "host" : nodes[2] }]});
+
+ // Make sure we have a master
+ var master = replTest.getMaster();
+
+ // Make sure we have an arbiter
+ assert.soon(function() {
+ res = conns[1].getDB("admin").runCommand({replSetGetStatus: 1});
+ printjson(res);
+ return res.myState == 7;
+ }, "Aribiter failed to initialize.");
+
+ // Wait for initial replication
+ master.getDB("foo").foo.insert({a: "foo"});
+ replTest.awaitReplication();
+
+ // Now kill the original master
+ mId = replTest.getNodeId( master );
+ replTest.stop( mId );
+
+ // And make sure that the slave is promoted
+ new_master = replTest.getMaster();
+
+ newMasterId = replTest.getNodeId( new_master );
+ assert( newMasterId == 2, "Slave wasn't promoted to new master");
+
+ replTest.stopSet( signal );
+}
+
+doTest( 15 );
@@ -83,7 +83,11 @@ doTest = function( signal ) {
var max = max1.z;
// now, let's see if rollback works
- var result = dbs[0].runCommand({replSetTest : 1, blind : false});
+ var result = dbs[0].getSisterDB("admin").runCommand({replSetTest : 1, blind : false});
+ dbs[0].getMongo().setSlaveOk();
+
+ printjson(result);
+ sleep(5000);
// FAIL! This never resyncs
// now this should resync
View
@@ -1146,6 +1146,14 @@ ReplSetTest.prototype.awaitReplication = function() {
var synced = true;
for(var i=0; i<this.liveNodes.slaves.length; i++) {
var slave = this.liveNodes.slaves[i];
+
+ // Continue if we're connected to an arbiter
+ if(res = slave.getDB("admin").runCommand({replSetGetStatus: 1})) {
+ if(res.myState == 7) {
+ continue;
+ }
+ }
+
slave.getDB("admin").getMongo().setSlaveOk();
var log = slave.getDB("local")['replset.minvalid'];
if(log.find().hasNext()) {

0 comments on commit 24d9585

Please sign in to comment.