summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2017-01-25 12:19:41 -0500
committerBenety Goh <benety@mongodb.com>2017-01-25 15:20:44 -0500
commit15011acb7283e4c97779a986f45f632d4057fbd9 (patch)
treea6d3c9431099dbff1998adf3df3a7bdeb35e90eb
parent8253fab192fad307a07846878e368e970990d7b3 (diff)
downloadmongo-15011acb7283e4c97779a986f45f632d4057fbd9.tar.gz
SERVER-27808 backup_restore.js waits secondary nodes to agree on primary before adding hidden node to replica set configr3.5.2
-rw-r--r--jstests/noPassthrough/libs/backup_restore.js18
-rw-r--r--src/mongo/shell/replsettest.js8
2 files changed, 15 insertions, 11 deletions
diff --git a/jstests/noPassthrough/libs/backup_restore.js b/jstests/noPassthrough/libs/backup_restore.js
index 645d5cba362..73ee3e64cc4 100644
--- a/jstests/noPassthrough/libs/backup_restore.js
+++ b/jstests/noPassthrough/libs/backup_restore.js
@@ -260,10 +260,13 @@ var BackupRestoreTest = function(options) {
rst.waitForState(rst.getSecondaries(), ReplSetTest.State.SECONDARY);
// Add new hidden node to replSetTest
+ jsTestLog('Starting new hidden node (but do not add to replica set) with dbpath ' +
+ hiddenDbpath + '.');
var hiddenCfg =
{noCleanData: true, oplogSize: 1024, dbpath: hiddenDbpath, replSet: replSetName};
- rst.add(hiddenCfg);
- var hiddenHost = rst.nodes[numNodes].host;
+ var nodesBeforeAddingHiddenMember = rst.nodes.slice();
+ var hiddenNode = rst.add(hiddenCfg);
+ var hiddenHost = hiddenNode.host;
// Verify if dbHash is the same on hidden secondary for crudDb
// Note the dbhash can only run when the DB is inactive to get a result
@@ -273,8 +276,7 @@ var BackupRestoreTest = function(options) {
try {
// Need to hammer this since the node can disconnect connections as it is
// starting up into REMOVED replication state.
- return (dbHash ===
- rst.nodes[numNodes].getDB(crudDb).runCommand({dbhash: 1}).md5);
+ return (dbHash === hiddenNode.getDB(crudDb).runCommand({dbhash: 1}).md5);
} catch (e) {
return false;
}
@@ -282,6 +284,9 @@ var BackupRestoreTest = function(options) {
}
// Add new hidden secondary to replica set
+ jsTestLog('Adding new hidden node ' + hiddenHost + ' to replica set.');
+ rst.awaitNodesAgreeOnPrimary(ReplSetTest.kDefaultTimeoutMS, nodesBeforeAddingHiddenMember);
+ primary = rst.getPrimary();
var rsConfig = primary.getDB("local").system.replset.findOne();
rsConfig.version += 1;
var hiddenMember = {_id: numNodes, host: hiddenHost, priority: 0, hidden: true};
@@ -290,8 +295,7 @@ var BackupRestoreTest = function(options) {
testName + ' failed to reconfigure replSet ' + tojson(rsConfig));
// Wait up to 5 minutes until the new hidden node is in state RECOVERING.
- rst.waitForState(rst.nodes[numNodes],
- [ReplSetTest.State.RECOVERING, ReplSetTest.State.SECONDARY]);
+ rst.waitForState(hiddenNode, [ReplSetTest.State.RECOVERING, ReplSetTest.State.SECONDARY]);
// Stop CRUD client and FSM client.
assert(checkProgram(crudPid), testName + ' CRUD client was not running at end of test');
@@ -300,7 +304,7 @@ var BackupRestoreTest = function(options) {
stopMongoProgramByPid(fsmPid);
// Wait up to 5 minutes until the new hidden node is in state SECONDARY.
- rst.waitForState(rst.nodes[numNodes], ReplSetTest.State.SECONDARY);
+ rst.waitForState(hiddenNode, ReplSetTest.State.SECONDARY);
// Wait for secondaries to finish catching up before shutting down.
primary = rst.getPrimary();
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 0be088cdc42..81ccdcd45d0 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -539,15 +539,15 @@ var ReplSetTest = function(opts) {
/**
* Blocks until all nodes agree on who the primary is.
*/
- this.awaitNodesAgreeOnPrimary = function(timeout) {
+ this.awaitNodesAgreeOnPrimary = function(timeout, nodes) {
timeout = timeout || self.kDefaultTimeoutMS;
+ nodes = nodes || self.nodes;
assert.soonNoExcept(function() {
var primary = -1;
- for (var i = 0; i < self.nodes.length; i++) {
- var replSetGetStatus =
- self.nodes[i].getDB("admin").runCommand({replSetGetStatus: 1});
+ for (var i = 0; i < nodes.length; i++) {
+ var replSetGetStatus = nodes[i].getDB("admin").runCommand({replSetGetStatus: 1});
var nodesPrimary = -1;
for (var j = 0; j < replSetGetStatus.members.length; j++) {
if (replSetGetStatus.members[j].state === ReplSetTest.State.PRIMARY) {