summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Schultz <william.schultz@mongodb.com>2020-05-12 15:52:51 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-12 20:05:36 +0000
commit1c9a43aa1e3801f09b2323d9290b60a37056269e (patch)
tree047b5695be897654aa1d1241a4b256264bf668a3
parentbc2892576ac1893706bdd170daa8a02842bb355f (diff)
downloadmongo-1c9a43aa1e3801f09b2323d9290b60a37056269e.tar.gz
SERVER-47691 Remove reliance on external dependencies in ReplSetTest
(cherry picked from commit be4fd3cca7fc4ea6883ceb1e262b0ac5cc7ecf69)
-rw-r--r--jstests/multiVersion/add_config_term_on_replset_upgrade.js1
-rw-r--r--jstests/multiVersion/agg_with_comment_during_upgrade.js1
-rw-r--r--jstests/multiVersion/hiddenIndexes.js1
-rw-r--r--jstests/multiVersion/map_reduce_multiversion_cluster.js1
-rw-r--r--jstests/multiVersion/remove_config_term_on_replset_downgrade.js1
-rw-r--r--jstests/multiVersion/upgrade_downgrade_cluster.js1
-rw-r--r--jstests/multiVersion/upgrade_replset_creates_initialsyncid.js1
-rw-r--r--jstests/noPassthrough/read_write_concern_defaults_startup.js1
-rw-r--r--jstests/replsets/force_reconfig_skips_oplog_commitment.js1
-rw-r--r--src/mongo/shell/replsettest.js52
10 files changed, 48 insertions, 13 deletions
diff --git a/jstests/multiVersion/add_config_term_on_replset_upgrade.js b/jstests/multiVersion/add_config_term_on_replset_upgrade.js
index 6ea1cb4b498..3617d0ea096 100644
--- a/jstests/multiVersion/add_config_term_on_replset_upgrade.js
+++ b/jstests/multiVersion/add_config_term_on_replset_upgrade.js
@@ -8,6 +8,7 @@
load('jstests/multiVersion/libs/multi_rs.js');
load('jstests/libs/test_background_ops.js');
+load("jstests/replsets/rslib.js");
const newVersion = "latest";
const oldVersion = "last-stable";
diff --git a/jstests/multiVersion/agg_with_comment_during_upgrade.js b/jstests/multiVersion/agg_with_comment_during_upgrade.js
index 40bab2597f3..3accd349dfb 100644
--- a/jstests/multiVersion/agg_with_comment_during_upgrade.js
+++ b/jstests/multiVersion/agg_with_comment_during_upgrade.js
@@ -17,6 +17,7 @@ TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
load("jstests/multiVersion/libs/multi_cluster.js"); // For upgradeCluster().
load("jstests/multiVersion/libs/multi_rs.js"); // For upgradeSet().
+load("jstests/replsets/rslib.js");
// Start with a last-stable cluster with two shards.
const st = new ShardingTest({
diff --git a/jstests/multiVersion/hiddenIndexes.js b/jstests/multiVersion/hiddenIndexes.js
index c31e08e35ad..d1683fe371c 100644
--- a/jstests/multiVersion/hiddenIndexes.js
+++ b/jstests/multiVersion/hiddenIndexes.js
@@ -13,6 +13,7 @@
load("jstests/libs/analyze_plan.js"); // For assertStagesForExplainOfCommand.
load("jstests/multiVersion/libs/multi_cluster.js"); // For upgradeCluster.
+load("jstests/replsets/rslib.js");
TestData.skipCheckDBHashes = true; // Skip db hashes when restarting the replset.
diff --git a/jstests/multiVersion/map_reduce_multiversion_cluster.js b/jstests/multiVersion/map_reduce_multiversion_cluster.js
index e949fce813a..4526c4d7c8f 100644
--- a/jstests/multiVersion/map_reduce_multiversion_cluster.js
+++ b/jstests/multiVersion/map_reduce_multiversion_cluster.js
@@ -9,6 +9,7 @@ TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
"use strict";
load("jstests/multiVersion/libs/multi_cluster.js"); // For upgradeCluster.
+load("jstests/replsets/rslib.js");
const testName = "map_reduce_multiversion_cluster";
const dbName = "test_" + testName;
diff --git a/jstests/multiVersion/remove_config_term_on_replset_downgrade.js b/jstests/multiVersion/remove_config_term_on_replset_downgrade.js
index bf39a50fb88..35425be873a 100644
--- a/jstests/multiVersion/remove_config_term_on_replset_downgrade.js
+++ b/jstests/multiVersion/remove_config_term_on_replset_downgrade.js
@@ -8,6 +8,7 @@
load('jstests/multiVersion/libs/multi_rs.js');
load('jstests/libs/test_background_ops.js');
+load("jstests/replsets/rslib.js");
const newVersion = "latest";
const oldVersion = "last-stable";
diff --git a/jstests/multiVersion/upgrade_downgrade_cluster.js b/jstests/multiVersion/upgrade_downgrade_cluster.js
index f699d3df981..997576fe3b0 100644
--- a/jstests/multiVersion/upgrade_downgrade_cluster.js
+++ b/jstests/multiVersion/upgrade_downgrade_cluster.js
@@ -7,6 +7,7 @@
load('./jstests/multiVersion/libs/multi_rs.js');
load('./jstests/multiVersion/libs/multi_cluster.js');
+load("jstests/replsets/rslib.js");
// When checking UUID consistency, the shell attempts to run a command on the node it believes is
// primary in each shard. However, this test restarts shards, and the node that is elected primary
diff --git a/jstests/multiVersion/upgrade_replset_creates_initialsyncid.js b/jstests/multiVersion/upgrade_replset_creates_initialsyncid.js
index b34e4ab4c13..0d6eafac2f6 100644
--- a/jstests/multiVersion/upgrade_replset_creates_initialsyncid.js
+++ b/jstests/multiVersion/upgrade_replset_creates_initialsyncid.js
@@ -6,6 +6,7 @@
"use strict";
load('jstests/multiVersion/libs/multi_rs.js');
+load("jstests/replsets/rslib.js");
const oldVersion = "last-stable";
diff --git a/jstests/noPassthrough/read_write_concern_defaults_startup.js b/jstests/noPassthrough/read_write_concern_defaults_startup.js
index bf64b93011f..8705cca6088 100644
--- a/jstests/noPassthrough/read_write_concern_defaults_startup.js
+++ b/jstests/noPassthrough/read_write_concern_defaults_startup.js
@@ -5,6 +5,7 @@
// @tags: [requires_sharding, requires_persistence, requires_journaling]
(function() {
"use strict";
+load("jstests/replsets/rslib.js"); // For reconnect.
function runTest(conn, failPointConn, restartFn) {
// Set a default rwc.
diff --git a/jstests/replsets/force_reconfig_skips_oplog_commitment.js b/jstests/replsets/force_reconfig_skips_oplog_commitment.js
index 5893fa8f144..bb98a7fee76 100644
--- a/jstests/replsets/force_reconfig_skips_oplog_commitment.js
+++ b/jstests/replsets/force_reconfig_skips_oplog_commitment.js
@@ -9,6 +9,7 @@
(function() {
"use strict";
load("jstests/libs/write_concern_util.js");
+load("jstests/replsets/rslib.js"); // For reconnect.
const dbName = "test";
const collName = "coll";
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 4013ecea6ff..f3335320585 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -75,10 +75,6 @@
var ReplSetTest = function(opts) {
'use strict';
- load("jstests/libs/parallelTester.js"); // For Thread.
- load("jstests/libs/fail_point_util.js"); // For configureFailPoint.
- load("jstests/replsets/rslib.js"); // For setFailPoint.
-
if (!(this instanceof ReplSetTest)) {
return new ReplSetTest(opts);
}
@@ -110,6 +106,19 @@ var ReplSetTest = function(opts) {
// Publicly exposed variables
/**
+ * Tries to load the 'jstests/libs/parallelTester.js' dependency. Returns true if the file is
+ * loaded successfully, and false otherwise.
+ */
+ function tryLoadParallelTester() {
+ try {
+ load("jstests/libs/parallelTester.js"); // For Thread.
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
+
+ /**
* Returns the config document reported from the specified connection.
*/
function _replSetGetConfig(conn) {
@@ -253,6 +262,20 @@ var ReplSetTest = function(opts) {
}
/**
+ * Helper functions for setting/clearing a failpoint.
+ */
+ function setFailPoint(node, failpoint, data = {}) {
+ print("Setting fail point " + failpoint);
+ assert.commandWorked(
+ node.adminCommand({configureFailPoint: failpoint, mode: "alwaysOn", data: data}));
+ }
+
+ function clearFailPoint(node, failpoint) {
+ print("Clearing fail point " + failpoint);
+ assert.commandWorked(node.adminCommand({configureFailPoint: failpoint, mode: "off"}));
+ }
+
+ /**
* Wait for a rs indicator to go to a particular state or states.
*
* @param node is a single node or list of nodes, by id or conn
@@ -1159,7 +1182,7 @@ var ReplSetTest = function(opts) {
// operations. This is only an optimization so it's OK if we bypass it in some suites.
let skipWaitFp;
if (failPointsSupported) {
- skipWaitFp = configureFailPoint(this.nodes[0], "skipOplogBatcherWaitForData");
+ setFailPoint(this.nodes[0], "skipOplogBatcherWaitForData");
}
// replSetInitiate and replSetReconfig commands can fail with a NodeNotFound error if a
@@ -1174,7 +1197,7 @@ var ReplSetTest = function(opts) {
// primary to be ready very soon. We also turn the failpoint off once we have a primary.
this.getPrimary(self.kDefaultTimeoutMS, 25 /* retryIntervalMS */);
if (failPointsSupported) {
- skipWaitFp.off();
+ clearFailPoint(this.nodes[0], "skipOplogBatcherWaitForData");
}
print("ReplSetTest initiate command took " + (new Date() - initiateStart) + "ms for " +
@@ -2983,7 +3006,7 @@ var ReplSetTest = function(opts) {
*
* @param {int[]} ports the array of mongo ports to run validation on
*/
- this.validateNodes = function(ports) {
+ this._validateNodes = function(ports) {
// Perform collection validation on each node in parallel.
let validators = [];
for (let i = 0; i < ports.length; i++) {
@@ -3062,17 +3085,20 @@ var ReplSetTest = function(opts) {
let startTime = new Date(); // Measure the execution time of shutting down nodes.
- // Optionally validate collections on all nodes.
+ // Optionally validate collections on all nodes. Parallel validation depends on use of the
+ // 'Thread' object, so we check for and load that dependency here. If the dependency is not
+ // met, we validate each node serially on shutdown.
+ const parallelValidate = tryLoadParallelTester();
if (opts.skipValidation) {
print("ReplSetTest stopSet skipping validation before stopping nodes.");
- } else {
+ } else if (parallelValidate) {
print("ReplSetTest stopSet validating all replica set nodes before stopping them.");
- this.validateNodes(this.ports);
+ this._validateNodes(this.ports);
}
- // Stop all nodes without waiting for them to terminate. We also skip validation since we
- // have already done it above.
- opts = Object.merge(opts, {skipValidation: true});
+ // Stop all nodes without waiting for them to terminate. We can skip validation on shutdown
+ // if we have already done it above.
+ opts = Object.merge(opts, {skipValidation: (parallelValidate || opts.skipValidation)});
for (let i = 0; i < this.ports.length; i++) {
this.stop(i, signal, opts, {waitpid: false});
}