jstests/noPassthrough/hello_feature_compatibility_version.js
// Test wire version for upgrade/downgrade.
Test wire version for upgrade/downgrade.
Test wire version for upgrade / downgrade .
function runTest(downgradeFCV, downgradeWireVersion, maxWireVersion, cmd) {
    assert.commandWorked(
        adminDB.system.version.update({_id: "featureCompatibilityVersion"},
                                      {$set: {version: downgradeFCV, targetVersion: latestFCV}}));
    let res = cmdAsInternalClient(cmd);
    assert.eq(res.minWireVersion, res.maxWireVersion, tojson(res));
    assert.eq(maxWireVersion, res.maxWireVersion, tojson(res));
    assert.commandWorked(adminDB.system.version.update(
        {_id: "featureCompatibilityVersion"},
        {$set: {version: downgradeFCV, targetVersion: downgradeFCV, previousVersion: latestFCV}}));
    res = cmdAsInternalClient(cmd);
    assert.eq(res.minWireVersion, res.maxWireVersion, tojson(res));
    assert.eq(maxWireVersion, res.maxWireVersion, tojson(res));
    assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: downgradeFCV}));
    res = cmdAsInternalClient(cmd);
    assert.eq(downgradeWireVersion, res.minWireVersion, tojson(res));
    assert.eq(maxWireVersion, res.maxWireVersion, tojson(res));
    assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: latestFCV}));
    res = adminDB.runCommand({[cmd]: 1});
    assert.commandWorked(res);
    assert.eq(res.minWireVersion, 0, tojson(res));
    assert.lt(res.minWireVersion, res.maxWireVersion, tojson(res));
    assert.eq(maxWireVersion, res.maxWireVersion, tojson(res));
}
function runTest ( downgradeFCV , downgradeWireVersion , maxWireVersion , cmd ) { assert . commandWorked ( adminDB . system . version . update ( { _id : "featureCompatibilityVersion" } , { $set : { version : downgradeFCV , targetVersion : latestFCV } } ) ) ; let res = cmdAsInternalClient ( cmd ) ; assert . eq ( res . minWireVersion , res . maxWireVersion , tojson ( res ) ) ; assert . eq ( maxWireVersion , res . maxWireVersion , tojson ( res ) ) ; assert . commandWorked ( adminDB . system . version . update ( { _id : "featureCompatibilityVersion" } , { $set : { version : downgradeFCV , targetVersion : downgradeFCV , previousVersion : latestFCV } } ) ) ; res = cmdAsInternalClient ( cmd ) ; assert . eq ( res . minWireVersion , res . maxWireVersion , tojson ( res ) ) ; assert . eq ( maxWireVersion , res . maxWireVersion , tojson ( res ) ) ; assert . commandWorked ( adminDB . runCommand ( { setFeatureCompatibilityVersion : downgradeFCV } ) ) ; res = cmdAsInternalClient ( cmd ) ; assert . eq ( downgradeWireVersion , res . minWireVersion , tojson ( res ) ) ; assert . eq ( maxWireVersion , res . maxWireVersion , tojson ( res ) ) ; assert . commandWorked ( adminDB . runCommand ( { setFeatureCompatibilityVersion : latestFCV } ) ) ; res = adminDB . runCommand ( { [ cmd ] : 1 } ) ; assert . commandWorked ( res ) ; assert . eq ( res . minWireVersion , 0 , tojson ( res ) ) ; assert . lt ( res . minWireVersion , res . maxWireVersion , tojson ( res ) ) ; assert . eq ( maxWireVersion , res . maxWireVersion , tojson ( res ) ) ; }
Test wire version for upgrade/downgrade.
Test wire version for upgrade / downgrade .
// When the featureCompatibilityVersion is upgrading, running hello/isMaster with internalClient // returns a response with minWireVersion == maxWireVersion. // When the featureCompatibilityVersion is downgrading, running hello/isMaster with // internalClient returns a response with minWireVersion == maxWireVersion. // When the featureCompatibilityVersion is equal to the downgrade version, running // hello/isMaster with internalClient returns a response with minWireVersion + 1 == // maxWireVersion. // When the internalClient field is missing from the hello/isMaster command, the response // returns the full wire version range from minWireVersion == 0 to maxWireVersion == latest // version, even if the featureCompatibilityVersion is equal to the upgrade version.