summaryrefslogtreecommitdiff
path: root/src/mongo/shell/shardingtest.js
diff options
context:
space:
mode:
authorjannaerin <golden.janna@gmail.com>2018-02-07 17:38:49 -0500
committerjannaerin <golden.janna@gmail.com>2018-03-27 17:28:32 -0400
commita13de396ad866e677cb6e9598852b1f84e6b8346 (patch)
tree1dcd3a6bcbcd847d721df0293b468823089cf019 /src/mongo/shell/shardingtest.js
parentfb35ca2b60583936e7c20dd5c47ee34d62b8c5d2 (diff)
downloadmongo-a13de396ad866e677cb6e9598852b1f84e6b8346.tar.gz
SERVER-33444 Fix tests that fail when shard servers started as replica sets
Diffstat (limited to 'src/mongo/shell/shardingtest.js')
-rw-r--r--src/mongo/shell/shardingtest.js50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js
index 3a63f8192f4..29f710386b0 100644
--- a/src/mongo/shell/shardingtest.js
+++ b/src/mongo/shell/shardingtest.js
@@ -876,9 +876,31 @@ var ShardingTest = function(params) {
};
/**
+ * Restarts each node in a particular shard replica set using the shard's original startup
+ * options by default.
+ *
+ * Option { startClean : true } forces clearing the data directory.
+ * Option { auth : Object } object that contains the auth details for admin credentials.
+ * Should contain the fields 'user' and 'pwd'
+ *
+ *
+ * @param {int} shard server number (0, 1, 2, ...) to be restarted
+ */
+ this.restartShardRS = function(n, options, signal, wait) {
+ for (let i = 0; i < this["rs" + n].nodeList().length; i++) {
+ this["rs" + n].restart(i);
+ }
+
+ this["rs" + n].awaitSecondaryNodes();
+ this._connections[n] = new Mongo(this["rs" + n].getURL());
+ this["shard" + n] = this._connections[n];
+ };
+
+ /**
* Stops and restarts a config server mongod process.
*
- * If opts is specified, the new mongod is started using those options. Otherwise, it is started
+ * If opts is specified, the new mongod is started using those options. Otherwise, it is
+ * started
* with its previous parameters.
*
* Warning: Overwrites the old cn/confign member variables.
@@ -1053,6 +1075,7 @@ var ShardingTest = function(params) {
var tempCount = 0;
for (var i in numShards) {
otherParams[i] = numShards[i];
+
tempCount++;
}
@@ -1143,6 +1166,31 @@ var ShardingTest = function(params) {
rsDefaults.nodes = rsDefaults.nodes || otherParams.numReplicas;
}
+ if (startShardsAsRS && !(otherParams.rs || otherParams["rs" + i])) {
+ if (jsTestOptions().shardMixedBinVersions) {
+ if (!otherParams.shardOptions) {
+ otherParams.shardOptions = {};
+ }
+ // If the test doesn't depend on specific shard binVersions, create a mixed
+ // version
+ // shard cluster that randomly assigns shard binVersions, half "latest" and half
+ // "last-stable".
+ if (!otherParams.shardOptions.binVersion) {
+ Random.setRandomSeed();
+ otherParams.shardOptions.binVersion =
+ MongoRunner.versionIterator(["latest", "last-stable"], true);
+ }
+ }
+
+ if (otherParams.shardOptions && otherParams.shardOptions.binVersion) {
+ otherParams.shardOptions.binVersion =
+ MongoRunner.versionIterator(otherParams.shardOptions.binVersion);
+ }
+
+ rsDefaults = Object.merge(rsDefaults, otherParams["d" + i]);
+ rsDefaults = Object.merge(rsDefaults, otherParams.shardOptions);
+ }
+
var rsSettings = rsDefaults.settings;
delete rsDefaults.settings;