jstests/replsets/tenant_migration_donor_rollback_recovery.js
/**
 * Starts a migration and forces the donor's primary to go through rollback after a random amount
 * of time. After the replication steady state is reached, asserts that the migration is resumed
 * successfully.
 */
Starts a migration and forces the donor's primary to go through rollback after a random amount
of time. After the replication steady state is reached, asserts that the migration is resumed
successfully.
Starts a migration and forces the donor ' s primary to go through rollback after a random amount of time . After the replication steady state is reached asserts that the migration is resumed successfully .
function testRollBackRandom() {
    const migrationId = UUID();
    const migrationOpts = makeMigrationOpts(migrationId, kTenantId + "-random");
    let migrationThread;
    let setUpFunc = (tenantMigrationTest, donorRstArgs) => {
        migrationThread = new Thread((donorRstArgs, migrationOpts) => {
            load("jstests/replsets/libs/tenant_migration_util.js");
            assert.commandWorked(TenantMigrationUtil.runMigrationAsync(
                migrationOpts, donorRstArgs, {retryOnRetryableErrors: true}));
            assert.commandWorked(TenantMigrationUtil.forgetMigrationAsync(
                migrationOpts.migrationIdString, donorRstArgs, true ));
        }, donorRstArgs, migrationOpts);
        migrationThread.start();
        sleep(Math.random() * kMaxSleepTimeMS);
    };
    let rollbackOpsFunc = (tenantMigrationTest, donorRstArgs) => {
        sleep(Math.random() * kMaxSleepTimeMS);
    };
    let steadyStateFunc = (tenantMigrationTest) => {
        migrationThread.join();
        tenantMigrationTest.waitForDonorNodesToReachState(
            tenantMigrationTest.getDonorRst().nodes,
            migrationId,
            migrationOpts.tenantId,
            TenantMigrationTest.DonorState.kCommitted);
        tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, migrationOpts.tenantId);
    };
    testRollBack(setUpFunc, rollbackOpsFunc, steadyStateFunc);
}
function testRollBackRandom ( ) { const migrationId = UUID ( ) ; const migrationOpts = makeMigrationOpts ( migrationId , kTenantId + "-random" ) ; let migrationThread ; let setUpFunc = ( tenantMigrationTest , donorRstArgs ) => { migrationThread = new Thread ( ( donorRstArgs , migrationOpts ) => { load ( "jstests/replsets/libs/tenant_migration_util.js" ) ; assert . commandWorked ( TenantMigrationUtil . runMigrationAsync ( migrationOpts , donorRstArgs , { retryOnRetryableErrors : true } ) ) ; assert . commandWorked ( TenantMigrationUtil . forgetMigrationAsync ( migrationOpts . migrationIdString , donorRstArgs , true ) ) ; } , donorRstArgs , migrationOpts ) ; migrationThread . start ( ) ; sleep ( Math . random ( ) * kMaxSleepTimeMS ) ; } ; let rollbackOpsFunc = ( tenantMigrationTest , donorRstArgs ) => { sleep ( Math . random ( ) * kMaxSleepTimeMS ) ; } ; let steadyStateFunc = ( tenantMigrationTest ) => { migrationThread . join ( ) ; tenantMigrationTest . waitForDonorNodesToReachState ( tenantMigrationTest . getDonorRst ( ) . nodes , migrationId , migrationOpts . tenantId , TenantMigrationTest . DonorState . kCommitted ) ; tenantMigrationTest . waitForMigrationGarbageCollection ( migrationId , migrationOpts . tenantId ) ; } ; testRollBack ( setUpFunc , rollbackOpsFunc , steadyStateFunc ) ; }
Starts a migration and forces the donor's primary to go through rollback after a random amount
 of time.
Starts a migration and forces the donor ' s primary to go through rollback after a random amount of time .
/* retryOnRetryableErrors */ // Start the migration and wait for a random amount of time before transitioning to the // rollback operations state. // Let the migration run in the rollback operations state for a random amount of time. // Verify that the migration completed and was garbage collected successfully despite the // rollback.