src/mongo/shell/feature_compatibility_version.js
/**
 * Checks the featureCompatibilityVersion document and server parameter. The
 * featureCompatibilityVersion document is of the form {_id: "featureCompatibilityVersion", version:
 * <required>, targetVersion: <optional>, previousVersion: <optional>}. The getParameter result is
 * of the form {featureCompatibilityVersion: {version: <required>, targetVersion: <optional>,
 * previousVersion: <optional>}, ok: 1}.
 */
Checks the featureCompatibilityVersion document and server parameter. The
featureCompatibilityVersion document is of the form {_id: "featureCompatibilityVersion", version:
, targetVersion: , previousVersion: }.
Checks the featureCompatibilityVersion document and server parameter . The featureCompatibilityVersion document is of the form { _id : " featureCompatibilityVersion " version : targetVersion : previousVersion : } .
function checkFCV(adminDB, version, targetVersion) {
    const isDowngrading = (version === lastLTSFCV && targetVersion === lastLTSFCV) ||
        (version === lastContinuousFCV && targetVersion === lastContinuousFCV);
    const isMongod = !adminDB.getMongo().isMongos();
    if (isMongod) {
        let res = adminDB.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
        assert.commandWorked(res);
        assert.eq(res.featureCompatibilityVersion.version, version, tojson(res));
        assert.eq(res.featureCompatibilityVersion.targetVersion, targetVersion, tojson(res));
        if (isDowngrading) {
            assert.eq(res.featureCompatibilityVersion.previousVersion, latestFCV, tojson(res));
        } else {
            assert.eq(res.featureCompatibilityVersion.previousVersion, undefined, tojson(res));
        }
    }
    let doc = adminDB.system.version.find({_id: "featureCompatibilityVersion"})
                  .limit(1)
                  .readConcern("local")
                  .next();
    assert.eq(doc.version, version, tojson(doc));
    assert.eq(doc.targetVersion, targetVersion, tojson(doc));
    if (isDowngrading) {
        assert.eq(doc.previousVersion, latestFCV, tojson(doc));
    } else {
        assert.eq(doc.previousVersion, undefined, tojson(doc));
    }
}
function checkFCV ( adminDB , version , targetVersion ) { const isDowngrading = ( version === lastLTSFCV && targetVersion === lastLTSFCV ) || ( version === lastContinuousFCV && targetVersion === lastContinuousFCV ) ; const isMongod = ! adminDB . getMongo ( ) . isMongos ( ) ; if ( isMongod ) { let res = adminDB . runCommand ( { getParameter : 1 , featureCompatibilityVersion : 1 } ) ; assert . commandWorked ( res ) ; assert . eq ( res . featureCompatibilityVersion . version , version , tojson ( res ) ) ; assert . eq ( res . featureCompatibilityVersion . targetVersion , targetVersion , tojson ( res ) ) ; if ( isDowngrading ) { assert . eq ( res . featureCompatibilityVersion . previousVersion , latestFCV , tojson ( res ) ) ; } else { assert . eq ( res . featureCompatibilityVersion . previousVersion , undefined , tojson ( res ) ) ; } } let doc = adminDB . system . version . find ( { _id : "featureCompatibilityVersion" } ) . limit ( 1 ) . readConcern ( "local" ) . next ( ) ; assert . eq ( doc . version , version , tojson ( doc ) ) ; assert . eq ( doc . targetVersion , targetVersion , tojson ( doc ) ) ; if ( isDowngrading ) { assert . eq ( doc . previousVersion , latestFCV , tojson ( doc ) ) ; } else { assert . eq ( doc . previousVersion , undefined , tojson ( doc ) ) ; } }
Checks the featureCompatibilityVersion document and server parameter.
Checks the featureCompatibilityVersion document and server parameter .
// When both version and targetVersion are equal to lastContinuousFCV or lastLTSFCV, downgrade // is in progress. This tests that previousVersion is always equal to latestFCV in downgrading // states or undefined otherwise. // This query specifies an explicit readConcern because some FCV tests pass a connection that // has manually run isMaster with internalClient, and mongod expects internalClients (ie. other // cluster members) to include read/write concern (on commands that accept read/write concern).