@@ -1111,7 +1111,7 @@ describe('Change Streams', function () {
11111111 changeStream . next ( ( err , doc ) => {
11121112 expect ( err ) . to . exist ;
11131113 expect ( doc ) . to . not . exist ;
1114- expect ( err . message ) . to . equal ( 'ChangeStream is closed' ) ;
1114+ expect ( err ? .message ) . to . equal ( 'ChangeStream is closed' ) ;
11151115 changeStream . close ( ( ) => client . close ( done ) ) ;
11161116 } ) ;
11171117 } ) ;
@@ -1372,23 +1372,97 @@ describe('Change Streams', function () {
13721372 )
13731373 . run ( ) ;
13741374
1375+ UnifiedTestSuiteBuilder . describe ( 'entity.watch() server-side options' )
1376+ . runOnRequirement ( {
1377+ topologies : [ 'replicaset' , 'sharded-replicaset' , 'sharded' , 'load-balanced' ] ,
1378+ minServerVersion : '4.4.0'
1379+ } )
1380+ . createEntities ( [
1381+ { client : { id : 'client0' , observeEvents : [ 'commandStartedEvent' ] } } ,
1382+ { database : { id : 'db0' , client : 'client0' , databaseName : 'watchOpts' } } ,
1383+ { collection : { id : 'collection0' , database : 'db0' , collectionName : 'watchOpts' } }
1384+ ] )
1385+ . test (
1386+ TestBuilder . it ( 'should use maxAwaitTimeMS to send maxTimeMS on getMore commands' )
1387+ . operation ( {
1388+ object : 'collection0' ,
1389+ name : 'createChangeStream' ,
1390+ saveResultAsEntity : 'changeStreamOnClient' ,
1391+ arguments : { maxAwaitTimeMS : 5000 }
1392+ } )
1393+ . operation ( {
1394+ name : 'insertOne' ,
1395+ object : 'collection0' ,
1396+ arguments : { document : { a : 1 } } ,
1397+ ignoreResultAndError : true
1398+ } )
1399+ . operation ( {
1400+ object : 'changeStreamOnClient' ,
1401+ name : 'iterateUntilDocumentOrError' ,
1402+ ignoreResultAndError : true
1403+ } )
1404+ . expectEvents ( {
1405+ client : 'client0' ,
1406+ events : [
1407+ { commandStartedEvent : { commandName : 'aggregate' } } ,
1408+ { commandStartedEvent : { commandName : 'insert' } } ,
1409+ { commandStartedEvent : { commandName : 'getMore' , command : { maxTimeMS : 5000 } } }
1410+ ]
1411+ } )
1412+ . toJSON ( )
1413+ )
1414+ . test (
1415+ TestBuilder . it ( 'should send maxTimeMS on aggregate command' )
1416+ . operation ( {
1417+ object : 'collection0' ,
1418+ name : 'createChangeStream' ,
1419+ saveResultAsEntity : 'changeStreamOnClient' ,
1420+ arguments : { maxTimeMS : 5000 }
1421+ } )
1422+ . operation ( {
1423+ name : 'insertOne' ,
1424+ object : 'collection0' ,
1425+ arguments : { document : { a : 1 } } ,
1426+ ignoreResultAndError : true
1427+ } )
1428+ . operation ( {
1429+ object : 'changeStreamOnClient' ,
1430+ name : 'iterateUntilDocumentOrError' ,
1431+ ignoreResultAndError : true
1432+ } )
1433+ . expectEvents ( {
1434+ client : 'client0' ,
1435+ events : [
1436+ { commandStartedEvent : { commandName : 'aggregate' , command : { maxTimeMS : 5000 } } } ,
1437+ { commandStartedEvent : { commandName : 'insert' } } ,
1438+ {
1439+ commandStartedEvent : {
1440+ commandName : 'getMore' ,
1441+ command : { maxTimeMS : { $$exists : false } }
1442+ }
1443+ }
1444+ ]
1445+ } )
1446+ . toJSON ( )
1447+ )
1448+ . run ( ) ;
1449+
13751450 describe ( 'BSON Options' , function ( ) {
13761451 let client : MongoClient ;
13771452 let db : Db ;
13781453 let collection : Collection ;
13791454 let cs : ChangeStream ;
1455+
13801456 beforeEach ( async function ( ) {
13811457 client = await this . configuration . newClient ( { monitorCommands : true } ) . connect ( ) ;
13821458 db = client . db ( 'db' ) ;
13831459 collection = await db . createCollection ( 'collection' ) ;
13841460 } ) ;
1461+
13851462 afterEach ( async function ( ) {
13861463 await db . dropCollection ( 'collection' ) ;
13871464 await cs . close ( ) ;
13881465 await client . close ( ) ;
1389- client = undefined ;
1390- db = undefined ;
1391- collection = undefined ;
13921466 } ) ;
13931467
13941468 context ( 'promoteLongs' , ( ) => {
@@ -1452,7 +1526,7 @@ describe('Change Streams', function () {
14521526 it ( 'does not send invalid options on the aggregate command' , {
14531527 metadata : { requires : { topology : '!single' } } ,
14541528 test : async function ( ) {
1455- const started = [ ] ;
1529+ const started : CommandStartedEvent [ ] = [ ] ;
14561530
14571531 client . on ( 'commandStarted' , filterForCommands ( [ 'aggregate' ] , started ) ) ;
14581532 const doc = { invalidBSONOption : true } ;
@@ -1473,7 +1547,7 @@ describe('Change Streams', function () {
14731547 it ( 'does not send invalid options on the getMore command' , {
14741548 metadata : { requires : { topology : '!single' } } ,
14751549 test : async function ( ) {
1476- const started = [ ] ;
1550+ const started : CommandStartedEvent [ ] = [ ] ;
14771551
14781552 client . on ( 'commandStarted' , filterForCommands ( [ 'aggregate' ] , started ) ) ;
14791553 const doc = { invalidBSONOption : true } ;
@@ -1503,7 +1577,7 @@ describe('ChangeStream resumability', function () {
15031577 const changeStreamResumeOptions : ChangeStreamOptions = {
15041578 fullDocument : 'updateLookup' ,
15051579 collation : { locale : 'en' , maxVariable : 'punct' } ,
1506- maxAwaitTimeMS : 20000 ,
1580+ maxAwaitTimeMS : 2000 ,
15071581 batchSize : 200
15081582 } ;
15091583
0 commit comments