@@ -10,7 +10,12 @@ import {
10
10
MongoOperationTimeoutError ,
11
11
MongoServerError
12
12
} from '../../mongodb' ;
13
- import { clearFailPoint , configureFailPoint , measureDuration } from '../../tools/utils' ;
13
+ import {
14
+ clearFailPoint ,
15
+ configureFailPoint ,
16
+ measureDuration ,
17
+ waitUntilPoolsFilled
18
+ } from '../../tools/utils' ;
14
19
import { filterForCommands } from '../shared' ;
15
20
16
21
const explain = [ true , false , 'queryPlanner' , 'allPlansExecution' , 'executionStats' , 'invalid' ] ;
@@ -312,16 +317,22 @@ describe('CRUD API explain option', function () {
312
317
}
313
318
314
319
beforeEach ( async function ( ) {
315
- client = this . configuration . newClient ( { } , { monitorCommands : true } ) ;
320
+ client = this . configuration . newClient (
321
+ { } ,
322
+ { monitorCommands : true , minPoolSize : 5 , appName : 'explain-test' }
323
+ ) ;
316
324
client . on ( 'commandStarted' , filterForCommands ( 'explain' , commands ) ) ;
317
325
326
+ waitUntilPoolsFilled ( client , AbortSignal . timeout ( 30_000 ) , 4 ) ;
327
+
318
328
await configureFailPoint ( this . configuration , {
319
329
configureFailPoint : 'failCommand' ,
320
330
mode : { times : 1 } ,
321
331
data : {
322
332
failCommands : [ 'explain' ] ,
323
333
blockConnection : true ,
324
- blockTimeMS : 1000
334
+ blockTimeMS : 1000 ,
335
+ appName : 'explain-tests'
325
336
}
326
337
} ) ;
327
338
} ) ;
@@ -525,7 +536,7 @@ describe('CRUD API explain option', function () {
525
536
cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e )
526
537
) ;
527
538
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
528
- expect ( duration ) . to . be . within ( 1000 , 1000 + 100 ) ;
539
+ expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
529
540
} ) ;
530
541
} ) ;
531
542
@@ -537,7 +548,7 @@ describe('CRUD API explain option', function () {
537
548
cursor . explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } ) . catch ( e => e )
538
549
) ;
539
550
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
540
- expect ( duration ) . to . be . within ( 1000 , 1000 + 100 ) ;
551
+ expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
541
552
} ) ;
542
553
} ) ;
543
554
@@ -548,7 +559,7 @@ describe('CRUD API explain option', function () {
548
559
cursor . explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } ) . catch ( e => e )
549
560
) ;
550
561
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
551
- expect ( duration ) . to . be . within ( 1000 , 1000 + 100 ) ;
562
+ expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
552
563
} ) ;
553
564
} ) ;
554
565
@@ -560,7 +571,7 @@ describe('CRUD API explain option', function () {
560
571
) ;
561
572
562
573
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
563
- expect ( duration ) . to . be . within ( 1000 , 1000 + 100 ) ;
574
+ expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
564
575
} ) ;
565
576
} ) ;
566
577
@@ -572,7 +583,7 @@ describe('CRUD API explain option', function () {
572
583
) ;
573
584
574
585
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
575
- expect ( duration ) . to . be . within ( 1000 , 1000 + 100 ) ;
586
+ expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
576
587
} ) ;
577
588
} ) ;
578
589
@@ -582,7 +593,7 @@ describe('CRUD API explain option', function () {
582
593
const { duration, result } = await measureDuration ( ( ) =>
583
594
cursor . explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } ) . catch ( e => e )
584
595
) ;
585
- expect ( duration ) . to . be . within ( 1000 , 1000 + 100 ) ;
596
+ expect ( duration ) . to . be . within ( 1000 - 100 , 1000 + 100 ) ;
586
597
expect ( result ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
587
598
} ) ;
588
599
} ) ;
0 commit comments