jstests/noPassthrough/libs/index_build.js
/**
     * Runs a resumable index build test on the specified namespace, starting it on the 'rst'
     * replica set and resuming it in the 'upg' replica set, which could be a different binary
     * version.
     *
     * 'indexSpecs' is a 2d array that specifies all indexes that should be built. The first
     *   dimension indicates separate calls to the createIndexes command, while the second
     *   dimension is for indexes that are built together using one call to createIndexes.
     *
     * 'failPoints' is an array of objects that contain two fields: 'name', which specifies the
     *   name of the failpoint, and exactly one of 'logIdWithBuildUUID' and 'logIdWithIndexName'.
     *   The former is used for failpoints whose log message includes the build UUID, and the
     *   latter is used for failpoints whose log message includes the index name. The array must
     *   either contain one element, in which case that one element will be applied to all index
     *   builds specified above, or it must be exactly the length of 'indexSpecs'.
     *
     * 'failPointsIteration' is an integer value used as the 'iteration' field in the failpoint
     *   data for every failpoint specified above.
     *
     * 'expectedResumePhases' is an array of strings that specify the name of the phases that each
     *   index build is expected to resume in. The array must either contain one string, in which
     *   case all index builds will be expected to resume from that phase, or it must be exactly
     *   the length of 'indexSpecs'.
     *
     * 'resumeChecks' is an array of objects that contain exactly one of 'numScannedAfterResume' and
     *   'skippedPhaseLogID'. The former is used to verify that the index build scanned the
     *   expected number of documents in the collection scan after resuming. The latter is used for
     *   phases which do not perform a collection scan after resuming, to verify that the index
     *   index build did not resume from an earlier phase than expected. The log message must
     *   contain the buildUUID attribute.
     *
     * 'sideWrites' is an array of documents inserted during the initialization phase so that they
     *   are inserted into the side writes table and processed during the drain writes phase.
     *
     * 'postIndexBuildInserts' is an array of documents inserted after the index builds have
     *   completed.
     */
Runs a resumable index build test on the specified namespace, starting it on the 'rst'
replica set and resuming it in the 'upg' replica set, which could be a different binary
version.

'indexSpecs' is a 2d array that specifies all indexes that should be built. The first
dimension indicates separate calls to the createIndexes command, while the second
dimension is for indexes that are built together using one call to createIndexes.



'failPointsIteration' is an integer value used as the 'iteration' field in the failpoint
data for every failpoint specified above.

'expectedResumePhases' is an array of strings that specify the name of the phases that each
index build is expected to resume in. The array must either contain one string, in which
case all index builds will be expected to resume from that phase, or it must be exactly
the length of 'indexSpecs'.



'sideWrites' is an array of documents inserted during the initialization phase so that they
are inserted into the side writes table and processed during the drain writes phase.

'postIndexBuildInserts' is an array of documents inserted after the index builds have
completed.
Runs a resumable index build test on the specified namespace starting it on the ' rst ' replica set and resuming it in the ' upg ' replica set which could be a different binary version . ' indexSpecs ' is a 2d array that specifies all indexes that should be built . The first dimension indicates separate calls to the createIndexes command while the second dimension is for indexes that are built together using one call to createIndexes . ' failPointsIteration ' is an integer value used as the ' iteration ' field in the failpoint data for every failpoint specified above . ' expectedResumePhases ' is an array of strings that specify the name of the phases that each index build is expected to resume in . The array must either contain one string in which case all index builds will be expected to resume from that phase or it must be exactly the length of ' indexSpecs ' . ' sideWrites ' is an array of documents inserted during the initialization phase so that they are inserted into the side writes table and processed during the drain writes phase . ' postIndexBuildInserts ' is an array of documents inserted after the index builds have completed .
static runAndUpgrade(rst,
                         upg,
                         dbName,
                         collName,
                         indexSpecs,
                         failPoints,
                         failPointsIteration,
                         expectedResumePhases,
                         resumeChecks,
                         sideWrites = [],
                         postIndexBuildInserts = [],
                         restartOptions) {
        const primary = rst.getPrimary();
        const coll = primary.getDB(dbName).getCollection(collName);
        const indexNames = ResumableIndexBuildTest.generateIndexNames(indexSpecs);
        const awaitCreateIndexes = ResumableIndexBuildTest.createIndexesWithSideWrites(
            rst, function(collName, indexSpecs, indexNames) {
                load("jstests/noPassthrough/libs/index_build.js");
                ResumableIndexBuildTest.createIndexesFails(db, collName, indexSpecs, indexNames);
            }, coll, indexSpecs, indexNames, sideWrites, {hangBeforeBuildingIndex: true});
        const buildUUIDs = ResumableIndexBuildTest.restartWithUpgrade(rst,
                                                                      upg,
                                                                      primary,
                                                                      coll,
                                                                      indexNames,
                                                                      failPoints,
                                                                      failPointsIteration,
                                                                      true,
                                                                      undefined,
                                                                      undefined,
                                                                      restartOptions);
        for (const awaitCreateIndex of awaitCreateIndexes) {
            awaitCreateIndex();
        }
        ResumableIndexBuildTest.checkResume(
            primary, buildUUIDs, expectedResumePhases, resumeChecks);
        ResumableIndexBuildTest.checkIndexes(
            rst, dbName, collName, indexNames, postIndexBuildInserts);
    }
static runAndUpgrade ( rst , upg , dbName , collName , indexSpecs , failPoints , failPointsIteration , expectedResumePhases , resumeChecks , sideWrites = [ ] , postIndexBuildInserts = [ ] , restartOptions ) { const primary = rst . getPrimary ( ) ; const coll = primary . getDB ( dbName ) . getCollection ( collName ) ; const indexNames = ResumableIndexBuildTest . generateIndexNames ( indexSpecs ) ; const awaitCreateIndexes = ResumableIndexBuildTest . createIndexesWithSideWrites ( rst , function ( collName , indexSpecs , indexNames ) { load ( "jstests/noPassthrough/libs/index_build.js" ) ; ResumableIndexBuildTest . createIndexesFails ( db , collName , indexSpecs , indexNames ) ; } , coll , indexSpecs , indexNames , sideWrites , { hangBeforeBuildingIndex : true } ) ; const buildUUIDs = ResumableIndexBuildTest . restartWithUpgrade ( rst , upg , primary , coll , indexNames , failPoints , failPointsIteration , true , undefined , undefined , restartOptions ) ; for ( const awaitCreateIndex of awaitCreateIndexes ) { awaitCreateIndex ( ) ; } ResumableIndexBuildTest . checkResume ( primary , buildUUIDs , expectedResumePhases , resumeChecks ) ; ResumableIndexBuildTest . checkIndexes ( rst , dbName , collName , indexNames , postIndexBuildInserts ) ; }
Runs a resumable index build test on the specified namespace, starting it on the 'rst'
 replica set and resuming it in the 'upg' replica set, which could be a different binary
 version.
Runs a resumable index build test on the specified namespace starting it on the ' rst ' replica set and resuming it in the ' upg ' replica set which could be a different binary version .