summaryrefslogtreecommitdiff
path: root/jstests/multiVersion
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@mongodb.com>2020-03-05 16:28:07 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-10 14:29:44 +0000
commit771398011bc520c425563fa41c2096b3b361700d (patch)
tree8b74a8408c1ac022ffef4b4b39cc6f49085a2705 /jstests/multiVersion
parente0d34a841aab61ff6fa2a6045c90a0a828bcb3bc (diff)
downloadmongo-771398011bc520c425563fa41c2096b3b361700d.tar.gz
SERVER-46089 Test downgrade with arbiter
(cherry picked from commit ef959bbc8e0b3601323a162eb99d69716b07e548)
Diffstat (limited to 'jstests/multiVersion')
-rw-r--r--jstests/multiVersion/libs/multi_rs.js19
-rw-r--r--jstests/multiVersion/remove_config_term_on_replset_downgrade.js136
2 files changed, 90 insertions, 65 deletions
diff --git a/jstests/multiVersion/libs/multi_rs.js b/jstests/multiVersion/libs/multi_rs.js
index ce67a5ed157..1529353aca5 100644
--- a/jstests/multiVersion/libs/multi_rs.js
+++ b/jstests/multiVersion/libs/multi_rs.js
@@ -10,14 +10,14 @@
ReplSetTest.prototype.upgradeSet = function(options, user, pwd) {
let primary = this.getPrimary();
- // Upgrade secondaries first.
this.upgradeSecondaries(primary, options, user, pwd);
+ this.upgradeArbiters(primary, options, user, pwd);
- // Then upgrade the primary after stepping down.
+ // Upgrade the primary after stepping down.
this.upgradePrimary(primary, options, user, pwd);
};
-ReplSetTest.prototype.upgradeSecondaries = function(primary, options, user, pwd) {
+ReplSetTest.prototype.upgradeMembers = function(primary, members, options, user, pwd) {
const noDowntimePossible = this.nodes.length > 2;
// Merge new options into node settings.
@@ -25,14 +25,22 @@ ReplSetTest.prototype.upgradeSecondaries = function(primary, options, user, pwd)
this.nodeOptions[nodeName] = Object.merge(this.nodeOptions[nodeName], options);
}
- for (let secondary of this.getSecondaries()) {
- this.upgradeNode(secondary, options, user, pwd);
+ for (let member of members) {
+ this.upgradeNode(member, options, user, pwd);
if (noDowntimePossible)
assert.eq(this.getPrimary(), primary);
}
};
+ReplSetTest.prototype.upgradeSecondaries = function(primary, options, user, pwd) {
+ this.upgradeMembers(primary, this.getSecondaries(), options, user, pwd);
+};
+
+ReplSetTest.prototype.upgradeArbiters = function(primary, options, user, pwd) {
+ this.upgradeMembers(primary, this.getArbiters(), options, user, pwd);
+};
+
ReplSetTest.prototype.upgradePrimary = function(primary, options, user, pwd) {
const noDowntimePossible = this.nodes.length > 2;
@@ -122,7 +130,6 @@ ReplSetTest.prototype.stepdown = function(nodeId) {
ReplSetTest.prototype.reconnect = function(node) {
var nodeId = this.getNodeId(node);
this.nodes[nodeId] = new Mongo(node.host);
- var except = {};
for (var i in node) {
if (typeof (node[i]) == "function")
continue;
diff --git a/jstests/multiVersion/remove_config_term_on_replset_downgrade.js b/jstests/multiVersion/remove_config_term_on_replset_downgrade.js
index 782c4e24fd8..bf39a50fb88 100644
--- a/jstests/multiVersion/remove_config_term_on_replset_downgrade.js
+++ b/jstests/multiVersion/remove_config_term_on_replset_downgrade.js
@@ -9,73 +9,91 @@
load('jstests/multiVersion/libs/multi_rs.js');
load('jstests/libs/test_background_ops.js');
-let newVersion = "latest";
-let oldVersion = "last-stable";
+const newVersion = "latest";
+const oldVersion = "last-stable";
-let nodes = {
- n1: {binVersion: newVersion},
- n2: {binVersion: newVersion},
- n3: {binVersion: newVersion}
-};
+function testDowngrade(useArbiter) {
+ let nodes = {
+ n1: {binVersion: newVersion},
+ n2: {binVersion: newVersion},
+ n3: {binVersion: newVersion}
+ };
-let rst = new ReplSetTest({nodes: nodes});
-rst.startSet();
-rst.initiate();
+ let replicaSetName = `testDowngrade${useArbiter ? "With" : "Without"}Arbiter`;
+ let rst = new ReplSetTest({name: replicaSetName, nodes: nodes});
+ let nodenames = rst.nodeList();
+ rst.startSet();
+ rst.initiate({
+ "_id": replicaSetName,
+ "members": [
+ {"_id": 0, "host": nodenames[0]},
+ {"_id": 1, "host": nodenames[1]},
+ {"_id": 2, "host": nodenames[2], arbiterOnly: useArbiter}
+ ]
+ });
-let primary = rst.getPrimary();
+ let primary = rst.getPrimary();
-// The default FCV is latestFCV for non-shard replica sets.
-let primaryAdminDB = rst.getPrimary().getDB("admin");
-checkFCV(primaryAdminDB, latestFCV);
+ // The default FCV is latestFCV for non-shard replica sets.
+ let primaryAdminDB = rst.getPrimary().getDB("admin");
+ checkFCV(primaryAdminDB, latestFCV);
-// Reconfig in FCV 4.4.
-let originalConfig = rst.getReplSetConfigFromNode();
-originalConfig.version++;
-reconfig(rst, originalConfig);
-rst.awaitNodesAgreeOnConfigVersion();
+ // Reconfig in FCV 4.4.
+ let originalConfig = rst.getReplSetConfigFromNode();
+ originalConfig.version++;
+ reconfig(rst, originalConfig);
+ rst.awaitNodesAgreeOnConfigVersion();
-// Check that the term field exists in the config document on all nodes.
-rst.nodes.forEach(function(node) {
- jsTestLog("Checking the config term on node " + tojson(node.host) + " before downgrade.");
- let config = node.getDB("local").getCollection("system.replset").findOne();
- assert(config.hasOwnProperty("term"));
-});
+ // Check that the term field exists in the config document on all nodes.
+ rst.nodes.forEach(function(node) {
+ jsTestLog("Checking the config term on node " + tojson(node.host) + " before downgrade.");
+ let config = node.getDB("local").getCollection("system.replset").findOne();
+ assert(config.hasOwnProperty("term"));
+ });
-// Remember the config from the primary before the downgrade.
-let configInNewVersion = rst.getReplSetConfigFromNode();
+ // Remember the config from the primary before the downgrade.
+ let configInNewVersion = rst.getReplSetConfigFromNode();
-jsTest.log("Downgrading FCV to 4.2");
-assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: lastStableFCV}));
-rst.awaitReplication();
-// Check that the term field doesn't exist in the config document on all nodes.
-rst.nodes.forEach(function(node) {
- jsTestLog("Checking the config term on node " + tojson(node.host) + " after FCV downgrade.");
- let config = node.getDB("local").getCollection("system.replset").findOne();
- assert(!config.hasOwnProperty("term"), tojson(config));
- // The configs can only differ in config versions and terms.
- config.term = configInNewVersion.term;
- // The versions differ because of the force reconfig on downgrade.
- assert.eq(config.version, configInNewVersion.version + 1);
- config.version = configInNewVersion.version;
- assert.docEq(configInNewVersion, config);
-});
+ jsTest.log("Downgrading FCV to 4.2");
+ assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: lastStableFCV}));
+ rst.awaitReplication();
+ // Check that the term field doesn't exist in the config document on all nodes.
+ rst.nodes.forEach(function(node) {
+ jsTestLog("Checking the config term on node " + tojson(node.host) +
+ " after FCV downgrade.");
+ let config = node.getDB("local").getCollection("system.replset").findOne();
+ assert(!config.hasOwnProperty("term"), tojson(config));
+ // The configs can only differ in config versions and terms.
+ config.term = configInNewVersion.term;
+ // The versions differ because of the force reconfig on downgrade.
+ assert.eq(config.version, configInNewVersion.version + 1);
+ config.version = configInNewVersion.version;
+ assert.docEq(configInNewVersion, config);
+ });
-jsTest.log("Downgrading replica set..");
-rst.upgradeSet({binVersion: oldVersion});
-jsTest.log("Downgrade complete.");
+ jsTest.log("Downgrading replica set..");
+ rst.upgradeSet({binVersion: oldVersion});
+ jsTest.log("Downgrade complete.");
-// Check that the term field doesn't exist in the config document on all nodes.
-rst.nodes.forEach(function(node) {
- reconnect(node);
- jsTestLog("Checking the config term on node " + tojson(node.host) + " after binary downgrade.");
- let config = node.getDB("local").getCollection("system.replset").findOne();
- assert(!config.hasOwnProperty("term"), tojson(config));
- // The configs can only differ in config versions and terms.
- config.term = configInNewVersion.term;
- // The versions differ because of the force reconfig on downgrade.
- assert.eq(config.version, configInNewVersion.version + 1);
- config.version = configInNewVersion.version;
- assert.docEq(configInNewVersion, config);
-});
-rst.stopSet();
+ // Check that the term field doesn't exist in the config document on all nodes.
+ rst.nodes.forEach(function(node) {
+ reconnect(node);
+ jsTestLog("Checking the config term on node " + tojson(node.host) +
+ " after binary downgrade.");
+ let config = node.getDB("local").getCollection("system.replset").findOne();
+ assert(!config.hasOwnProperty("term"), tojson(config));
+ // The configs can only differ in config versions and terms.
+ config.term = configInNewVersion.term;
+ // The versions differ because of the force reconfig on downgrade.
+ assert.eq(config.version, configInNewVersion.version + 1);
+ config.version = configInNewVersion.version;
+ assert.docEq(configInNewVersion, config);
+ });
+ rst.stopSet();
+}
+
+jsTestLog('Test downgrading WITHOUT an arbiter');
+testDowngrade(false);
+jsTestLog('Test downgrading WITH an arbiter');
+testDowngrade(true);
})();