jstests/sharding/change_stream_transaction_sharded.js
/**
 * Test that change stream returns the expected set of documuments when resumed from each
 * point captured by 'changeList'.
 */
Test that change stream returns the expected set of documuments when resumed from each
point captured by 'changeList'.
Test that change stream returns the expected set of documuments when resumed from each point captured by ' changeList ' .
function confirmResumeForChangeList(changeList, changeListShard1, changeListShard2) {
    for (let i = 0; i < changeList.length; ++i) {
        const resumeDoc = changeList[i];
        let indexShard1 = getPostTokenChangeIndex(resumeDoc, changeListShard1);
        let indexShard2 = getPostTokenChangeIndex(resumeDoc, changeListShard2);
        const resumeCursor = coll.watch([], {startAfter: resumeDoc._id});
        while ((indexShard1 + indexShard2) < (changeListShard1.length + changeListShard2.length)) {
            assert.soon(() => resumeCursor.hasNext());
            const changeDoc = resumeCursor.next();
            if (changeDoc.documentKey.shard === 1) {
                shardHasDocumentAtChangeListIndex(changeDoc, changeListShard1, indexShard1++);
            } else {
                assert(changeDoc.documentKey.shard === 2);
                shardHasDocumentAtChangeListIndex(changeDoc, changeListShard2, indexShard2++);
            }
        }
        assertNoChanges(resumeCursor);
        resumeCursor.close();
    }
}
function confirmResumeForChangeList ( changeList , changeListShard1 , changeListShard2 ) { for ( let i = 0 ; i < changeList . length ; ++ i ) { const resumeDoc = changeList [ i ] ; let indexShard1 = getPostTokenChangeIndex ( resumeDoc , changeListShard1 ) ; let indexShard2 = getPostTokenChangeIndex ( resumeDoc , changeListShard2 ) ; const resumeCursor = coll . watch ( [ ] , { startAfter : resumeDoc . _id } ) ; while ( ( indexShard1 + indexShard2 ) < ( changeListShard1 . length + changeListShard2 . length ) ) { assert . soon ( ( ) => resumeCursor . hasNext ( ) ) ; const changeDoc = resumeCursor . next ( ) ; if ( changeDoc . documentKey . shard === 1 ) { shardHasDocumentAtChangeListIndex ( changeDoc , changeListShard1 , indexShard1 ++ ) ; } else { assert ( changeDoc . documentKey . shard === 2 ) ; shardHasDocumentAtChangeListIndex ( changeDoc , changeListShard2 , indexShard2 ++ ) ; } } assertNoChanges ( resumeCursor ) ; resumeCursor . close ( ) ; } }
Test that change stream returns the expected set of documuments when resumed from each
 point captured by 'changeList'.
Test that change stream returns the expected set of documuments when resumed from each point captured by ' changeList ' .