jstests/replsets/split_horizon_startup_warning.js
// disableSplitHorizonIPCheck is required to prevent crashing when the bad config is initially set.
disableSplitHorizonIPCheck is required to prevent crashing when the bad config is initially set.
disableSplitHorizonIPCheck is required to prevent crashing when the bad config is initially set .
function testStartupWarnings(horizonName, options = {}) {
    jsTestLog("Running startupWarning check.");
    const includesStartupWarning = (line) =>
        line.includes("Found split horizon configuration using IP");
    const replTest = new ReplSetTest({
        nodes: 1,
        nodeOptions: Object.assign({setParameter: {disableSplitHorizonIPCheck: true}}, options)
    });
    replTest.startSet();
    replTest.initiate();
    let replPrimary = replTest.getPrimary();
    let testDB = replPrimary.getDB("test");
    let startupWarnings = assert.commandWorked(testDB.adminCommand({getLog: "startupWarnings"}));
    jsTestLog("First-time startupWarnings:\n" + tojson(startupWarnings));
    assert(!startupWarnings.log.some(includesStartupWarning));
    const rsConfig = replTest.getReplSetConfig();
    for (let i = 0; i < rsConfig.members.length; i++) {
        rsConfig.members[i].horizons = {horizon_name: horizonName};
    }
    jsTestLog(rsConfig);
    rsConfig["version"] = 2;
    assert.commandWorked(replPrimary.adminCommand({replSetReconfig: rsConfig}));
    replTest.restart(replPrimary);
    replPrimary = replTest.getPrimary();
    testDB = replPrimary.getDB("test");
    startupWarnings = assert.commandWorked(testDB.adminCommand({getLog: "startupWarnings"}));
    jsTestLog("Post-restart startupWarnings:\n" + tojson(startupWarnings));
    assert(startupWarnings.log.some(includesStartupWarning));
    replTest.stopSet();
}
function testStartupWarnings ( horizonName , options = { } ) { jsTestLog ( "Running startupWarning check." ) ; const includesStartupWarning = ( line ) => line . includes ( "Found split horizon configuration using IP" ) ; const replTest = new ReplSetTest ( { nodes : 1 , nodeOptions : Object . assign ( { setParameter : { disableSplitHorizonIPCheck : true } } , options ) } ) ; replTest . startSet ( ) ; replTest . initiate ( ) ; let replPrimary = replTest . getPrimary ( ) ; let testDB = replPrimary . getDB ( "test" ) ; let startupWarnings = assert . commandWorked ( testDB . adminCommand ( { getLog : "startupWarnings" } ) ) ; jsTestLog ( "First-time startupWarnings:\n" + tojson ( startupWarnings ) ) ; assert ( ! startupWarnings . log . some ( includesStartupWarning ) ) ; const rsConfig = replTest . getReplSetConfig ( ) ; for ( let i = 0 ; i < rsConfig . members . length ; i ++ ) { rsConfig . members [ i ] . horizons = { horizon_name : horizonName } ; } jsTestLog ( rsConfig ) ; rsConfig [ "version" ] = 2 ; assert . commandWorked ( replPrimary . adminCommand ( { replSetReconfig : rsConfig } ) ) ; replTest . restart ( replPrimary ) ; replPrimary = replTest . getPrimary ( ) ; testDB = replPrimary . getDB ( "test" ) ; startupWarnings = assert . commandWorked ( testDB . adminCommand ( { getLog : "startupWarnings" } ) ) ; jsTestLog ( "Post-restart startupWarnings:\n" + tojson ( startupWarnings ) ) ; assert ( startupWarnings . log . some ( includesStartupWarning ) ) ; replTest . stopSet ( ) ; }
disableSplitHorizonIPCheck is required to prevent crashing when the bad config is initially set.
disableSplitHorizonIPCheck is required to prevent crashing when the bad config is initially set .
// Start an initial Replica Set with no SplitHorizon configuration // Ensure that the startup warning is not issued if the SplitHorizon configuration is normal // Restart the replset