@@ -317,28 +317,30 @@ describe('CRUD API explain option', function () {
317
317
}
318
318
319
319
beforeEach ( async function ( ) {
320
- client = this . configuration . newClient (
321
- { } ,
322
- { monitorCommands : true , minPoolSize : 5 , appName : 'explain-tests' }
323
- ) ;
320
+ const uri = this . configuration . url ( { useMultipleMongoses : false } ) ;
321
+ client = this . configuration . newClient ( uri , { monitorCommands : true } ) ;
324
322
client . on ( 'commandStarted' , filterForCommands ( 'explain' , commands ) ) ;
325
323
326
- waitUntilPoolsFilled ( client , AbortSignal . timeout ( 30_000 ) , 4 ) ;
327
-
328
- await configureFailPoint ( this . configuration , {
329
- configureFailPoint : 'failCommand' ,
330
- mode : { times : 1 } ,
331
- data : {
332
- failCommands : [ 'explain' ] ,
333
- blockConnection : true ,
334
- blockTimeMS : 1000 ,
335
- appName : 'explain-tests'
336
- }
337
- } ) ;
324
+ await configureFailPoint (
325
+ this . configuration ,
326
+ {
327
+ configureFailPoint : 'failCommand' ,
328
+ mode : { times : 1 } ,
329
+ data : {
330
+ failCommands : [ 'explain' ] ,
331
+ blockConnection : true ,
332
+ blockTimeMS : 1000
333
+ }
334
+ } ,
335
+ uri
336
+ ) ;
338
337
} ) ;
339
338
340
339
afterEach ( async function ( ) {
341
- await clearFailPoint ( this . configuration ) ;
340
+ await clearFailPoint (
341
+ this . configuration ,
342
+ this . configuration . url ( { useMultipleMongoses : false } )
343
+ ) ;
342
344
await client ?. close ( ) ;
343
345
commands . length = 0 ;
344
346
} ) ;
@@ -535,6 +537,12 @@ describe('CRUD API explain option', function () {
535
537
const { result, duration } = await measureDuration ( ( ) =>
536
538
cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e )
537
539
) ;
540
+ const [
541
+ {
542
+ command : { maxTimeMS }
543
+ }
544
+ ] = commands ;
545
+ expect ( maxTimeMS ) . to . exist ;
538
546
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
539
547
expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
540
548
} ) ;
@@ -547,6 +555,12 @@ describe('CRUD API explain option', function () {
547
555
const { result, duration } = await measureDuration ( ( ) =>
548
556
cursor . explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } ) . catch ( e => e )
549
557
) ;
558
+ const [
559
+ {
560
+ command : { maxTimeMS }
561
+ }
562
+ ] = commands ;
563
+ expect ( maxTimeMS ) . to . exist ;
550
564
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
551
565
expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
552
566
} ) ;
@@ -558,6 +572,12 @@ describe('CRUD API explain option', function () {
558
572
const { result, duration } = await measureDuration ( ( ) =>
559
573
cursor . explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } ) . catch ( e => e )
560
574
) ;
575
+ const [
576
+ {
577
+ command : { maxTimeMS }
578
+ }
579
+ ] = commands ;
580
+ expect ( maxTimeMS ) . to . exist ;
561
581
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
562
582
expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
563
583
} ) ;
@@ -570,6 +590,12 @@ describe('CRUD API explain option', function () {
570
590
cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e )
571
591
) ;
572
592
593
+ const [
594
+ {
595
+ command : { maxTimeMS }
596
+ }
597
+ ] = commands ;
598
+ expect ( maxTimeMS ) . to . exist ;
573
599
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
574
600
expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
575
601
} ) ;
@@ -581,7 +607,12 @@ describe('CRUD API explain option', function () {
581
607
const { result, duration } = await measureDuration ( ( ) =>
582
608
cursor . explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } ) . catch ( e => e )
583
609
) ;
584
-
610
+ const [
611
+ {
612
+ command : { maxTimeMS }
613
+ }
614
+ ] = commands ;
615
+ expect ( maxTimeMS ) . to . exist ;
585
616
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
586
617
expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
587
618
} ) ;
@@ -593,6 +624,12 @@ describe('CRUD API explain option', function () {
593
624
const { duration, result } = await measureDuration ( ( ) =>
594
625
cursor . explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } ) . catch ( e => e )
595
626
) ;
627
+ const [
628
+ {
629
+ command : { maxTimeMS }
630
+ }
631
+ ] = commands ;
632
+ expect ( maxTimeMS ) . to . exist ;
596
633
expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
597
634
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
598
635
} ) ;
0 commit comments