jstests/replsets/tenant_migration_recipient_initial_sync_cloning.js
// matches up with the primary's. Returns the initial sync node.
matches up with the primary's. Returns the initial sync node.
matches up with the primary ' s . Returns the initial sync node .
function restartNodeAndCheckState(tenantId, tenantMigrationTest, checkMtab) {
    const recipientRst = tenantMigrationTest.getRecipientRst();
    const originalRecipientPrimary = recipientRst.getPrimary();
    jsTestLog("Restarting a node from the recipient replica set.");
    let initialSyncNode = recipientRst.getSecondaries()[0];
    initialSyncNode =
        recipientRst.restart(initialSyncNode, {startClean: true, skipValidation: true});
    waitForNewlyAddedRemovalForNodeToBeCommitted(originalRecipientPrimary,
                                                 recipientRst.getNodeId(initialSyncNode));
    recipientRst.awaitSecondaryNodes();
    recipientRst.awaitReplication();
    jsTestLog("Ensure that the new node's state matches up with the primary's.");
    let recipientDocOnPrimary = undefined;
    let recipientDocOnNewNode = undefined;
    assert.soon(
        () => {
            recipientDocOnPrimary =
                originalRecipientPrimary.getCollection(TenantMigrationTest.kConfigRecipientsNS)
                    .findOne({tenantId: tenantId});
            recipientDocOnNewNode =
                initialSyncNode.getCollection(TenantMigrationTest.kConfigRecipientsNS).findOne({
                    tenantId: tenantId
                });
            return recipientDocOnPrimary.state == recipientDocOnNewNode.state;
        },
        `States never matched, primary: ${recipientDocOnPrimary}, on new node: ${
            recipientDocOnNewNode}`);
    if (checkMtab) {
        jsTestLog("Ensuring TenantMigrationAccessBlocker states match.");
        const primaryMtab = tenantMigrationTest.getTenantMigrationAccessBlocker(
            {recipientNode: originalRecipientPrimary, tenantId});
        const newNodeMtab = tenantMigrationTest.getTenantMigrationAccessBlocker(
            {recipientNode: initialSyncNode, tenantId});
        assert.eq(primaryMtab.recipient.state,
                  newNodeMtab.recipient.state,
                  `Mtab didn't match, primary: ${primaryMtab}, on new node: ${newNodeMtab}`);
    }
    return initialSyncNode;
}
function restartNodeAndCheckState ( tenantId , tenantMigrationTest , checkMtab ) { const recipientRst = tenantMigrationTest . getRecipientRst ( ) ; const originalRecipientPrimary = recipientRst . getPrimary ( ) ; jsTestLog ( "Restarting a node from the recipient replica set." ) ; let initialSyncNode = recipientRst . getSecondaries ( ) [ 0 ] ; initialSyncNode = recipientRst . restart ( initialSyncNode , { startClean : true , skipValidation : true } ) ; waitForNewlyAddedRemovalForNodeToBeCommitted ( originalRecipientPrimary , recipientRst . getNodeId ( initialSyncNode ) ) ; recipientRst . awaitSecondaryNodes ( ) ; recipientRst . awaitReplication ( ) ; jsTestLog ( "Ensure that the new node's state matches up with the primary's." ) ; let recipientDocOnPrimary = undefined ; let recipientDocOnNewNode = undefined ; assert . soon ( ( ) => { recipientDocOnPrimary = originalRecipientPrimary . getCollection ( TenantMigrationTest . kConfigRecipientsNS ) . findOne ( { tenantId : tenantId } ) ; recipientDocOnNewNode = initialSyncNode . getCollection ( TenantMigrationTest . kConfigRecipientsNS ) . findOne ( { tenantId : tenantId } ) ; return recipientDocOnPrimary . state == recipientDocOnNewNode . state ; } , ` ${ recipientDocOnPrimary } ${ recipientDocOnNewNode } ` ) ; if ( checkMtab ) { jsTestLog ( "Ensuring TenantMigrationAccessBlocker states match." ) ; const primaryMtab = tenantMigrationTest . getTenantMigrationAccessBlocker ( { recipientNode : originalRecipientPrimary , tenantId } ) ; const newNodeMtab = tenantMigrationTest . getTenantMigrationAccessBlocker ( { recipientNode : initialSyncNode , tenantId } ) ; assert . eq ( primaryMtab . recipient . state , newNodeMtab . recipient . state , ` ${ primaryMtab } ${ newNodeMtab } ` ) ; } return initialSyncNode ; }
matches up with the primary's.
matches up with the primary ' s .
// Restart a node and allow it to complete initial sync. // Allow the new node to finish initial sync. // Make sure the new node's state makes sense.