jstests/change_streams/migrate_last_chunk_from_shard_event.js
// Test that if showSystemEvents is false, we do not see the migrateLastChunkFromShard event.
Test that if showSystemEvents is false, we do not see the migrateLastChunkFromShard event.
Test that if showSystemEvents is false we do not see the migrateLastChunkFromShard event .
function validateShowSystemEventsFalse() {
    prepareCollection();
    let pipeline = [
        {$changeStream: {showExpandedEvents: true, showSystemEvents: false}},
        {$match: {operationType: {$nin: ["create", "createIndexes"]}}}
    ];
    let cursor = test.startWatchingChanges(
        {pipeline, collection: collName, aggregateOptions: {cursor: {batchSize: 0}}});
    assert.commandWorked(
        db.adminCommand({moveChunk: collNS, find: {_id: 0}, to: st.shard1.shardName}));
    assert.commandWorked(db[collName].insert({_id: numDocs + 1}));
    test.assertNextChangesEqual({
        cursor: cursor,
        expectedChanges: {
            operationType: "insert",
            ns: ns,
            fullDocument: {_id: numDocs + 1},
            documentKey: {_id: numDocs + 1},
        }
    });
}
function validateShowSystemEventsFalse ( ) { prepareCollection ( ) ; let pipeline = [ { $changeStream : { showExpandedEvents : true , showSystemEvents : false } } , { $match : { operationType : { $nin : [ "create" , "createIndexes" ] } } } ] ; let cursor = test . startWatchingChanges ( { pipeline , collection : collName , aggregateOptions : { cursor : { batchSize : 0 } } } ) ; assert . commandWorked ( db . adminCommand ( { moveChunk : collNS , find : { _id : 0 } , to : st . shard1 . shardName } ) ) ; assert . commandWorked ( db [ collName ] . insert ( { _id : numDocs + 1 } ) ) ; test . assertNextChangesEqual ( { cursor : cursor , expectedChanges : { operationType : "insert" , ns : ns , fullDocument : { _id : numDocs + 1 } , documentKey : { _id : numDocs + 1 } , } } ) ; }
Test that if showSystemEvents is false, we do not see the migrateLastChunkFromShard event.
Test that if showSystemEvents is false we do not see the migrateLastChunkFromShard event .
// Migrate a chunk, then insert a new document. // Confirm that we don't observe the migrateLastChunkFromShard event in the stream, but only see // the subsequent insert.