@@ -15,7 +15,7 @@ describe('MongoClient.close() Integration', () => {
1515
1616 describe ( 'Node.js resource: TLS File read' , ( ) => {
1717 describe ( 'when client is connecting and reads an infinite TLS file' , ( ) => {
18- it ( 'the file read is interrupted by client.close()' , async function ( ) {
18+ it . skip ( 'the file read is interrupted by client.close()' , async function ( ) {
1919 await runScriptAndGetProcessInfo (
2020 'tls-file-read' ,
2121 config ,
@@ -51,7 +51,7 @@ describe('MongoClient.close() Integration', () => {
5151 } ) ;
5252
5353 describe ( 'when MongoClientAuthProviders is instantiated and token file read hangs' , ( ) => {
54- it ( 'the file read is interrupted by client.close()' , async ( ) => {
54+ it . skip ( 'the file read is interrupted by client.close()' , async ( ) => {
5555 await runScriptAndGetProcessInfo (
5656 'token-file-read' ,
5757 config ,
@@ -78,8 +78,7 @@ describe('MongoClient.close() Integration', () => {
7878 describe ( 'Node.js resource: Server Selection Timer' , ( ) => {
7979 describe ( 'after a Topology is created through client.connect()' , ( ) => {
8080 const metadata : MongoDBMetadataUI = { requires : { topology : 'replicaset' } } ;
81-
82- it ( 'server selection timers are cleaned up by client.close()' , metadata , async ( ) => {
81+ it . skip ( 'server selection timers are cleaned up by client.close()' , metadata , async ( ) => {
8382 const run = async function ( { MongoClient, uri, expect, sleep, mongodb, getTimerCount } ) {
8483 const serverSelectionTimeoutMS = 2222 ;
8584 const client = new MongoClient ( uri , {
@@ -118,7 +117,7 @@ describe('MongoClient.close() Integration', () => {
118117 describe ( 'MonitorInterval' , ( ) => {
119118 describe ( 'Node.js resource: Timer' , ( ) => {
120119 describe ( 'after a new monitor is made' , ( ) => {
121- it (
120+ it . skip (
122121 'monitor interval timer is cleaned up by client.close()' ,
123122 metadata ,
124123 async function ( ) {
@@ -151,7 +150,7 @@ describe('MongoClient.close() Integration', () => {
151150 } ) ;
152151
153152 describe ( 'after a heartbeat fails' , ( ) => {
154- it (
153+ it . skip (
155154 'the new monitor interval timer is cleaned up by client.close()' ,
156155 metadata ,
157156 async ( ) => {
@@ -161,7 +160,6 @@ describe('MongoClient.close() Integration', () => {
161160 const willBeHeartbeatFailed = once ( client , 'serverHeartbeatFailed' ) ;
162161 client . connect ( ) ;
163162 await willBeHeartbeatFailed ;
164-
165163 function getMonitorTimer ( servers ) {
166164 for ( const [ , server ] of servers ) {
167165 return server ?. monitor . monitorId . timerId ;
@@ -184,7 +182,7 @@ describe('MongoClient.close() Integration', () => {
184182
185183 describe ( 'Monitoring Connection' , ( ) => {
186184 describe ( 'Node.js resource: Socket' , ( ) => {
187- it ( 'no sockets remain after client.close()' , metadata , async function ( ) {
185+ it . skip ( 'no sockets remain after client.close()' , metadata , async function ( ) {
188186 const run = async function ( { MongoClient, uri, expect, getSocketEndpoints } ) {
189187 const client = new MongoClient ( uri ) ;
190188 await client . connect ( ) ;
@@ -212,7 +210,7 @@ describe('MongoClient.close() Integration', () => {
212210 describe ( 'RTT Pinger' , ( ) => {
213211 describe ( 'Node.js resource: Timer' , ( ) => {
214212 describe ( 'after entering monitor streaming mode ' , ( ) => {
215- it (
213+ it . skip (
216214 'the rtt pinger timer is cleaned up by client.close()' ,
217215 metadata ,
218216 async function ( ) {
@@ -248,8 +246,8 @@ describe('MongoClient.close() Integration', () => {
248246 describe ( 'Connection' , ( ) => {
249247 describe ( 'Node.js resource: Socket' , ( ) => {
250248 describe ( 'when rtt monitoring is turned on' , ( ) => {
251- it ( 'no sockets remain after client.close()' , metadata , async ( ) => {
252- const run = async ( { MongoClient, uri, expect, getSockets, once, log } ) => {
249+ it . skip ( 'no sockets remain after client.close()' , metadata , async ( ) => {
250+ const run = async ( { MongoClient, uri, expect, getSockets, once } ) => {
253251 const heartbeatFrequencyMS = 500 ;
254252 const client = new MongoClient ( uri , {
255253 serverMonitoringMode : 'stream' ,
@@ -266,7 +264,6 @@ describe('MongoClient.close() Integration', () => {
266264
267265 while ( heartbeatOccurredSet . size < servers . size ) {
268266 const ev = await once ( client , 'serverHeartbeatSucceeded' ) ;
269- log ( { ev : ev [ 0 ] } ) ;
270267 heartbeatOccurredSet . add ( ev [ 0 ] . connectionId ) ;
271268 }
272269
@@ -282,8 +279,6 @@ describe('MongoClient.close() Integration', () => {
282279
283280 // close the client
284281 await client . close ( ) ;
285-
286- log ( { socketsAfterClose : getSockets ( ) } ) ;
287282 // upon close, assert rttPinger sockets are cleaned up
288283 const activeSocketsAfterClose = activeSocketsAfterHeartbeat ( ) ;
289284 expect ( activeSocketsAfterClose ) . to . have . lengthOf ( 0 ) ;
@@ -300,7 +295,7 @@ describe('MongoClient.close() Integration', () => {
300295 describe ( 'ConnectionPool' , ( ) => {
301296 describe ( 'Node.js resource: minPoolSize timer' , ( ) => {
302297 describe ( 'after new connection pool is created' , ( ) => {
303- it ( 'the minPoolSize timer is cleaned up by client.close()' , async function ( ) {
298+ it . skip ( 'the minPoolSize timer is cleaned up by client.close()' , async function ( ) {
304299 const run = async function ( { MongoClient, uri, expect, getTimerCount } ) {
305300 const client = new MongoClient ( uri , { minPoolSize : 1 } ) ;
306301 let minPoolSizeTimerCreated = false ;
@@ -358,7 +353,7 @@ describe('MongoClient.close() Integration', () => {
358353 await utilClient . close ( ) ;
359354 } ) ;
360355
361- it ( 'the wait queue timer is cleaned up by client.close()' , async function ( ) {
356+ it . skip ( 'the wait queue timer is cleaned up by client.close()' , async function ( ) {
362357 const run = async function ( { MongoClient, uri, expect, getTimerCount, once } ) {
363358 const waitQueueTimeoutMS = 1515 ;
364359
@@ -400,7 +395,7 @@ describe('MongoClient.close() Integration', () => {
400395 describe ( 'Connection' , ( ) => {
401396 describe ( 'Node.js resource: Socket' , ( ) => {
402397 describe ( 'after a minPoolSize has been set on the ConnectionPool' , ( ) => {
403- it ( 'no sockets remain after client.close()' , async function ( ) {
398+ it . skip ( 'no sockets remain after client.close()' , async function ( ) {
404399 const run = async function ( { MongoClient, uri, expect, getSockets } ) {
405400 // assert no sockets to start with
406401 expect ( getSockets ( ) ) . to . have . lengthOf ( 0 ) ;
@@ -432,7 +427,7 @@ describe('MongoClient.close() Integration', () => {
432427 const metadata : MongoDBMetadataUI = { requires : { topology : 'sharded' } } ;
433428
434429 describe ( 'after SRVPoller is created' , ( ) => {
435- it ( 'timers are cleaned up by client.close()' , metadata , async ( ) => {
430+ it . skip ( 'timers are cleaned up by client.close()' , metadata , async ( ) => {
436431 const run = async function ( { MongoClient, expect, getTimerCount } ) {
437432 const SRV_CONNECTION_STRING = `mongodb+srv://test1.test.build.10gen.cc` ;
438433 // 27018 localhost.test.build.10gen.cc.
@@ -456,83 +451,119 @@ describe('MongoClient.close() Integration', () => {
456451 describe ( 'ClientSession (Implicit)' , ( ) => {
457452 let idleSessionsBeforeClose ;
458453 let idleSessionsAfterClose ;
454+ let client ;
455+ let utilClient ;
456+ let session ;
457+
458+ const metadata : MongoDBMetadataUI = { requires : { topology : [ 'replicaset' , 'sharded' ] } } ;
459459
460460 beforeEach ( async function ( ) {
461- const client = this . configuration . newClient ( ) ;
461+ client = this . configuration . newClient ( ) ;
462+ utilClient = this . configuration . newClient ( ) ;
462463 await client . connect ( ) ;
463- const session = client . startSession ( { explicit : false } ) ;
464+ session = client . startSession ( { explicit : false } ) ;
464465 session . startTransaction ( ) ;
465466 await client . db ( 'db' ) . collection ( 'collection' ) . insertOne ( { x : 1 } , { session } ) ;
466467
467- const opBefore = await client . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
468+ const opBefore = await utilClient . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
468469 idleSessionsBeforeClose = opBefore . inprog . filter ( s => s . type === 'idleSession' ) ;
469470
470471 await client . close ( ) ;
471- await client . connect ( ) ;
472472
473- const opAfter = await client . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
473+ const opAfter = await utilClient . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
474474 idleSessionsAfterClose = opAfter . inprog . filter ( s => s . type === 'idleSession' ) ;
475475
476- await client . close ( ) ;
476+ await utilClient . close ( ) ;
477+ } ) ;
478+
479+ afterEach ( async function ( ) {
480+ await utilClient ?. close ( ) ;
481+ await session ?. endSession ( ) ;
482+ await client ?. close ( ) ;
477483 } ) ;
478484
479485 describe ( 'Server resource: LSID/ServerSession' , ( ) => {
480486 describe ( 'after a clientSession is implicitly created and used' , ( ) => {
481- it ( 'the server-side ServerSession is cleaned up by client.close()' , async function ( ) {
482- expect ( idleSessionsBeforeClose ) . to . not . be . empty ;
483- expect ( idleSessionsAfterClose ) . to . be . empty ;
484- } ) ;
487+ it (
488+ 'the server-side ServerSession is cleaned up by client.close()' ,
489+ metadata ,
490+ async function ( ) {
491+ expect ( idleSessionsBeforeClose ) . to . not . be . empty ;
492+ expect ( idleSessionsAfterClose ) . to . be . empty ;
493+ }
494+ ) ;
485495 } ) ;
486496 } ) ;
487497
488498 describe ( 'Server resource: Transactions' , ( ) => {
489499 describe ( 'after a clientSession is implicitly created and used' , ( ) => {
490- it ( 'the server-side transaction is cleaned up by client.close()' , async function ( ) {
491- expect ( idleSessionsBeforeClose [ 0 ] . transaction . txnNumber ) . to . not . null ;
492- expect ( idleSessionsAfterClose ) . to . be . empty ;
493- } ) ;
500+ it (
501+ 'the server-side transaction is cleaned up by client.close()' ,
502+ metadata ,
503+ async function ( ) {
504+ expect ( idleSessionsBeforeClose [ 0 ] . transaction . txnNumber ) . to . not . null ;
505+ expect ( idleSessionsAfterClose ) . to . be . empty ;
506+ }
507+ ) ;
494508 } ) ;
495509 } ) ;
496510 } ) ;
497511
498512 describe ( 'ClientSession (Explicit)' , ( ) => {
499513 let idleSessionsBeforeClose ;
500514 let idleSessionsAfterClose ;
515+ let client ;
516+ let utilClient ;
517+ let session ;
518+
519+ const metadata : MongoDBMetadataUI = { requires : { topology : [ 'replicaset' , 'sharded' ] } } ;
501520
502521 beforeEach ( async function ( ) {
503- const client = this . configuration . newClient ( ) ;
522+ client = this . configuration . newClient ( ) ;
523+ utilClient = this . configuration . newClient ( ) ;
504524 await client . connect ( ) ;
505- const session = client . startSession ( ) ;
525+ session = client . startSession ( ) ;
506526 session . startTransaction ( ) ;
507527 await client . db ( 'db' ) . collection ( 'collection' ) . insertOne ( { x : 1 } , { session } ) ;
508528
509- const opBefore = await client . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
529+ const opBefore = await utilClient . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
510530 idleSessionsBeforeClose = opBefore . inprog . filter ( s => s . type === 'idleSession' ) ;
511531
512532 await client . close ( ) ;
513- await client . connect ( ) ;
514533
515- const opAfter = await client . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
534+ const opAfter = await utilClient . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
516535 idleSessionsAfterClose = opAfter . inprog . filter ( s => s . type === 'idleSession' ) ;
536+ } ) ;
517537
518- await client . close ( ) ;
538+ afterEach ( async function ( ) {
539+ await utilClient ?. close ( ) ;
540+ await session ?. endSession ( ) ;
541+ await client ?. close ( ) ;
519542 } ) ;
520543
521544 describe ( 'Server resource: LSID/ServerSession' , ( ) => {
522545 describe ( 'after a clientSession is created and used' , ( ) => {
523- it ( 'the server-side ServerSession is cleaned up by client.close()' , async function ( ) {
524- expect ( idleSessionsBeforeClose ) . to . not . be . empty ;
525- expect ( idleSessionsAfterClose ) . to . be . empty ;
526- } ) ;
546+ it (
547+ 'the server-side ServerSession is cleaned up by client.close()' ,
548+ metadata ,
549+ async function ( ) {
550+ expect ( idleSessionsBeforeClose ) . to . not . be . empty ;
551+ expect ( idleSessionsAfterClose ) . to . be . empty ;
552+ }
553+ ) ;
527554 } ) ;
528555 } ) ;
529556
530557 describe ( 'Server resource: Transactions' , ( ) => {
531558 describe ( 'after a clientSession is created and used' , ( ) => {
532- it ( 'the server-side transaction is cleaned up by client.close()' , async function ( ) {
533- expect ( idleSessionsBeforeClose [ 0 ] . transaction . txnNumber ) . to . not . null ;
534- expect ( idleSessionsAfterClose ) . to . be . empty ;
535- } ) ;
559+ it (
560+ 'the server-side transaction is cleaned up by client.close()' ,
561+ metadata ,
562+ async function ( ) {
563+ expect ( idleSessionsBeforeClose [ 0 ] . transaction . txnNumber ) . to . not . null ;
564+ expect ( idleSessionsAfterClose ) . to . be . empty ;
565+ }
566+ ) ;
536567 } ) ;
537568 } ) ;
538569 } ) ;
@@ -548,7 +579,7 @@ describe('MongoClient.close() Integration', () => {
548579 describe ( 'KMS Request' , ( ) => {
549580 describe ( 'Node.js resource: TLS file read' , ( ) => {
550581 describe ( 'when KMSRequest reads an infinite TLS file' , ( ) => {
551- it ( 'the file read is interrupted by client.close()' , metadata , async ( ) => {
582+ it . skip ( 'the file read is interrupted by client.close()' , metadata , async ( ) => {
552583 await runScriptAndGetProcessInfo (
553584 'tls-file-read-auto-encryption' ,
554585 config ,
@@ -645,20 +676,24 @@ describe('MongoClient.close() Integration', () => {
645676 let client ;
646677 let coll ;
647678 let cursor ;
679+ let utilClient ;
648680
649681 beforeEach ( async function ( ) {
650682 client = this . configuration . newClient ( ) ;
683+ utilClient = this . configuration . newClient ( ) ;
684+ await client . connect ( ) ;
651685 coll = client . db ( 'db' ) . collection ( 'coll' ) ;
652686 } ) ;
653687
654688 afterEach ( async function ( ) {
689+ await utilClient ?. close ( ) ;
655690 await client ?. close ( ) ;
656691 await cursor ?. close ( ) ;
657692 } ) ;
658693
659- it ( 'all active server-side cursors are closed by client.close()' , async function ( ) {
694+ it . skip ( 'all active server-side cursors are closed by client.close()' , async function ( ) {
660695 const getCursors = async ( ) => {
661- const res = await client
696+ const res = await utilClient
662697 . db ( )
663698 . admin ( )
664699 . command ( {
@@ -672,17 +707,18 @@ describe('MongoClient.close() Integration', () => {
672707 } ;
673708
674709 await coll . insertMany ( [ { a : 1 } , { b : 2 } , { c : 3 } ] ) ;
710+ await coll . insertMany ( [ { d : 4 } , { e : 5 } , { f : 3 } ] ) ;
675711 cursor = await coll . find ( ) ;
712+ await cursor . next ( ) ;
676713
677714 // assert creation
678715 expect ( await getCursors ( ) ) . to . not . be . empty ;
679716
680717 await client . close ( ) ;
681- await client . connect ( ) ;
682718
683719 // assert clean-up
684720 expect ( await getCursors ( ) ) . to . be . empty ;
685721 } ) ;
686722 } ) ;
687723 } ) ;
688- } ) ;
724+ } ) ;
0 commit comments