summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2017-03-26 05:57:46 -0400
committerBenety Goh <benety@mongodb.com>2017-04-01 05:57:50 -0400
commitae657f64a63699a14df6b6e6950818393de75b3a (patch)
tree97345280e8ac261100ce990d2901927129acc2e4 /src/mongo
parentcf1d5cf8a9db86729371a3d1b69ee1b79642ce52 (diff)
downloadmongo-ae657f64a63699a14df6b6e6950818393de75b3a.tar.gz
SERVER-28376 ReplSetTest.stepUp() calls awaitReplication() before sending replSetStepUp command
(cherry picked from commit f1fb0600a328f0792fa84bea78e368831e4af669) This backport also includes some changes to JS tests and replsettest.js from commit cdc7af4c6d453b8c1ce2319d0cd3b50074609d87.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/shell/replsettest.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index aaf866362fc..d9919c91341 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -136,6 +136,14 @@ var ReplSetTest = function(opts) {
return self.liveNodes.master || false;
}
+ function asCluster(conn, fn) {
+ if (self.keyFile) {
+ return authutil.asCluster(conn, self.keyFile, fn);
+ } else {
+ return fn();
+ }
+ }
+
/**
* Returns 'true' if the test has been configured to run without journaling enabled.
*/
@@ -458,6 +466,10 @@ var ReplSetTest = function(opts) {
this.startSet = function(options) {
print("ReplSetTest starting set");
+ if (options && options.keyFile) {
+ self.keyFile = options.keyFile;
+ }
+
var nodes = [];
for (var n = 0; n < this.ports.length; n++) {
nodes.push(this.start(n, options));
@@ -765,7 +777,12 @@ var ReplSetTest = function(opts) {
*/
this.initiateWithNodeZeroAsPrimary = function(cfg, initCmd) {
this.initiateWithAnyNodeAsPrimary(cfg, initCmd);
- this.stepUp(this.nodes[0]);
+
+ // stepUp() calls awaitReplication() which requires all nodes to be authorized to run
+ // replSetGetStatus.
+ asCluster(this.nodes, function() {
+ self.stepUp(self.nodes[0]);
+ });
};
/**
@@ -784,6 +801,7 @@ var ReplSetTest = function(opts) {
*/
this.stepUp = function(node) {
this.awaitSecondaryNodes();
+ this.awaitReplication();
this.awaitNodesAgreeOnPrimary();
if (this.getPrimary() === node) {
return;
@@ -804,6 +822,7 @@ var ReplSetTest = function(opts) {
print("Caught exception while stepping down node '" + tojson(node.host) +
"': " + tojson(ex));
}
+ this.awaitReplication();
this.awaitNodesAgreeOnPrimary();
}