jstests/sharding/read_write_concern_defaults_commands_api.js
// Verifies the default responses for the default RWC commands and the default persisted state.
Verifies the default responses for the default RWC commands and the default persisted state.
Verifies the default responses for the default RWC commands and the default persisted state .
function verifyDefaultState(conn, isImplicitDefaultWCMajority) {
    const res = assert.commandWorked(conn.adminCommand({getDefaultRWConcern: 1}));
    const inMemoryRes =
        assert.commandWorked(conn.adminCommand({getDefaultRWConcern: 1, inMemory: true}));
    const expectedFields = ["localUpdateWallClockTime"];
    if (isImplicitDefaultWCMajority) {
        expectedFields.push("defaultWriteConcern");
    }
    expectedFields.push("defaultWriteConcernSource");
    expectedFields.push("defaultReadConcern");
    expectedFields.push("defaultReadConcernSource");
    expectedFields.forEach(field => {
        assert(res.hasOwnProperty(field),
               `response did not have field '${field}', res: ${tojson(res)}`);
        assert(inMemoryRes.hasOwnProperty(field),
               `inMemory=true response did not have field '${field}', res: ${tojson(inMemoryRes)}`);
    });
    assert.eq(inMemoryRes.inMemory, true, tojson(inMemoryRes));
    assert.eq(res.defaultWriteConcernSource, "implicit", tojson(res));
    assert.eq(inMemoryRes.defaultWriteConcernSource, "implicit", tojson(inMemoryRes));
    const unexpectedFields = ["updateOpTime", "updateWallClockTime"];
    if (!isImplicitDefaultWCMajority) {
        unexpectedFields.push("defaultWriteConcern");
    }
    unexpectedFields.forEach(field => {
        assert(!res.hasOwnProperty(field),
               `response unexpectedly had field '${field}', res: ${tojson(res)}`);
        assert(!inMemoryRes.hasOwnProperty(field),
               `inMemory=true response unexpectedly had field '${field}', res: ${
                   tojson(inMemoryRes)}`);
    });
    assert.eq(undefined, res.inMemory, tojson(res));
    assert.eq(null, getPersistedRWCDocument(conn));
}
function verifyDefaultState ( conn , isImplicitDefaultWCMajority ) { const res = assert . commandWorked ( conn . adminCommand ( { getDefaultRWConcern : 1 } ) ) ; const inMemoryRes = assert . commandWorked ( conn . adminCommand ( { getDefaultRWConcern : 1 , inMemory : true } ) ) ; const expectedFields = [ "localUpdateWallClockTime" ] ; if ( isImplicitDefaultWCMajority ) { expectedFields . push ( "defaultWriteConcern" ) ; } expectedFields . push ( "defaultWriteConcernSource" ) ; expectedFields . push ( "defaultReadConcern" ) ; expectedFields . push ( "defaultReadConcernSource" ) ; expectedFields . forEach ( field => { assert ( res . hasOwnProperty ( field ) , ` ${ field } ${ tojson ( res ) } ` ) ; assert ( inMemoryRes . hasOwnProperty ( field ) , ` ${ field } ${ tojson ( inMemoryRes ) } ` ) ; } ) ; assert . eq ( inMemoryRes . inMemory , true , tojson ( inMemoryRes ) ) ; assert . eq ( res . defaultWriteConcernSource , "implicit" , tojson ( res ) ) ; assert . eq ( inMemoryRes . defaultWriteConcernSource , "implicit" , tojson ( inMemoryRes ) ) ; const unexpectedFields = [ "updateOpTime" , "updateWallClockTime" ] ; if ( ! isImplicitDefaultWCMajority ) { unexpectedFields . push ( "defaultWriteConcern" ) ; } unexpectedFields . forEach ( field => { assert ( ! res . hasOwnProperty ( field ) , ` ${ field } ${ tojson ( res ) } ` ) ; assert ( ! inMemoryRes . hasOwnProperty ( field ) , ` ${ field } ${ tojson ( inMemoryRes ) } ` ) ; } ) ; assert . eq ( undefined , res . inMemory , tojson ( res ) ) ; assert . eq ( null , getPersistedRWCDocument ( conn ) ) ; }
Verifies the default responses for the default RWC commands and the default persisted state.
Verifies the default responses for the default RWC commands and the default persisted state .
// localUpdateWallClockTime is set when a node refreshes its defaults, even if none are found. // No other fields should be returned if neither a default read nor write concern has been set. // There should be no default RWC document.