jstests/noPassthrough/libs/index_build.js
/**
     * Runs createIndexFn in a parellel shell to create indexes, inserting the documents specified
     * by sideWrites into the side writes table.
     *
     * 'createIndexFn' should take three parameters: collection name, index specifications, and
     *   index names.
     *
     * 'indexNames' should follow the exact same format as 'indexSpecs'. For example, if indexSpecs
     *   is [[{a: 1}, {b: 1}], [{c: 1}]], a valid indexNames would look like
     *   [["index_1", "index_2"], ["index_3"]].
     *
     * If {hangBeforeBuildingIndex: true}, returns with the hangBeforeBuildingIndex failpoint
     * enabled and the index builds hanging at this point.
     */
Runs createIndexFn in a parellel shell to create indexes, inserting the documents specified
by sideWrites into the side writes table.

'createIndexFn' should take three parameters: collection name, index specifications, and
index names.

'indexNames' should follow the exact same format as 'indexSpecs'.

If {hangBeforeBuildingIndex: true}, returns with the hangBeforeBuildingIndex failpoint
enabled and the index builds hanging at this point.
Runs createIndexFn in a parellel shell to create indexes inserting the documents specified by sideWrites into the side writes table . ' createIndexFn ' should take three parameters : collection name index specifications and index names . ' indexNames ' should follow the exact same format as ' indexSpecs ' . If { hangBeforeBuildingIndex : true } returns with the hangBeforeBuildingIndex failpoint enabled and the index builds hanging at this point .
static createIndexesWithSideWrites(test,
                                       createIndexesFn,
                                       coll,
                                       indexSpecs,
                                       indexNames,
                                       sideWrites,
                                       {hangBeforeBuildingIndex} = {
                                           hangBeforeBuildingIndex: false
                                       }) {
        const primary = test.getPrimary();
        const fp = configureFailPoint(primary, "hangBeforeBuildingIndex");
        const awaitCreateIndexes = new Array(indexSpecs.length);
        for (let i = 0; i < indexSpecs.length; i++) {
            awaitCreateIndexes[i] = startParallelShell(
                funWithArgs(createIndexesFn, coll.getName(), indexSpecs[i], indexNames[i]),
                primary.port);
        }
        const indexNamesFlat = ResumableIndexBuildTest.flatten(indexNames);
        let indexes;
        assert.soonNoExcept(function() {
            indexes = IndexBuildTest.assertIndexesIdHelper(
                coll, indexNamesFlat.length, [], indexNamesFlat, {includeBuildUUIDs: true});
            return true;
        });
        for (const indexName of indexNamesFlat) {
            checkLog.containsJson(primary, 4940900, {
                buildUUID: function(uuid) {
                    return uuid["uuid"]["$uuid"] ===
                        extractUUIDFromObject(indexes[indexName].buildUUID);
                }
            });
        }
        assert.commandWorked(coll.insert(sideWrites));
        test.awaitLastOpCommitted();
        if (!hangBeforeBuildingIndex)
            fp.off();
        return awaitCreateIndexes;
    }
static createIndexesWithSideWrites ( test , createIndexesFn , coll , indexSpecs , indexNames , sideWrites , { hangBeforeBuildingIndex } = { hangBeforeBuildingIndex : false } ) { const primary = test . getPrimary ( ) ; const fp = configureFailPoint ( primary , "hangBeforeBuildingIndex" ) ; const awaitCreateIndexes = new Array ( indexSpecs . length ) ; for ( let i = 0 ; i < indexSpecs . length ; i ++ ) { awaitCreateIndexes [ i ] = startParallelShell ( funWithArgs ( createIndexesFn , coll . getName ( ) , indexSpecs [ i ] , indexNames [ i ] ) , primary . port ) ; } const indexNamesFlat = ResumableIndexBuildTest . flatten ( indexNames ) ; let indexes ; assert . soonNoExcept ( function ( ) { indexes = IndexBuildTest . assertIndexesIdHelper ( coll , indexNamesFlat . length , [ ] , indexNamesFlat , { includeBuildUUIDs : true } ) ; return true ; } ) ; for ( const indexName of indexNamesFlat ) { checkLog . containsJson ( primary , 4940900 , { buildUUID : function ( uuid ) { return uuid [ "uuid" ] [ "$uuid" ] === extractUUIDFromObject ( indexes [ indexName ] . buildUUID ) ; } } ) ; } assert . commandWorked ( coll . insert ( sideWrites ) ) ; test . awaitLastOpCommitted ( ) ; if ( ! hangBeforeBuildingIndex ) fp . off ( ) ; return awaitCreateIndexes ; }
Runs createIndexFn in a parellel shell to create indexes, inserting the documents specified
 by sideWrites into the side writes table.
Runs createIndexFn in a parellel shell to create indexes inserting the documents specified by sideWrites into the side writes table .
// Wait for the index builds to be registered so that they can be recognized using their // build UUIDs. // Wait for the index builds to reach the hangBeforeBuildingIndex failpoint. // Before building the index, wait for the the last op to be committed so that establishing // the majority read cursor does not race with step down.