jstests/replsets/tenant_migration_donor_interrupt_on_stepdown_and_shutdown.js
/**
 * Starts a migration and sets the passed in failpoint during the migration, then runs the
 * donorAbortMigration, and interrupts the donor using the 'interruptFunc', and verifies the command
 * response using the 'verifyCmdResponseFunc'.
 */
Starts a migration and sets the passed in failpoint during the migration, then runs the
donorAbortMigration, and interrupts the donor using the 'interruptFunc', and verifies the command
response using the 'verifyCmdResponseFunc'.
Starts a migration and sets the passed in failpoint during the migration then runs the donorAbortMigration and interrupts the donor using the ' interruptFunc ' and verifies the command response using the ' verifyCmdResponseFunc ' .
function testDonorAbortMigrationInterrupt(interruptFunc, verifyCmdResponseFunc, fpName) {
    const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
    const donorRst = tenantMigrationTest.getDonorRst();
    const donorPrimary = tenantMigrationTest.getDonorPrimary();
    if (TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
        jsTestLog("Skipping Shard Merge-incompatible test");
        tenantMigrationTest.stop();
        return;
    }
    const migrationId = UUID();
    const migrationOpts = {
        migrationIdString: extractUUIDFromObject(migrationId),
        tenantId: kTenantId,
        recipientConnString: tenantMigrationTest.getRecipientConnString(),
    };
    const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
    if (fpName) {
        configureFailPoint(donorPrimary, fpName);
    }
    assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts));
    const tryAbortThread = new Thread(TenantMigrationUtil.tryAbortMigrationAsync,
                                      {migrationIdString: migrationOpts.migrationIdString},
                                      donorRstArgs);
    tryAbortThread.start();
    assert.soon(() => {
        const res = assert.commandWorked(
            donorPrimary.adminCommand({currentOp: true, desc: "tenant donor migration"}));
        return res.inprog[0].receivedCancellation;
    });
    interruptFunc(donorRst, migrationId, migrationOpts.tenantId);
    verifyCmdResponseFunc(tryAbortThread);
    tenantMigrationTest.stop();
}
function testDonorAbortMigrationInterrupt ( interruptFunc , verifyCmdResponseFunc , fpName ) { const tenantMigrationTest = new TenantMigrationTest ( { name : jsTestName ( ) } ) ; const donorRst = tenantMigrationTest . getDonorRst ( ) ; const donorPrimary = tenantMigrationTest . getDonorPrimary ( ) ; if ( TenantMigrationUtil . isShardMergeEnabled ( donorPrimary . getDB ( "admin" ) ) ) { jsTestLog ( "Skipping Shard Merge-incompatible test" ) ; tenantMigrationTest . stop ( ) ; return ; } const migrationId = UUID ( ) ; const migrationOpts = { migrationIdString : extractUUIDFromObject ( migrationId ) , tenantId : kTenantId , recipientConnString : tenantMigrationTest . getRecipientConnString ( ) , } ; const donorRstArgs = TenantMigrationUtil . createRstArgs ( donorRst ) ; if ( fpName ) { configureFailPoint ( donorPrimary , fpName ) ; } assert . commandWorked ( tenantMigrationTest . startMigration ( migrationOpts ) ) ; const tryAbortThread = new Thread ( TenantMigrationUtil . tryAbortMigrationAsync , { migrationIdString : migrationOpts . migrationIdString } , donorRstArgs ) ; tryAbortThread . start ( ) ; assert . soon ( ( ) => { const res = assert . commandWorked ( donorPrimary . adminCommand ( { currentOp : true , desc : "tenant donor migration" } ) ) ; return res . inprog [ 0 ] . receivedCancellation ; } ) ; interruptFunc ( donorRst , migrationId , migrationOpts . tenantId ) ; verifyCmdResponseFunc ( tryAbortThread ) ; tenantMigrationTest . stop ( ) ; }
Starts a migration and sets the passed in failpoint during the migration, then runs the
 donorAbortMigration, and interrupts the donor using the 'interruptFunc', and verifies the command
 response using the 'verifyCmdResponseFunc'.
Starts a migration and sets the passed in failpoint during the migration then runs the donorAbortMigration and interrupts the donor using the ' interruptFunc ' and verifies the command response using the ' verifyCmdResponseFunc ' .
// TODO SERVER-63390: Remove this conditional and ensure test(s) run // successfully for shard merge. // If we passed in a valid failpoint we set it, otherwise we let the migration run normally. // Wait for donorAbortMigration command to start.