summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/feature_compatibility_version.js
blob: 4f7cd42f45007cee7de837906a6075bc68dd5f4a (plain)
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
// 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");

const conn = MongoRunner.runMongod({});
assert.neq(null, conn, "mongod was unable to start up");

let adminDB = conn.getDB("admin");

// Initially the featureCompatibilityVersion is latestFCV.
checkFCV(adminDB, latestFCV);

// Updating the featureCompatibilityVersion document changes the featureCompatibilityVersion
// server parameter.
assert.writeOK(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
                                             {$set: {version: lastStableFCV}}));
checkFCV(adminDB, lastStableFCV);

assert.writeOK(
    adminDB.system.version.update({_id: "featureCompatibilityVersion"},
                                  {$set: {version: lastStableFCV, targetVersion: latestFCV}}));
checkFCV(adminDB, lastStableFCV, latestFCV);

assert.writeOK(
    adminDB.system.version.update({_id: "featureCompatibilityVersion"},
                                  {$set: {version: lastStableFCV, targetVersion: lastStableFCV}}));
checkFCV(adminDB, lastStableFCV, lastStableFCV);

assert.writeOK(
    adminDB.system.version.update({_id: "featureCompatibilityVersion"},
                                  {$set: {version: latestFCV}, $unset: {targetVersion: true}}));
checkFCV(adminDB, latestFCV);

// 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);

// 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);

assert.writeErrorWithCode(adminDB.system.version.update({_id: "featureCompatibilityVersion"},
                                                        {$set: {targetVersion: latestFCV}}),
                          ErrorCodes.BadValue);
checkFCV(adminDB, latestFCV);

MongoRunner.stopMongod(conn);
}());