@@ -15,7 +15,7 @@ describe('MongoClient.close() Integration', () => {
15
15
16
16
describe ( 'Node.js resource: TLS File read' , ( ) => {
17
17
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 ( ) {
19
19
await runScriptAndGetProcessInfo (
20
20
'tls-file-read' ,
21
21
config ,
@@ -51,7 +51,7 @@ describe('MongoClient.close() Integration', () => {
51
51
} ) ;
52
52
53
53
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 ( ) => {
55
55
await runScriptAndGetProcessInfo (
56
56
'token-file-read' ,
57
57
config ,
@@ -78,8 +78,7 @@ describe('MongoClient.close() Integration', () => {
78
78
describe ( 'Node.js resource: Server Selection Timer' , ( ) => {
79
79
describe ( 'after a Topology is created through client.connect()' , ( ) => {
80
80
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 ( ) => {
83
82
const run = async function ( { MongoClient, uri, expect, sleep, mongodb, getTimerCount } ) {
84
83
const serverSelectionTimeoutMS = 2222 ;
85
84
const client = new MongoClient ( uri , {
@@ -118,7 +117,7 @@ describe('MongoClient.close() Integration', () => {
118
117
describe ( 'MonitorInterval' , ( ) => {
119
118
describe ( 'Node.js resource: Timer' , ( ) => {
120
119
describe ( 'after a new monitor is made' , ( ) => {
121
- it (
120
+ it . skip (
122
121
'monitor interval timer is cleaned up by client.close()' ,
123
122
metadata ,
124
123
async function ( ) {
@@ -151,7 +150,7 @@ describe('MongoClient.close() Integration', () => {
151
150
} ) ;
152
151
153
152
describe ( 'after a heartbeat fails' , ( ) => {
154
- it (
153
+ it . skip (
155
154
'the new monitor interval timer is cleaned up by client.close()' ,
156
155
metadata ,
157
156
async ( ) => {
@@ -161,7 +160,6 @@ describe('MongoClient.close() Integration', () => {
161
160
const willBeHeartbeatFailed = once ( client , 'serverHeartbeatFailed' ) ;
162
161
client . connect ( ) ;
163
162
await willBeHeartbeatFailed ;
164
-
165
163
function getMonitorTimer ( servers ) {
166
164
for ( const [ , server ] of servers ) {
167
165
return server ?. monitor . monitorId . timerId ;
@@ -184,7 +182,7 @@ describe('MongoClient.close() Integration', () => {
184
182
185
183
describe ( 'Monitoring Connection' , ( ) => {
186
184
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 ( ) {
188
186
const run = async function ( { MongoClient, uri, expect, getSocketEndpoints } ) {
189
187
const client = new MongoClient ( uri ) ;
190
188
await client . connect ( ) ;
@@ -212,7 +210,7 @@ describe('MongoClient.close() Integration', () => {
212
210
describe ( 'RTT Pinger' , ( ) => {
213
211
describe ( 'Node.js resource: Timer' , ( ) => {
214
212
describe ( 'after entering monitor streaming mode ' , ( ) => {
215
- it (
213
+ it . skip (
216
214
'the rtt pinger timer is cleaned up by client.close()' ,
217
215
metadata ,
218
216
async function ( ) {
@@ -248,8 +246,8 @@ describe('MongoClient.close() Integration', () => {
248
246
describe ( 'Connection' , ( ) => {
249
247
describe ( 'Node.js resource: Socket' , ( ) => {
250
248
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 } ) => {
253
251
const heartbeatFrequencyMS = 500 ;
254
252
const client = new MongoClient ( uri , {
255
253
serverMonitoringMode : 'stream' ,
@@ -266,7 +264,6 @@ describe('MongoClient.close() Integration', () => {
266
264
267
265
while ( heartbeatOccurredSet . size < servers . size ) {
268
266
const ev = await once ( client , 'serverHeartbeatSucceeded' ) ;
269
- log ( { ev : ev [ 0 ] } ) ;
270
267
heartbeatOccurredSet . add ( ev [ 0 ] . connectionId ) ;
271
268
}
272
269
@@ -282,8 +279,6 @@ describe('MongoClient.close() Integration', () => {
282
279
283
280
// close the client
284
281
await client . close ( ) ;
285
-
286
- log ( { socketsAfterClose : getSockets ( ) } ) ;
287
282
// upon close, assert rttPinger sockets are cleaned up
288
283
const activeSocketsAfterClose = activeSocketsAfterHeartbeat ( ) ;
289
284
expect ( activeSocketsAfterClose ) . to . have . lengthOf ( 0 ) ;
@@ -300,7 +295,7 @@ describe('MongoClient.close() Integration', () => {
300
295
describe ( 'ConnectionPool' , ( ) => {
301
296
describe ( 'Node.js resource: minPoolSize timer' , ( ) => {
302
297
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 ( ) {
304
299
const run = async function ( { MongoClient, uri, expect, getTimerCount } ) {
305
300
const client = new MongoClient ( uri , { minPoolSize : 1 } ) ;
306
301
let minPoolSizeTimerCreated = false ;
@@ -358,7 +353,7 @@ describe('MongoClient.close() Integration', () => {
358
353
await utilClient . close ( ) ;
359
354
} ) ;
360
355
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 ( ) {
362
357
const run = async function ( { MongoClient, uri, expect, getTimerCount, once } ) {
363
358
const waitQueueTimeoutMS = 1515 ;
364
359
@@ -400,7 +395,7 @@ describe('MongoClient.close() Integration', () => {
400
395
describe ( 'Connection' , ( ) => {
401
396
describe ( 'Node.js resource: Socket' , ( ) => {
402
397
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 ( ) {
404
399
const run = async function ( { MongoClient, uri, expect, getSockets } ) {
405
400
// assert no sockets to start with
406
401
expect ( getSockets ( ) ) . to . have . lengthOf ( 0 ) ;
@@ -432,7 +427,7 @@ describe('MongoClient.close() Integration', () => {
432
427
const metadata : MongoDBMetadataUI = { requires : { topology : 'sharded' } } ;
433
428
434
429
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 ( ) => {
436
431
const run = async function ( { MongoClient, expect, getTimerCount } ) {
437
432
const SRV_CONNECTION_STRING = `mongodb+srv://test1.test.build.10gen.cc` ;
438
433
// 27018 localhost.test.build.10gen.cc.
@@ -456,83 +451,119 @@ describe('MongoClient.close() Integration', () => {
456
451
describe ( 'ClientSession (Implicit)' , ( ) => {
457
452
let idleSessionsBeforeClose ;
458
453
let idleSessionsAfterClose ;
454
+ let client ;
455
+ let utilClient ;
456
+ let session ;
457
+
458
+ const metadata : MongoDBMetadataUI = { requires : { topology : [ 'replicaset' , 'sharded' ] } } ;
459
459
460
460
beforeEach ( async function ( ) {
461
- const client = this . configuration . newClient ( ) ;
461
+ client = this . configuration . newClient ( ) ;
462
+ utilClient = this . configuration . newClient ( ) ;
462
463
await client . connect ( ) ;
463
- const session = client . startSession ( { explicit : false } ) ;
464
+ session = client . startSession ( { explicit : false } ) ;
464
465
session . startTransaction ( ) ;
465
466
await client . db ( 'db' ) . collection ( 'collection' ) . insertOne ( { x : 1 } , { session } ) ;
466
467
467
- const opBefore = await client . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
468
+ const opBefore = await utilClient . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
468
469
idleSessionsBeforeClose = opBefore . inprog . filter ( s => s . type === 'idleSession' ) ;
469
470
470
471
await client . close ( ) ;
471
- await client . connect ( ) ;
472
472
473
- const opAfter = await client . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
473
+ const opAfter = await utilClient . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
474
474
idleSessionsAfterClose = opAfter . inprog . filter ( s => s . type === 'idleSession' ) ;
475
475
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 ( ) ;
477
483
} ) ;
478
484
479
485
describe ( 'Server resource: LSID/ServerSession' , ( ) => {
480
486
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
+ ) ;
485
495
} ) ;
486
496
} ) ;
487
497
488
498
describe ( 'Server resource: Transactions' , ( ) => {
489
499
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
+ ) ;
494
508
} ) ;
495
509
} ) ;
496
510
} ) ;
497
511
498
512
describe ( 'ClientSession (Explicit)' , ( ) => {
499
513
let idleSessionsBeforeClose ;
500
514
let idleSessionsAfterClose ;
515
+ let client ;
516
+ let utilClient ;
517
+ let session ;
518
+
519
+ const metadata : MongoDBMetadataUI = { requires : { topology : [ 'replicaset' , 'sharded' ] } } ;
501
520
502
521
beforeEach ( async function ( ) {
503
- const client = this . configuration . newClient ( ) ;
522
+ client = this . configuration . newClient ( ) ;
523
+ utilClient = this . configuration . newClient ( ) ;
504
524
await client . connect ( ) ;
505
- const session = client . startSession ( ) ;
525
+ session = client . startSession ( ) ;
506
526
session . startTransaction ( ) ;
507
527
await client . db ( 'db' ) . collection ( 'collection' ) . insertOne ( { x : 1 } , { session } ) ;
508
528
509
- const opBefore = await client . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
529
+ const opBefore = await utilClient . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
510
530
idleSessionsBeforeClose = opBefore . inprog . filter ( s => s . type === 'idleSession' ) ;
511
531
512
532
await client . close ( ) ;
513
- await client . connect ( ) ;
514
533
515
- const opAfter = await client . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
534
+ const opAfter = await utilClient . db ( ) . admin ( ) . command ( { currentOp : 1 } ) ;
516
535
idleSessionsAfterClose = opAfter . inprog . filter ( s => s . type === 'idleSession' ) ;
536
+ } ) ;
517
537
518
- await client . close ( ) ;
538
+ afterEach ( async function ( ) {
539
+ await utilClient ?. close ( ) ;
540
+ await session ?. endSession ( ) ;
541
+ await client ?. close ( ) ;
519
542
} ) ;
520
543
521
544
describe ( 'Server resource: LSID/ServerSession' , ( ) => {
522
545
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
+ ) ;
527
554
} ) ;
528
555
} ) ;
529
556
530
557
describe ( 'Server resource: Transactions' , ( ) => {
531
558
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
+ ) ;
536
567
} ) ;
537
568
} ) ;
538
569
} ) ;
@@ -548,7 +579,7 @@ describe('MongoClient.close() Integration', () => {
548
579
describe ( 'KMS Request' , ( ) => {
549
580
describe ( 'Node.js resource: TLS file read' , ( ) => {
550
581
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 ( ) => {
552
583
await runScriptAndGetProcessInfo (
553
584
'tls-file-read-auto-encryption' ,
554
585
config ,
@@ -645,20 +676,24 @@ describe('MongoClient.close() Integration', () => {
645
676
let client ;
646
677
let coll ;
647
678
let cursor ;
679
+ let utilClient ;
648
680
649
681
beforeEach ( async function ( ) {
650
682
client = this . configuration . newClient ( ) ;
683
+ utilClient = this . configuration . newClient ( ) ;
684
+ await client . connect ( ) ;
651
685
coll = client . db ( 'db' ) . collection ( 'coll' ) ;
652
686
} ) ;
653
687
654
688
afterEach ( async function ( ) {
689
+ await utilClient ?. close ( ) ;
655
690
await client ?. close ( ) ;
656
691
await cursor ?. close ( ) ;
657
692
} ) ;
658
693
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 ( ) {
660
695
const getCursors = async ( ) => {
661
- const res = await client
696
+ const res = await utilClient
662
697
. db ( )
663
698
. admin ( )
664
699
. command ( {
@@ -672,17 +707,18 @@ describe('MongoClient.close() Integration', () => {
672
707
} ;
673
708
674
709
await coll . insertMany ( [ { a : 1 } , { b : 2 } , { c : 3 } ] ) ;
710
+ await coll . insertMany ( [ { d : 4 } , { e : 5 } , { f : 3 } ] ) ;
675
711
cursor = await coll . find ( ) ;
712
+ await cursor . next ( ) ;
676
713
677
714
// assert creation
678
715
expect ( await getCursors ( ) ) . to . not . be . empty ;
679
716
680
717
await client . close ( ) ;
681
- await client . connect ( ) ;
682
718
683
719
// assert clean-up
684
720
expect ( await getCursors ( ) ) . to . be . empty ;
685
721
} ) ;
686
722
} ) ;
687
723
} ) ;
688
- } ) ;
724
+ } ) ;
0 commit comments