jstests/replsets/tenant_migration_recipient_rollback_recovery.js
/**
 * Starts a migration and waits for the recipient's primary to insert the recipient's state doc.
 * Forces the write to be rolled back. After the replication steady state is reached, asserts that
 * recipientSyncData can restart the migration on the new primary.
 */
Starts a migration and waits for the recipient's primary to insert the recipient's state doc.
Forces the write to be rolled back. After the replication steady state is reached, asserts that
recipientSyncData can restart the migration on the new primary.
Starts a migration and waits for the recipient ' s primary to insert the recipient ' s state doc . Forces the write to be rolled back . After the replication steady state is reached asserts that recipientSyncData can restart the migration on the new primary .
function testRollbackInitialState() {
    const migrationId = UUID();
    let migrationOpts;
    let migrationThread;
    let setUpFunc = (tenantMigrationTest, donorRstArgs) => {};
    let rollbackOpsFunc = (tenantMigrationTest, donorRstArgs) => {
        const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
        migrationOpts = makeMigrationOpts(tenantMigrationTest, migrationId, kTenantId + "-initial");
        migrationThread =
            new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
        migrationThread.start();
        assert.soon(() => {
            return 1 ===
                recipientPrimary.getCollection(TenantMigrationTest.kConfigRecipientsNS).count({
                    _id: migrationId
                });
        });
    };
    let steadyStateFunc = (tenantMigrationTest) => {
        TenantMigrationTest.assertCommitted(migrationThread.returnData());
        tenantMigrationTest.assertRecipientNodesInExpectedState(
            tenantMigrationTest.getRecipientRst().nodes,
            migrationId,
            migrationOpts.tenantId,
            TenantMigrationTest.RecipientState.kConsistent,
            TenantMigrationTest.RecipientAccessState.kRejectBefore);
        assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
    };
    testRollBack(setUpFunc, rollbackOpsFunc, steadyStateFunc);
}
function testRollbackInitialState ( ) { const migrationId = UUID ( ) ; let migrationOpts ; let migrationThread ; let setUpFunc = ( tenantMigrationTest , donorRstArgs ) => { } ; let rollbackOpsFunc = ( tenantMigrationTest , donorRstArgs ) => { const recipientPrimary = tenantMigrationTest . getRecipientPrimary ( ) ; migrationOpts = makeMigrationOpts ( tenantMigrationTest , migrationId , kTenantId + "-initial" ) ; migrationThread = new Thread ( TenantMigrationUtil . runMigrationAsync , migrationOpts , donorRstArgs ) ; migrationThread . start ( ) ; assert . soon ( ( ) => { return 1 === recipientPrimary . getCollection ( TenantMigrationTest . kConfigRecipientsNS ) . count ( { _id : migrationId } ) ; } ) ; } ; let steadyStateFunc = ( tenantMigrationTest ) => { TenantMigrationTest . assertCommitted ( migrationThread . returnData ( ) ) ; tenantMigrationTest . assertRecipientNodesInExpectedState ( tenantMigrationTest . getRecipientRst ( ) . nodes , migrationId , migrationOpts . tenantId , TenantMigrationTest . RecipientState . kConsistent , TenantMigrationTest . RecipientAccessState . kRejectBefore ) ; assert . commandWorked ( tenantMigrationTest . forgetMigration ( migrationOpts . migrationIdString ) ) ; } ; testRollBack ( setUpFunc , rollbackOpsFunc , steadyStateFunc ) ; }
Starts a migration and waits for the recipient's primary to insert the recipient's state doc.
Starts a migration and waits for the recipient ' s primary to insert the recipient ' s state doc .
// Start the migration asynchronously and wait for the primary to insert the state doc. // Verify that the migration restarted successfully on the new primary despite rollback.