diff options
Diffstat (limited to 'jstests/noPassthrough')
-rw-r--r-- | jstests/noPassthrough/feature_compatibility_version.js | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/jstests/noPassthrough/feature_compatibility_version.js b/jstests/noPassthrough/feature_compatibility_version.js index a413ac02542..47f992f3b22 100644 --- a/jstests/noPassthrough/feature_compatibility_version.js +++ b/jstests/noPassthrough/feature_compatibility_version.js @@ -23,31 +23,49 @@ assert.commandWorked( {$set: {version: lastStableFCV, targetVersion: latestFCV}})); checkFCV(adminDB, lastStableFCV, latestFCV); -assert.commandWorked( - adminDB.system.version.update({_id: "featureCompatibilityVersion"}, - {$set: {version: lastStableFCV, targetVersion: lastStableFCV}})); +assert.commandWorked(adminDB.system.version.update( + {_id: "featureCompatibilityVersion"}, + {$set: {version: lastStableFCV, targetVersion: lastStableFCV, previousVersion: latestFCV}})); checkFCV(adminDB, lastStableFCV, lastStableFCV); -assert.commandWorked( - adminDB.system.version.update({_id: "featureCompatibilityVersion"}, - {$set: {version: latestFCV}, $unset: {targetVersion: true}})); +// When present, "previousVersion" will always be the latestFCV. +assert.writeErrorWithCode(adminDB.system.version.update({_id: "featureCompatibilityVersion"}, + {$set: {previousVersion: lastStableFCV}}), + 4926901); +checkFCV(adminDB, lastStableFCV, lastStableFCV); + +// Downgrading FCV must have a 'previousVersion' field. +assert.writeErrorWithCode(adminDB.system.version.update({_id: "featureCompatibilityVersion"}, + {$unset: {previousVersion: true}}), + 4926902); +checkFCV(adminDB, lastStableFCV, lastStableFCV); + +assert.commandWorked(adminDB.system.version.update( + {_id: "featureCompatibilityVersion"}, + {$set: {version: latestFCV}, $unset: {targetVersion: true, previousVersion: 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); + 4926900); 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); + 4926904); checkFCV(adminDB, latestFCV); assert.writeErrorWithCode(adminDB.system.version.update({_id: "featureCompatibilityVersion"}, {$set: {targetVersion: latestFCV}}), - ErrorCodes.BadValue); + 4926904); +checkFCV(adminDB, latestFCV); + +// Setting an unknown field. +assert.writeErrorWithCode(adminDB.system.version.update({_id: "featureCompatibilityVersion"}, + {$set: {unknownField: "unknown"}}), + 40415); checkFCV(adminDB, latestFCV); MongoRunner.stopMongod(conn); |