diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2013-10-24 13:07:40 -0400 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2013-12-04 14:35:59 -0500 |
commit | ec353f534593770eeb9c93fd965d591c73d4b11a (patch) | |
tree | 5dfe3752c7ab728cede9bf323d29e86498b2dbe7 /src/mongo/shell/replsettest.js | |
parent | 57a4f1697eebfeac1294dd740a1e3e3c4356d74a (diff) | |
download | mongo-ec353f534593770eeb9c93fd965d591c73d4b11a.tar.gz |
SERVER-11280 fix detecting downed replica nodes to check against a copy of the member with up to date lastHeartbeatRecv
also pass node id as well as node name in the heartbeat
Diffstat (limited to 'src/mongo/shell/replsettest.js')
-rw-r--r-- | src/mongo/shell/replsettest.js | 100 |
1 files changed, 52 insertions, 48 deletions
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index dd13d4111a1..05f1d3f73b5 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -36,8 +36,6 @@ * oplogSize {number}: Default: 40 * useSeedList {boolean}: Use the connection string format of this set * as the replica set name (overrides the name property). Default: false - * bridged {boolean}: Whether to set a mongobridge between replicas. - * Default: false * keyFile {string} * shardSvr {boolean}: Default: false * startPort {number}: port offset to be used for each replica. Default: 31000 @@ -54,7 +52,6 @@ ReplSetTest = function( opts ){ this.numNodes = opts.nodes || 0; this.oplogSize = opts.oplogSize || 40; this.useSeedList = opts.useSeedList || false; - this.bridged = opts.bridged || false; this.ports = []; this.keyFile = opts.keyFile this.shardSvr = opts.shardSvr || false; @@ -82,21 +79,7 @@ ReplSetTest = function( opts ){ this.nodeOptions[ "n" + i ] = opts.nodeOptions; } - if(this.bridged) { - this.bridgePorts = []; - - var allPorts = allocatePorts( this.numNodes * 2 , this.startPort ); - for(var i=0; i < this.numNodes; i++) { - this.ports[i] = allPorts[i*2]; - this.bridgePorts[i] = allPorts[i*2 + 1]; - } - - this.initBridges(); - } - else { - this.ports = allocatePorts( this.numNodes , this.startPort ); - } - + this.ports = allocatePorts( this.numNodes , this.startPort ); this.nodes = [] this.initLiveNodes() @@ -105,12 +88,6 @@ ReplSetTest = function( opts ){ } -ReplSetTest.prototype.initBridges = function() { - for(var i=0; i<this.ports.length; i++) { - startMongoProgram( "mongobridge", "--port", this.bridgePorts[i], "--dest", this.host + ":" + this.ports[i] ); - } -} - // List of nodes as host:port strings. ReplSetTest.prototype.nodeList = function() { var list = []; @@ -177,10 +154,7 @@ ReplSetTest.prototype.getReplSetConfig = function() { member = {}; member['_id'] = i; - if(this.bridged) - var port = this.bridgePorts[i]; - else - var port = this.ports[i]; + var port = this.ports[i]; member['host'] = this.host + ":" + port; if( this.nodeOptions[ "n" + i ] && this.nodeOptions[ "n" + i ].arbiter ) @@ -197,19 +171,9 @@ ReplSetTest.prototype.getURL = function(){ for(i=0; i<this.ports.length; i++) { - // Don't include this node in the replica set list - if(this.bridged && this.ports[i] == this.ports[n]) { - continue; - } - var port; // Connect on the right port - if(this.bridged) { - port = this.bridgePorts[i]; - } - else { - port = this.ports[i]; - } + port = this.ports[i]; var str = this.host + ":" + port; hosts.push(str); @@ -540,6 +504,16 @@ ReplSetTest.prototype.awaitReplication = function(timeout) { for (var i=0; i < self.liveNodes.slaves.length; i++) { var slave = self.liveNodes.slaves[i]; + var slaveConfigVersion = + slave.getDB("local")['system.replset'].findOne().version; + + if (configVersion != slaveConfigVersion) { + print("ReplSetTest awaitReplication: secondary #" + secondaryCount + + ", " + name + ", has config version #" + slaveConfigVersion + + ", but expected config version #" + configVersion); + return false; + } + // Continue if we're connected to an arbiter if (res = slave.getDB("admin").runCommand({replSetGetStatus: 1})) { if (res.myState == 7) { @@ -586,15 +560,6 @@ ReplSetTest.prototype.awaitReplication = function(timeout) { secondaryCount + ", " + name + ", to have an oplog built"); return false; } - - var slaveConfigVersion = slave.getDB("local")['system.replset'].findOne().version; - - if (configVersion != slaveConfigVersion) { - print("ReplSetTest awaitReplication: secondary #" + secondaryCount + - ", " + name + ", has config version #" + slaveConfigVersion + - ", but expected config version #" + configVersion); - return false; - } } print("ReplSetTest awaitReplication: finished: all " + secondaryCount + @@ -1080,6 +1045,9 @@ ReplSetTest.prototype.bridge = function( opts ) { for (var i=0; i<n; i++) { this.restart(i); } + this.reconfig = function() { + throw notImplemented; + } return this.getMaster(); }; @@ -1120,3 +1088,39 @@ ReplSetTest.prototype.unPartition = function(from, to, bidirectional) { this.bridges[to][from].start(); } }; + +/** + * Helpers for partitioning in only one direction so that the test files are more clear to readers. + */ +ReplSetTest.prototype.partitionOneWay = function(from, to) { + this.partition(from, to, false); +}; + +ReplSetTest.prototype.unPartitionOneWay = function(from, to) { + this.unPartition(from, to, false); +}; + +/** + * Helpers for adding/removing delays from a partition. + */ +ReplSetTest.prototype.addPartitionDelay = function(from, to, delay, bidirectional) { + bidirectional = typeof bidirectional !== 'undefined' ? bidirectional : true; + + this.bridges[from][to].setDelay(delay); + + if (bidirectional) { + this.bridges[to][from].setDelay(delay); + } +}; + +ReplSetTest.prototype.removePartitionDelay = function(from, to, bidirectional) { + this.addPartitionDelay(from, to, 0, bidirectional); +}; + +ReplSetTest.prototype.addOneWayPartitionDelay = function(from, to, delay) { + this.addPartitionDelay(from, to, delay, false); +}; + +ReplSetTest.prototype.removeOneWayPartitionDelay = function(from, to) { + this.addPartitionDelay(from, to, 0, false); +}; |