1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// Tests that manipulating the featureCompatibilityVersion document in admin.system.version changes
// the value of the featureCompatibilityVersion server parameter.
(function() {
"use strict";
load("jstests/libs/feature_compatibility_version.js");
/**
* Checks that the featureCompatibilityVersion document is missing.
*/
let checkFCVDocumentMissing = function(adminDB) {
assert.eq(null, adminDB.system.version.findOne({_id: "featureCompatibilityVersion"}));
};
const conn = MongoRunner.runMongod({});
assert.neq(null, conn, "mongod was unable to start up");
let adminDB = conn.getDB("admin");
// Initially the featureCompatibilityVersion is 3.6.
checkFCV(adminDB, "3.6");
// Updating the featureCompatibilityVersion document changes the featureCompatibilityVersion
// server parameter.
assert.writeOK(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
{$set: {version: "3.4"}}));
checkFCV(adminDB, "3.4");
assert.writeOK(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
{$set: {version: "3.4", targetVersion: "3.6"}}));
checkFCV(adminDB, "3.4", "3.6");
assert.writeOK(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
{$set: {version: "3.4", targetVersion: "3.4"}}));
checkFCV(adminDB, "3.4", "3.4");
assert.writeOK(
adminDB.system.version.update({_id: "featureCompatibilityVersion"},
{$set: {version: "3.6"}, $unset: {targetVersion: true}}));
checkFCV(adminDB, "3.6");
// 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, "3.6");
// Updating the featureCompatibilityVersion document with an invalid targetVersion fails.
assert.writeErrorWithCode(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
{$set: {targetVersion: "3.4"}}),
ErrorCodes.BadValue);
checkFCV(adminDB, "3.6");
assert.writeErrorWithCode(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
{$set: {targetVersion: "3.6"}}),
ErrorCodes.BadValue);
checkFCV(adminDB, "3.6");
// Do hack to remove FCV document.
removeFCVDocument(adminDB);
checkFCVDocumentMissing(adminDB);
// Inserting a featureCompatibilityVersion document with an invalid version fails.
assert.writeErrorWithCode(
adminDB.system.version.insert({_id: "featureCompatibilityVersion", version: "3.2"}),
ErrorCodes.BadValue);
checkFCVDocumentMissing(adminDB);
assert.writeErrorWithCode(
adminDB.system.version.insert({_id: "featureCompatibilityVersion", version: "3.8"}),
ErrorCodes.BadValue);
checkFCVDocumentMissing(adminDB);
// Inserting a featureCompatibilityVersion document with an invalid targetVersion fails.
assert.writeErrorWithCode(
adminDB.system.version.insert(
{_id: "featureCompatibilityVersion", version: "3.6", targetVersion: "3.4"}),
ErrorCodes.BadValue);
checkFCVDocumentMissing(adminDB);
assert.writeErrorWithCode(
adminDB.system.version.insert(
{_id: "featureCompatibilityVersion", version: "3.6", targetVersion: "3.6"}),
ErrorCodes.BadValue);
checkFCVDocumentMissing(adminDB);
assert.writeOK(
adminDB.system.version.insert({_id: "featureCompatibilityVersion", version: "3.6"}));
checkFCV(adminDB, "3.6");
MongoRunner.stopMongod(conn);
}());
|