jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js
/**
 * Tests that the recipient starts rejecting all reads after cloning is done.
 */
Tests that the recipient starts rejecting all reads after cloning is done.
Tests that the recipient starts rejecting all reads after cloning is done .
function testRejectAllReadsAfterCloningDone({testCase, dbName, collName, tenantMigrationTest}) {
    const tenantId = dbName.split('_')[0];
    const migrationOpts = {
        migrationIdString: extractUUIDFromObject(UUID()),
        tenantId,
        recipientConnString: tenantMigrationTest.getRecipientConnString(),
    };
    const donorRst = tenantMigrationTest.getDonorRst();
    const recipientRst = tenantMigrationTest.getRecipientRst();
    const recipientPrimary = recipientRst.getPrimary();
    let beforeFetchingTransactionsFp = configureFailPoint(
        recipientPrimary, "fpBeforeFetchingCommittedTransactions", {action: "hang"});
    const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
    const runMigrationThread =
        new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
    runMigrationThread.start();
    beforeFetchingTransactionsFp.wait();
    recipientRst.awaitReplication();
    const nodes = testCase.isSupportedOnSecondaries ? recipientRst.nodes : [recipientPrimary];
    nodes.forEach(node => {
        const command = testCase.requiresReadTimestamp
            ? testCase.command(collName, getLastOpTime(node).ts)
            : testCase.command(collName);
        const db = node.getDB(dbName);
        runCommand(db, command, ErrorCodes.SnapshotTooOld);
    });
    beforeFetchingTransactionsFp.off();
    TenantMigrationTest.assertCommitted(runMigrationThread.returnData());
    assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
    tenantMigrationTest.waitForMigrationGarbageCollection(migrationOpts.migrationIdString);
}
function testRejectAllReadsAfterCloningDone ( { testCase , dbName , collName , tenantMigrationTest } ) { const tenantId = dbName . split ( '_' ) [ 0 ] ; const migrationOpts = { migrationIdString : extractUUIDFromObject ( UUID ( ) ) , tenantId , recipientConnString : tenantMigrationTest . getRecipientConnString ( ) , } ; const donorRst = tenantMigrationTest . getDonorRst ( ) ; const recipientRst = tenantMigrationTest . getRecipientRst ( ) ; const recipientPrimary = recipientRst . getPrimary ( ) ; let beforeFetchingTransactionsFp = configureFailPoint ( recipientPrimary , "fpBeforeFetchingCommittedTransactions" , { action : "hang" } ) ; const donorRstArgs = TenantMigrationUtil . createRstArgs ( donorRst ) ; const runMigrationThread = new Thread ( TenantMigrationUtil . runMigrationAsync , migrationOpts , donorRstArgs ) ; runMigrationThread . start ( ) ; beforeFetchingTransactionsFp . wait ( ) ; recipientRst . awaitReplication ( ) ; const nodes = testCase . isSupportedOnSecondaries ? recipientRst . nodes : [ recipientPrimary ] ; nodes . forEach ( node => { const command = testCase . requiresReadTimestamp ? testCase . command ( collName , getLastOpTime ( node ) . ts ) : testCase . command ( collName ) ; const db = node . getDB ( dbName ) ; runCommand ( db , command , ErrorCodes . SnapshotTooOld ) ; } ) ; beforeFetchingTransactionsFp . off ( ) ; TenantMigrationTest . assertCommitted ( runMigrationThread . returnData ( ) ) ; assert . commandWorked ( tenantMigrationTest . forgetMigration ( migrationOpts . migrationIdString ) ) ; tenantMigrationTest . waitForMigrationGarbageCollection ( migrationOpts . migrationIdString ) ; }
Tests that the recipient starts rejecting all reads after cloning is done.
Tests that the recipient starts rejecting all reads after cloning is done .
// Wait for the write to mark cloning as done to be replicated to all nodes.