summaryrefslogtreecommitdiff
path: root/jstests/replsets/initial_sync_fcv_upgrade.js
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2020-05-07 08:30:13 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-30 03:21:52 +0000
commitd00b75bfcac3ac74036ac6c2ceec4e8b42ac93a0 (patch)
tree0dadf6ebd8824e80dcec2e8ccb412c84c3affe8d /jstests/replsets/initial_sync_fcv_upgrade.js
parent1e1af7c30b287e72773f72a9ba31d3bdfae1502a (diff)
downloadmongo-d00b75bfcac3ac74036ac6c2ceec4e8b42ac93a0.tar.gz
SERVER-46379 upgrade/downgrade support for initial sync semantics.
Diffstat (limited to 'jstests/replsets/initial_sync_fcv_upgrade.js')
-rw-r--r--jstests/replsets/initial_sync_fcv_upgrade.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/jstests/replsets/initial_sync_fcv_upgrade.js b/jstests/replsets/initial_sync_fcv_upgrade.js
new file mode 100644
index 00000000000..c251055da86
--- /dev/null
+++ b/jstests/replsets/initial_sync_fcv_upgrade.js
@@ -0,0 +1,68 @@
+/*
+ * Tests that on a successful fcv upgrade, adding new voters to the replica set
+ * makes replConfig to contain members with 'newlyAdded' field.
+ *
+ * This tests behavior centered around FCV upgrade.
+ * @tags: [multiversion_incompatible]
+ */
+(function() {
+'use strict';
+
+load('jstests/replsets/rslib.js');
+
+// Start a single node replica set.
+// Disable Chaining so that initial sync nodes always sync from primary.
+const rst = new ReplSetTest({
+ nodes: 1,
+ nodeOptions: {setParameter: {enableAutomaticReconfig: true}},
+ settings: {chainingAllowed: false}
+});
+rst.startSet();
+rst.initiateWithHighElectionTimeout();
+
+const dbName = jsTest.name();
+const collName = "coll";
+
+const primary = rst.getPrimary();
+const primaryDB = primary.getDB(dbName);
+const primaryColl = primaryDB[collName];
+const primaryAdminDB = primary.getDB("admin");
+
+// Set FCV to 4.4 to test the upgrade behavior.
+assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: lastStableFCV}));
+assert.commandWorked(primary.adminCommand({clearLog: "global"}));
+
+let startupParams = {};
+startupParams['failpoint.initialSyncHangAfterDataCloning'] = tojson({mode: 'alwaysOn'});
+startupParams['enableAutomaticReconfig'] = true;
+
+jsTestLog("Upgrade FCV to " + latestFCV);
+assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: latestFCV}));
+
+jsTestLog("Adding a new voting node (node1) to the replica set");
+const node1 = rst.add({rsConfig: {priority: 0, votes: 1}, setParameter: startupParams});
+rst.reInitiate();
+
+jsTestLog("Wait for node1 to hang during initial sync");
+checkLog.containsJson(node1, 21184);
+
+// Check that 'newlyAdded' field is set.
+assert(isMemberNewlyAdded(primary, 1));
+assertVoteCount(primary, {
+ votingMembersCount: 1,
+ majorityVoteCount: 1,
+ writableVotingMembersCount: 1,
+ writeMajorityCount: 1,
+ totalMembersCount: 2,
+});
+
+jsTestLog("Perform test cleanup");
+assert.commandWorked(
+ node1.adminCommand({configureFailPoint: "initialSyncHangAfterDataCloning", mode: 'off'}));
+rst.waitForState(node1, ReplSetTest.State.SECONDARY);
+
+// Check if writeConcern: 2 works.
+assert.commandWorked(primaryColl.insert({_id: 0}, {"writeConcern": {"w": 2}}));
+
+rst.stopSet();
+}()); \ No newline at end of file