jstests/noPassthrough/libs/index_build.js
/**
     * Runs the resumable index build test specified by the provided failpoint information and
     * index spec on the provided replica set and namespace. This will specifically be used to test
     * that resuming an index build on a secondary works. Documents specified by sideWrites will be
     * inserted during the initialization phase so that they are inserted into the side writes
     * table and processed during the drain writes phase.
     */
Runs the resumable index build test specified by the provided failpoint information and
index spec on the provided replica set and namespace. This will specifically be used to test
that resuming an index build on a secondary works. Documents specified by sideWrites will be
inserted during the initialization phase so that they are inserted into the side writes
table and processed during the drain writes phase.
Runs the resumable index build test specified by the provided failpoint information and index spec on the provided replica set and namespace . This will specifically be used to test that resuming an index build on a secondary works . Documents specified by sideWrites will be inserted during the initialization phase so that they are inserted into the side writes table and processed during the drain writes phase .
static runOnSecondary(rst,
                          dbName,
                          collName,
                          indexSpec,
                          resumeNodeFailPointName,
                          resumeNodeFailPointIteration,
                          primaryFailPointName,
                          sideWrites = [],
                          postIndexBuildInserts = []) {
        const primary = rst.getPrimary();
        const coll = primary.getDB(dbName).getCollection(collName);
        const indexName = "resumable_index_build";
        const resumeNode = rst.getSecondary();
        const resumeNodeColl = resumeNode.getDB(dbName).getCollection(collName);
        const resumeNodeFp = configureFailPoint(resumeNode, "hangBeforeBuildingIndex");
        let primaryFp;
        if (primaryFailPointName) {
            primaryFp = configureFailPoint(primary, primaryFailPointName);
        }
        const awaitCreateIndex = ResumableIndexBuildTest.createIndexWithSideWrites(
            rst, function(collName, indexSpec, indexName) {
                assert.commandWorkedOrFailedWithCode(
                    db.getCollection(collName).createIndex(indexSpec, {name: indexName}),
                    ErrorCodes.InterruptedDueToReplStateChange);
            }, coll, indexSpec, indexName, sideWrites);
        resumeNodeFp.wait();
        const buildUUID = ResumableIndexBuildTest.restart(
            rst,
            resumeNode,
            resumeNodeColl,
            [[indexName]],
            [{name: resumeNodeFailPointName, useWaitForFailPointForSingleIndexBuild: true}],
            resumeNodeFailPointIteration,
            !primaryFp )[0];
        if (primaryFp) {
            primaryFp.off();
            ResumableIndexBuildTest.assertCompleted(
                resumeNode, resumeNodeColl, [buildUUID], [indexName]);
        }
        awaitCreateIndex();
        ResumableIndexBuildTest.checkIndexes(
            rst, dbName, collName, [indexName], postIndexBuildInserts);
    }
static runOnSecondary ( rst , dbName , collName , indexSpec , resumeNodeFailPointName , resumeNodeFailPointIteration , primaryFailPointName , sideWrites = [ ] , postIndexBuildInserts = [ ] ) { const primary = rst . getPrimary ( ) ; const coll = primary . getDB ( dbName ) . getCollection ( collName ) ; const indexName = "resumable_index_build" ; const resumeNode = rst . getSecondary ( ) ; const resumeNodeColl = resumeNode . getDB ( dbName ) . getCollection ( collName ) ; const resumeNodeFp = configureFailPoint ( resumeNode , "hangBeforeBuildingIndex" ) ; let primaryFp ; if ( primaryFailPointName ) { primaryFp = configureFailPoint ( primary , primaryFailPointName ) ; } const awaitCreateIndex = ResumableIndexBuildTest . createIndexWithSideWrites ( rst , function ( collName , indexSpec , indexName ) { assert . commandWorkedOrFailedWithCode ( db . getCollection ( collName ) . createIndex ( indexSpec , { name : indexName } ) , ErrorCodes . InterruptedDueToReplStateChange ) ; } , coll , indexSpec , indexName , sideWrites ) ; resumeNodeFp . wait ( ) ; const buildUUID = ResumableIndexBuildTest . restart ( rst , resumeNode , resumeNodeColl , [ [ indexName ] ] , [ { name : resumeNodeFailPointName , useWaitForFailPointForSingleIndexBuild : true } ] , resumeNodeFailPointIteration , ! primaryFp ) [ 0 ] ; if ( primaryFp ) { primaryFp . off ( ) ; ResumableIndexBuildTest . assertCompleted ( resumeNode , resumeNodeColl , [ buildUUID ] , [ indexName ] ) ; } awaitCreateIndex ( ) ; ResumableIndexBuildTest . checkIndexes ( rst , dbName , collName , [ indexName ] , postIndexBuildInserts ) ; }
Runs the resumable index build test specified by the provided failpoint information and
 index spec on the provided replica set and namespace.
Runs the resumable index build test specified by the provided failpoint information and index spec on the provided replica set and namespace .
// If the secondary is shutdown for too long, the primary will step down until it // can reach the secondary again. In this case, the index build will continue in the // background. // We should only check that the index build completes after a restart if the index build is // not paused on the primary. /* shouldComplete */ // Ensure that the index build was completed after unpausing the primary.