2017-02-28 22:48:14 +01:00
|
|
|
// Tests that manipulating the featureCompatibilityVersion document in admin.system.version changes
|
|
|
|
// the value of the featureCompatibilityVersion server parameter.
|
|
|
|
|
|
|
|
(function() {
|
2019-07-27 00:20:35 +02:00
|
|
|
"use strict";
|
2017-02-28 22:48:14 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
load("jstests/libs/feature_compatibility_version.js");
|
2017-10-24 20:48:16 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
const conn = MongoRunner.runMongod({});
|
|
|
|
assert.neq(null, conn, "mongod was unable to start up");
|
2017-02-28 22:48:14 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
let adminDB = conn.getDB("admin");
|
2017-02-28 22:48:14 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
// Initially the featureCompatibilityVersion is latestFCV.
|
|
|
|
checkFCV(adminDB, latestFCV);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
// Updating the featureCompatibilityVersion document changes the featureCompatibilityVersion
|
|
|
|
// server parameter.
|
|
|
|
assert.writeOK(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
|
|
|
|
{$set: {version: lastStableFCV}}));
|
|
|
|
checkFCV(adminDB, lastStableFCV);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
assert.writeOK(
|
|
|
|
adminDB.system.version.update({_id: "featureCompatibilityVersion"},
|
|
|
|
{$set: {version: lastStableFCV, targetVersion: latestFCV}}));
|
|
|
|
checkFCV(adminDB, lastStableFCV, latestFCV);
|
2017-10-24 20:48:16 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
assert.writeOK(
|
|
|
|
adminDB.system.version.update({_id: "featureCompatibilityVersion"},
|
|
|
|
{$set: {version: lastStableFCV, targetVersion: lastStableFCV}}));
|
|
|
|
checkFCV(adminDB, lastStableFCV, lastStableFCV);
|
2017-10-24 20:48:16 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
assert.writeOK(
|
|
|
|
adminDB.system.version.update({_id: "featureCompatibilityVersion"},
|
|
|
|
{$set: {version: latestFCV}, $unset: {targetVersion: true}}));
|
|
|
|
checkFCV(adminDB, latestFCV);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
// Updating the featureCompatibilityVersion document with an invalid version fails.
|
|
|
|
assert.writeErrorWithCode(
|
|
|
|
adminDB.system.version.update({_id: "featureCompatibilityVersion"}, {$set: {version: "3.2"}}),
|
|
|
|
ErrorCodes.BadValue);
|
|
|
|
checkFCV(adminDB, latestFCV);
|
2017-10-24 20:48:16 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
// Updating the featureCompatibilityVersion document with an invalid targetVersion fails.
|
|
|
|
assert.writeErrorWithCode(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
|
|
|
|
{$set: {targetVersion: lastStableFCV}}),
|
|
|
|
ErrorCodes.BadValue);
|
|
|
|
checkFCV(adminDB, latestFCV);
|
2018-01-24 19:17:37 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
assert.writeErrorWithCode(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
|
|
|
|
{$set: {targetVersion: latestFCV}}),
|
|
|
|
ErrorCodes.BadValue);
|
|
|
|
checkFCV(adminDB, latestFCV);
|
2018-01-24 19:17:37 +01:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
MongoRunner.stopMongod(conn);
|
2017-02-28 22:48:14 +01:00
|
|
|
}());
|