2015-11-06 13:40:59 -05:00
|
|
|
var replTest = new ReplSetTest({name: 'sync2', nodes: 5, useBridge: true});
|
2014-05-05 09:33:06 -04:00
|
|
|
var nodes = replTest.nodeList();
|
2014-08-25 06:24:43 -04:00
|
|
|
var conns = replTest.startSet({oplogSize: "2"});
|
2014-05-05 09:33:06 -04:00
|
|
|
replTest.initiate({"_id": "sync2",
|
|
|
|
|
"members": [
|
|
|
|
|
{"_id": 0, host: nodes[0], priority: 2},
|
|
|
|
|
{"_id": 1, host: nodes[1]},
|
|
|
|
|
{"_id": 2, host: nodes[2]},
|
|
|
|
|
{"_id": 3, host: nodes[3]},
|
|
|
|
|
{"_id": 4, host: nodes[4]}]
|
|
|
|
|
});
|
2011-05-10 19:14:41 -04:00
|
|
|
|
2015-11-25 11:20:43 -05:00
|
|
|
var master = replTest.getPrimary();
|
2014-05-05 09:33:06 -04:00
|
|
|
jsTestLog("Replica set test initialized");
|
|
|
|
|
|
2011-05-10 19:14:41 -04:00
|
|
|
// initial sync
|
2011-05-12 13:18:16 -04:00
|
|
|
master.getDB("foo").bar.insert({x:1});
|
2011-05-10 19:14:41 -04:00
|
|
|
replTest.awaitReplication();
|
|
|
|
|
|
2015-11-06 13:40:59 -05:00
|
|
|
conns[0].disconnect(conns[4]);
|
|
|
|
|
conns[1].disconnect(conns[2]);
|
|
|
|
|
conns[2].disconnect(conns[3]);
|
|
|
|
|
conns[3].disconnect(conns[1]);
|
2011-05-10 19:14:41 -04:00
|
|
|
|
|
|
|
|
// 4 is connected to 2
|
2015-11-06 13:40:59 -05:00
|
|
|
conns[4].disconnect(conns[1]);
|
|
|
|
|
conns[4].disconnect(conns[3]);
|
2011-05-10 19:14:41 -04:00
|
|
|
|
2014-08-25 06:24:43 -04:00
|
|
|
assert.soon(function() {
|
2015-11-25 11:20:43 -05:00
|
|
|
master = replTest.getPrimary();
|
2014-08-25 06:24:43 -04:00
|
|
|
return master === conns[0];
|
|
|
|
|
}, 60 * 1000, "node 0 did not become primary quickly enough");
|
|
|
|
|
|
2015-05-22 10:17:26 -04:00
|
|
|
replTest.awaitReplication();
|
2013-01-22 18:52:52 -05:00
|
|
|
jsTestLog("Checking that ops still replicate correctly");
|
2014-08-01 11:31:32 -04:00
|
|
|
var option = { writeConcern: { w: 5, wtimeout: 30000 }};
|
2015-12-01 12:07:25 -05:00
|
|
|
// In PV0, this write can fail as a result of a bad spanning tree. If 2 was syncing from 4 prior to
|
|
|
|
|
// bridging, it will not change sync sources and receive the write in time. This was not a problem
|
|
|
|
|
// in 3.0 because the old version of mongobridge caused all the nodes to restart during
|
|
|
|
|
// partitioning, forcing the set to rebuild the spanning tree.
|
2014-03-03 11:27:18 -05:00
|
|
|
assert.writeOK(master.getDB("foo").bar.insert({ x: 1 }, option));
|
2011-05-10 19:14:41 -04:00
|
|
|
|
|
|
|
|
// 4 is connected to 3
|
2015-11-06 13:40:59 -05:00
|
|
|
conns[4].disconnect(conns[2]);
|
|
|
|
|
conns[4].reconnect(conns[3]);
|
2011-05-10 19:14:41 -04:00
|
|
|
|
2014-08-01 11:31:32 -04:00
|
|
|
option = { writeConcern: { w: 5, wtimeout: 30000 }};
|
2014-03-03 11:27:18 -05:00
|
|
|
assert.writeOK(master.getDB("foo").bar.insert({ x: 1 }, option));
|
2011-05-10 19:14:41 -04:00
|
|
|
|
2013-07-15 14:30:17 -04:00
|
|
|
replTest.stopSet();
|