jstests/noPassthroughWithMongod/fcv_changes_close_connections.js
// Mimic running a find command from an internal client with a lower binary version.
Mimic running a find command from an internal client with a lower binary version.
Mimic running a find command from an internal client with a lower binary version .
function findWithLowerBinaryInternalClient(expectConnectionClosed) {
        const testDB = db.getSiblingDB("test");
         The 'hello' command below will succeed because this is run through the shell and the
         shell is always compatible talking to the server. In reality though, a real internal
         client with a lower binary version is expected to hang up immediately after receiving the
         response to the 'hello' command from a latest server with an upgraded FCV.
        assert.commandWorked(testDB.adminCommand({
            hello: 1,
            internalClient: {minWireVersion: NumberInt(9), maxWireVersion: NumberInt(9)}
        }));
         Since mongod expects other cluster members to always include explicit read/write concern
         (on commands that accept read/write concern), this test must be careful to mimic this
         behavior.
        if (expectConnectionClosed) {
            const e = assert.throws(
                () => testDB.runCommand({find: "coll", readConcern: {level: "local"}}));
            assert.includes(e.toString(), "network error while attempting to run command");
        } else {
            assert.commandWorked(testDB.runCommand({find: "coll", readConcern: {level: "local"}}));
        }
    }
function findWithLowerBinaryInternalClient ( expectConnectionClosed ) { const testDB = db . getSiblingDB ( "test" ) ; assert . commandWorked ( testDB . adminCommand ( { hello : 1 , internalClient : { minWireVersion : NumberInt ( 9 ) , maxWireVersion : NumberInt ( 9 ) } } ) ) ; if ( expectConnectionClosed ) { const e = assert . throws ( ( ) => testDB . runCommand ( { find : "coll" , readConcern : { level : "local" } } ) ) ; assert . includes ( e . toString ( ) , "network error while attempting to run command" ) ; } else { assert . commandWorked ( testDB . runCommand ( { find : "coll" , readConcern : { level : "local" } } ) ) ; } }
Mimic running a find command from an internal client with a lower binary version.
Mimic running a find command from an internal client with a lower binary version .
// The value of the 'internalClient.maxWireVersion' does not matter for the purpose of this // test as long as it is less than the latest server's maxWireVersion. The server will tag // this connection as an internal client connection with a lower binary version on receiving // a 'hello' with 'internalClient.maxWireVersion' less than the server's maxWireVersion. // Connections with such a tag are closed by the server on certain FCV changes. // // The 'hello' command below will succeed because this is run through the shell and the // shell is always compatible talking to the server. In reality though, a real internal // client with a lower binary version is expected to hang up immediately after receiving the // response to the 'hello' command from a latest server with an upgraded FCV. // Since mongod expects other cluster members to always include explicit read/write concern // (on commands that accept read/write concern), this test must be careful to mimic this // behavior.