jstests/replsets/tenant_migration_donor_interrupt_on_stepdown_and_shutdown.js
/**
 * Starts a migration and waits for it to commit, then runs the donorForgetMigration, and interrupts
 * the donor using the 'interruptFunc', and verifies the command response using the
 * 'verifyCmdResponseFunc'.
 */
Starts a migration and waits for it to commit, then runs the donorForgetMigration, and interrupts
the donor using the 'interruptFunc', and verifies the command response using the
'verifyCmdResponseFunc'.
Starts a migration and waits for it to commit then runs the donorForgetMigration and interrupts the donor using the ' interruptFunc ' and verifies the command response using the ' verifyCmdResponseFunc ' .
function testDonorForgetMigrationInterrupt(interruptFunc, verifyCmdResponseFunc) {
    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);
    TenantMigrationTest.assertCommitted(
        tenantMigrationTest.runMigration(migrationOpts, {automaticForgetMigration: false}));
    const forgetMigrationThread = new Thread(
        TenantMigrationUtil.forgetMigrationAsync, migrationOpts.migrationIdString, donorRstArgs);
    forgetMigrationThread.start();
    assert.soon(() => {
        const res = assert.commandWorked(
            donorPrimary.adminCommand({currentOp: true, desc: "tenant donor migration"}));
        return res.inprog[0].expireAt != null;
    });
    sleep(Math.random() * kMaxSleepTimeMS);
    interruptFunc(donorRst, migrationId, migrationOpts.tenantId);
    verifyCmdResponseFunc(forgetMigrationThread);
    tenantMigrationTest.stop();
}
function testDonorForgetMigrationInterrupt ( interruptFunc , verifyCmdResponseFunc ) { 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 ) ; TenantMigrationTest . assertCommitted ( tenantMigrationTest . runMigration ( migrationOpts , { automaticForgetMigration : false } ) ) ; const forgetMigrationThread = new Thread ( TenantMigrationUtil . forgetMigrationAsync , migrationOpts . migrationIdString , donorRstArgs ) ; forgetMigrationThread . start ( ) ; assert . soon ( ( ) => { const res = assert . commandWorked ( donorPrimary . adminCommand ( { currentOp : true , desc : "tenant donor migration" } ) ) ; return res . inprog [ 0 ] . expireAt != null ; } ) ; sleep ( Math . random ( ) * kMaxSleepTimeMS ) ; interruptFunc ( donorRst , migrationId , migrationOpts . tenantId ) ; verifyCmdResponseFunc ( forgetMigrationThread ) ; tenantMigrationTest . stop ( ) ; }
Starts a migration and waits for it to commit, then runs the donorForgetMigration, and interrupts
 the donor using the 'interruptFunc', and verifies the command response using the
 'verifyCmdResponseFunc'.
Starts a migration and waits for it to commit then runs the donorForgetMigration 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. // Wait for the donorForgetMigration command to start.