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() {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const conn = MongoRunner.runMongod({});
|
|
|
|
assert.neq(null, conn, "mongod was unable to start up");
|
|
|
|
|
|
|
|
let adminDB = conn.getDB("admin");
|
|
|
|
|
2017-06-02 21:29:32 +02:00
|
|
|
// Initially the featureCompatibilityVersion is 3.6.
|
2017-02-28 22:48:14 +01:00
|
|
|
let res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
2017-06-02 21:29:32 +02:00
|
|
|
assert.eq("3.6", res.featureCompatibilityVersion);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
|
|
|
// Updating the featureCompatibilityVersion document changes the featureCompatibilityVersion
|
|
|
|
// server parameter.
|
|
|
|
assert.writeOK(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
|
2017-06-02 21:29:32 +02:00
|
|
|
{$set: {version: "3.4"}}));
|
2017-02-28 22:48:14 +01:00
|
|
|
res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
2017-06-02 21:29:32 +02:00
|
|
|
assert.eq("3.4", res.featureCompatibilityVersion);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
|
|
|
assert.writeOK(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
|
2017-06-02 21:29:32 +02:00
|
|
|
{$set: {version: "3.6"}}));
|
2017-02-28 22:48:14 +01:00
|
|
|
res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
2017-06-02 21:29:32 +02:00
|
|
|
assert.eq("3.6", res.featureCompatibilityVersion);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
|
|
|
// Updating the featureCompatibilityVersion document with an invalid version fails.
|
|
|
|
assert.writeErrorWithCode(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
|
2017-06-02 21:29:32 +02:00
|
|
|
{$set: {version: "3.2"}}),
|
2017-02-28 22:48:14 +01:00
|
|
|
ErrorCodes.BadValue);
|
|
|
|
res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
2017-06-02 21:29:32 +02:00
|
|
|
assert.eq("3.6", res.featureCompatibilityVersion);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
|
|
|
// Deleting the featureCompatibilityVersion document changes the featureCompatibilityVersion
|
2017-06-02 21:29:32 +02:00
|
|
|
// server parameter to 3.4.
|
2017-02-28 22:48:14 +01:00
|
|
|
assert.writeOK(adminDB.system.version.remove({_id: "featureCompatibilityVersion"}));
|
|
|
|
res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
2017-06-02 21:29:32 +02:00
|
|
|
assert.eq("3.4", res.featureCompatibilityVersion);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
|
|
|
// Inserting a featureCompatibilityVersion document with an invalid version fails.
|
|
|
|
assert.writeErrorWithCode(
|
2017-06-02 21:29:32 +02:00
|
|
|
adminDB.system.version.insert({_id: "featureCompatibilityVersion", version: "3.2"}),
|
|
|
|
ErrorCodes.BadValue);
|
|
|
|
res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
|
|
|
assert.eq("3.4", res.featureCompatibilityVersion);
|
|
|
|
|
|
|
|
assert.writeErrorWithCode(
|
|
|
|
adminDB.system.version.insert({_id: "featureCompatibilityVersion", version: "3.8"}),
|
2017-02-28 22:48:14 +01:00
|
|
|
ErrorCodes.BadValue);
|
|
|
|
res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
2017-06-02 21:29:32 +02:00
|
|
|
assert.eq("3.4", res.featureCompatibilityVersion);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
|
|
|
// Inserting the featureCompatibilityVersion document changes the featureCompatibilityVersion
|
|
|
|
// server parameter.
|
|
|
|
assert.writeOK(
|
2017-06-02 21:29:32 +02:00
|
|
|
adminDB.system.version.insert({_id: "featureCompatibilityVersion", version: "3.4"}));
|
2017-02-28 22:48:14 +01:00
|
|
|
res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
2017-06-02 21:29:32 +02:00
|
|
|
assert.eq("3.4", res.featureCompatibilityVersion);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
|
|
|
assert.writeOK(adminDB.system.version.remove({_id: "featureCompatibilityVersion"}));
|
|
|
|
res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
2017-06-02 21:29:32 +02:00
|
|
|
assert.eq("3.4", res.featureCompatibilityVersion);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
|
|
|
assert.writeOK(
|
2017-06-02 21:29:32 +02:00
|
|
|
adminDB.system.version.insert({_id: "featureCompatibilityVersion", version: "3.6"}));
|
2017-02-28 22:48:14 +01:00
|
|
|
res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
2017-06-02 21:29:32 +02:00
|
|
|
assert.eq("3.6", res.featureCompatibilityVersion);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
2017-06-02 21:29:32 +02:00
|
|
|
// Dropping the admin database changes the featureCompatibilityVersion server parameter to 3.4.
|
2017-02-28 22:48:14 +01:00
|
|
|
adminDB.dropDatabase();
|
|
|
|
res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
|
|
|
|
assert.commandWorked(res);
|
2017-06-02 21:29:32 +02:00
|
|
|
assert.eq("3.4", res.featureCompatibilityVersion);
|
2017-02-28 22:48:14 +01:00
|
|
|
|
|
|
|
MongoRunner.stopMongod(conn);
|
|
|
|
}());
|