jstests/serverless/tenant_migration_concurrent_bulk_writes_against_mongoq.js
/*
 * Test running a migration and then try to do an unordered/ordered once the migration has aborted.
 * Since the migration did not happen and was aborted, the bulk insert should succeed.
 */
Test running a migration and then try to do an unordered/ordered once the migration has aborted.
Since the migration did not happen and was aborted, the bulk insert should succeed.
Test running a migration and then try to do an unordered / ordered once the migration has aborted . Since the migration did not happen and was aborted the bulk insert should succeed .
function orderedBulkInsertAfterTenantMigrationAborted(st, isBulkWriteOrdered) {
    let titleOrderedStr = "Starting test - " + (isBulkWriteOrdered ? "ordered" : "unordered");
    jsTest.log(titleOrderedStr + " bulk insert after the migration has aborted.");
    const tenantID = ObjectId();
    const kDbName = tenantID.str + "_test";
    let adminDB = st.rs0.getPrimary().getDB('admin');
    const kCollName = 'foo';
    assert.commandWorked(st.q0.adminCommand({enableSharding: kDbName}));
    st.ensurePrimaryShard(kDbName, st.shard0.shardName);
    configureFailPoint(adminDB, "abortTenantMigrationBeforeLeavingBlockingState");
    let cmdObj = donorStartMigrationCmd(tenantID, st.rs1.getURL());
    assert.commandWorked(adminDB.runCommand(cmdObj));
    assert.soon(function() {
        let res = assert.commandWorked(adminDB.runCommand(cmdObj));
        return res['state'] == "aborted";
    }, "migration not in aborted state", 1 * 10000, 1 * 1000);
    const kNumWriteOps = 6;
    const bulkRes =
        bulkInsertDocs(st.q0.host, kDbName, kCollName, kNumWriteOps, isBulkWriteOrdered);
    assert.eq(bulkRes.res.nInserted, kNumWriteOps);
    assert.eq(bulkRes.res.writeErrors.length, 0);
}
function orderedBulkInsertAfterTenantMigrationAborted ( st , isBulkWriteOrdered ) { let titleOrderedStr = "Starting test - " + ( isBulkWriteOrdered ? "ordered" : "unordered" ) ; jsTest . log ( titleOrderedStr + " bulk insert after the migration has aborted." ) ; const tenantID = ObjectId ( ) ; const kDbName = tenantID . str + "_test" ; let adminDB = st . rs0 . getPrimary ( ) . getDB ( 'admin' ) ; const kCollName = 'foo' ; assert . commandWorked ( st . q0 . adminCommand ( { enableSharding : kDbName } ) ) ; st . ensurePrimaryShard ( kDbName , st . shard0 . shardName ) ; configureFailPoint ( adminDB , "abortTenantMigrationBeforeLeavingBlockingState" ) ; let cmdObj = donorStartMigrationCmd ( tenantID , st . rs1 . getURL ( ) ) ; assert . commandWorked ( adminDB . runCommand ( cmdObj ) ) ; assert . soon ( function ( ) { let res = assert . commandWorked ( adminDB . runCommand ( cmdObj ) ) ; return res [ 'state' ] == "aborted" ; } , "migration not in aborted state" , 1 * 10000 , 1 * 1000 ) ; const kNumWriteOps = 6 ; const bulkRes = bulkInsertDocs ( st . q0 . host , kDbName , kCollName , kNumWriteOps , isBulkWriteOrdered ) ; assert . eq ( bulkRes . res . nInserted , kNumWriteOps ) ; assert . eq ( bulkRes . res . writeErrors . length , 0 ) ; }
Test running a migration and then try to do an unordered/ordered once the migration has aborted.
Test running a migration and then try to do an unordered / ordered once the migration has aborted .