jstests/noPassthrough/list_indexes_index_build_info.js
/**
 * Given two listIndexes command results, the first without index build info included and the second
 * with, ensures that ready and in-progress indexes are formatted correctly in each output.
 */
Given two listIndexes command results, the first without index build info included and the second
with, ensures that ready and in-progress indexes are formatted correctly in each output.
Given two listIndexes command results the first without index build info included and the second with ensures that ready and in - progress indexes are formatted correctly in each output .
function assertListIndexesOutputsMatch(
    withoutBuildInfo, withBuildInfo, readyIndexNames, buildingIndexNames) {
    const allIndexNames = readyIndexNames.concat(buildingIndexNames);
    assert.eq(
        withoutBuildInfo.map(i => i.name).sort(),
        allIndexNames.sort(),
        "Expected indexes do not match returned indexes in withoutBuildInfo: Expected names: " +
            tojson(allIndexNames) + ", withoutBuildInfo: " + tojson(withoutBuildInfo));
    assert.eq(withBuildInfo.map(i => i.spec.name).sort(),
              allIndexNames.sort(),
              "Expected indexes do not match returned indexes in withBuildInfo: Expected names: " +
                  tojson(allIndexNames) + ", withBuildInfo: " + tojson(withBuildInfo));
    for (let i = 0; i < withBuildInfo.length; i++) {
        assert.eq(
            withoutBuildInfo[i],
            withBuildInfo[i].spec,
            "Expected withBuildInfo spec to contain the same information as withoutBuildInfo: withoutBuildInfo result: " +
                tojson(withoutBuildInfo[i]) +
                ", withBuildInfo result: " + tojson(withBuildInfo[i]));
        if (readyIndexNames.includes(withBuildInfo[i].spec.name)) {
            assert(!withBuildInfo[i].hasOwnProperty('indexBuildInfo'),
                   "Index expected to be done building had indexBuildInfo: " +
                       tojson(withBuildInfo[i]));
        } else {
            assert(withBuildInfo[i].hasOwnProperty('indexBuildInfo'),
                   "Index expected to be in-progress building did not have indexBuildInfo: " +
                       tojson(withBuildInfo[i]));
            assert(
                withBuildInfo[i].indexBuildInfo.hasOwnProperty('buildUUID'),
                "Index expected to be in-progress building did not have indexBuildInfo.buildUUID: " +
                    tojson(withBuildInfo[i]));
        }
    }
}
function assertListIndexesOutputsMatch ( withoutBuildInfo , withBuildInfo , readyIndexNames , buildingIndexNames ) { const allIndexNames = readyIndexNames . concat ( buildingIndexNames ) ; assert . eq ( withoutBuildInfo . map ( i => i . name ) . sort ( ) , allIndexNames . sort ( ) , "Expected indexes do not match returned indexes in withoutBuildInfo: Expected names: " + tojson ( allIndexNames ) + ", withoutBuildInfo: " + tojson ( withoutBuildInfo ) ) ; assert . eq ( withBuildInfo . map ( i => i . spec . name ) . sort ( ) , allIndexNames . sort ( ) , "Expected indexes do not match returned indexes in withBuildInfo: Expected names: " + tojson ( allIndexNames ) + ", withBuildInfo: " + tojson ( withBuildInfo ) ) ; for ( let i = 0 ; i < withBuildInfo . length ; i ++ ) { assert . eq ( withoutBuildInfo [ i ] , withBuildInfo [ i ] . spec , "Expected withBuildInfo spec to contain the same information as withoutBuildInfo: withoutBuildInfo result: " + tojson ( withoutBuildInfo [ i ] ) + ", withBuildInfo result: " + tojson ( withBuildInfo [ i ] ) ) ; if ( readyIndexNames . includes ( withBuildInfo [ i ] . spec . name ) ) { assert ( ! withBuildInfo [ i ] . hasOwnProperty ( 'indexBuildInfo' ) , "Index expected to be done building had indexBuildInfo: " + tojson ( withBuildInfo [ i ] ) ) ; } else { assert ( withBuildInfo [ i ] . hasOwnProperty ( 'indexBuildInfo' ) , "Index expected to be in-progress building did not have indexBuildInfo: " + tojson ( withBuildInfo [ i ] ) ) ; assert ( withBuildInfo [ i ] . indexBuildInfo . hasOwnProperty ( 'buildUUID' ) , "Index expected to be in-progress building did not have indexBuildInfo.buildUUID: " + tojson ( withBuildInfo [ i ] ) ) ; } } }
Given two listIndexes command results, the first without index build info included and the second
 with, ensures that ready and in-progress indexes are formatted correctly in each output.
Given two listIndexes command results the first without index build info included and the second with ensures that ready and in - progress indexes are formatted correctly in each output .
// Index is done, no indexBuildInfo // Index building, should have indexBuildInfo.buildUUID