jstests/noPassthrough/index_killop_standalone.js
// Test that building an index with 'options' can be aborted using killop.
Test that building an index with 'options' can be aborted using killop.
Test that building an index with ' options ' can be aborted using killop .
function testAbortIndexBuild(options) {
    IndexBuildTest.pauseIndexBuilds(conn);
    const createIdx = IndexBuildTest.startIndexBuild(conn, coll.getFullName(), {a: 1}, options);
    const opId = IndexBuildTest.waitForIndexBuildToScanCollection(testDB, coll.getName(), 'a_1');
    assert.commandWorked(testDB.killOp(opId));
    try {
        IndexBuildTest.waitForIndexBuildToStop(testDB);
    } finally {
        IndexBuildTest.resumeIndexBuilds(conn);
    }
    const exitCode = createIdx({checkExitSuccess: false});
    assert.neq(
        0, exitCode, 'expected shell to exit abnormally due to index build being terminated');
    IndexBuildTest.assertIndexes(coll, 1, ['_id_']);
}
function testAbortIndexBuild ( options ) { IndexBuildTest . pauseIndexBuilds ( conn ) ; const createIdx = IndexBuildTest . startIndexBuild ( conn , coll . getFullName ( ) , { a : 1 } , options ) ; const opId = IndexBuildTest . waitForIndexBuildToScanCollection ( testDB , coll . getName ( ) , 'a_1' ) ; assert . commandWorked ( testDB . killOp ( opId ) ) ; try { IndexBuildTest . waitForIndexBuildToStop ( testDB ) ; } finally { IndexBuildTest . resumeIndexBuilds ( conn ) ; } const exitCode = createIdx ( { checkExitSuccess : false } ) ; assert . neq ( 0 , exitCode , 'expected shell to exit abnormally due to index build being terminated' ) ; IndexBuildTest . assertIndexes ( coll , 1 , [ '_id_' ] ) ; }
Test that building an index with 'options' can be aborted using killop.
Test that building an index with ' options ' can be aborted using killop .
// When the index build starts, find its op id. // Kill the index build. // Wait for the index build to stop. // Check that no new index has been created.  This verifies that the index build was aborted // rather than successfully completed.