summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-02-18 12:39:10 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-18 17:51:37 +0000
commite01b8611919d8da6510818bf8a27e78e0c038418 (patch)
treea0218d944e7a8a9b114e1e71e630fad4eaa7d004
parent3f529eeb89a3821604012ea86e9ef7d6fb962a24 (diff)
downloadmongo-e01b8611919d8da6510818bf8a27e78e0c038418.tar.gz
SERVER-45944 add js test for fcv downgrade during index builds
create mode 100644 jstests/noPassthrough/index_downgrade_fcv.js
-rw-r--r--jstests/noPassthrough/index_downgrade_fcv.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/jstests/noPassthrough/index_downgrade_fcv.js b/jstests/noPassthrough/index_downgrade_fcv.js
new file mode 100644
index 00000000000..bbc29a5664b
--- /dev/null
+++ b/jstests/noPassthrough/index_downgrade_fcv.js
@@ -0,0 +1,55 @@
+/**
+ * If a user attempts to downgrade the server while there is an index build in progress, we should
+ * reject the downgrade request.
+ * @tags: [requires_replication]
+ */
+(function() {
+"use strict";
+
+load('jstests/noPassthrough/libs/index_build.js');
+
+const rst = new ReplSetTest({
+ nodes: [
+ {},
+ {
+ // Disallow elections on secondary.
+ rsConfig: {
+ priority: 0,
+ votes: 0,
+ },
+ },
+ ]
+});
+const nodes = rst.startSet();
+rst.initiate();
+
+const primary = rst.getPrimary();
+const testDB = primary.getDB('test');
+const coll = testDB.getCollection('test');
+
+assert.commandWorked(coll.insert({a: 1}));
+
+IndexBuildTest.pauseIndexBuilds(primary);
+
+const createIdx = IndexBuildTest.startIndexBuild(primary, coll.getFullName(), {a: 1});
+IndexBuildTest.waitForIndexBuildToScanCollection(testDB, coll.getName(), 'a_1');
+
+// Downgrade the primary using the setFeatureCompatibilityVersion command.
+try {
+ assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: lastStableFCV}));
+} finally {
+ IndexBuildTest.resumeIndexBuilds(primary);
+}
+
+IndexBuildTest.waitForIndexBuildToStop(testDB);
+
+createIdx();
+
+IndexBuildTest.assertIndexes(coll, 2, ['_id_', 'a_1']);
+
+// This confirms that the downgrade command will complete successfully after the index build has
+// completed.
+assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: lastStableFCV}));
+
+rst.stopSet();
+})();