summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/libs
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2021-01-04 16:58:56 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-04 21:13:33 +0000
commitf012be046c8a16fe80ca3c08ee19a48931feb696 (patch)
tree1e6c21c1639ff0cdc5e774d9f595dff7631b9334 /jstests/noPassthrough/libs
parent9537e7f9bd14ec7e097077b5a31e7a7db674114b (diff)
downloadmongo-f012be046c8a16fe80ca3c08ee19a48931feb696.tar.gz
SERVER-53559 Stop the background workload in the backup/restore test before adding the node from the backed up data to the replica set
Diffstat (limited to 'jstests/noPassthrough/libs')
-rw-r--r--jstests/noPassthrough/libs/backup_restore.js47
1 files changed, 23 insertions, 24 deletions
diff --git a/jstests/noPassthrough/libs/backup_restore.js b/jstests/noPassthrough/libs/backup_restore.js
index 5bc83d693d5..2084fc8237d 100644
--- a/jstests/noPassthrough/libs/backup_restore.js
+++ b/jstests/noPassthrough/libs/backup_restore.js
@@ -289,30 +289,6 @@ var BackupRestoreTest = function(options) {
// Wait up to 5 minutes until restarted node is in state secondary.
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 nodesBeforeAddingHiddenMember = rst.nodes.slice();
- // ReplSetTest.add() will use default values for --oplogSize and --replSet consistent with
- // existing nodes.
- var hiddenCfg = {noCleanData: true, dbpath: hiddenDbpath};
- var hiddenNode = rst.add(hiddenCfg);
- var hiddenHost = hiddenNode.host;
-
- // 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};
- rsConfig.members.push(hiddenMember);
- assert.commandWorked(primary.adminCommand({replSetReconfig: rsConfig}),
- testName + ' failed to reconfigure replSet ' + tojson(rsConfig));
-
- // Wait up to 5 minutes until the new hidden node is in state RECOVERING.
- rst.waitForState(hiddenNode, [ReplSetTest.State.RECOVERING, ReplSetTest.State.SECONDARY]);
-
jsTestLog('Stopping CRUD and FSM clients');
// Stop CRUD client and FSM client.
@@ -354,6 +330,29 @@ var BackupRestoreTest = function(options) {
{'a': 1}, {writeConcern: {w: 'majority'}}));
});
+ // Add the new hidden node to replSetTest.
+ jsTestLog('Starting new hidden node (but do not add to replica set) with dbpath ' +
+ hiddenDbpath + '.');
+ var nodesBeforeAddingHiddenMember = rst.nodes.slice();
+ // ReplSetTest.add() will use default values for --oplogSize and --replSet consistent with
+ // existing nodes.
+ var hiddenCfg = {noCleanData: true, dbpath: hiddenDbpath};
+ var hiddenNode = rst.add(hiddenCfg);
+ var hiddenHost = hiddenNode.host;
+
+ // Add the new hidden secondary to the replica set. This triggers an election, so it must be
+ // done after stopping the background workloads to prevent the workloads from failing if a
+ // new primary is elected.
+ 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};
+ rsConfig.members.push(hiddenMember);
+ assert.commandWorked(primary.adminCommand({replSetReconfig: rsConfig}),
+ testName + ' failed to reconfigure replSet ' + tojson(rsConfig));
+
// Wait up to 5 minutes until the new hidden node is in state SECONDARY.
jsTestLog('CRUD and FSM clients stopped. Waiting for hidden node ' + hiddenHost +
' to become SECONDARY');