@@ -33,7 +33,7 @@ describe('CSOT driver tests', metadata, () => {
33
33
let db : Db ;
34
34
let coll : Collection ;
35
35
36
- beforeEach ( async function ( ) {
36
+ beforeEach ( async function ( ) {
37
37
client = this . configuration . newClient ( undefined , { timeoutMS : 100 , minPoolSize } ) ;
38
38
db = client . db ( 'test' , { timeoutMS : 200 } ) ;
39
39
} ) ;
@@ -110,15 +110,15 @@ describe('CSOT driver tests', metadata, () => {
110
110
describe ( 'autoconnect' , ( ) => {
111
111
let client : MongoClient ;
112
112
113
- afterEach ( async function ( ) {
113
+ afterEach ( async function ( ) {
114
114
await client ?. close ( ) ;
115
115
client = undefined ;
116
116
} ) ;
117
117
118
118
describe ( 'when failing autoconnect with timeoutMS defined' , ( ) => {
119
119
let configClient : MongoClient ;
120
120
121
- beforeEach ( async function ( ) {
121
+ beforeEach ( async function ( ) {
122
122
configClient = this . configuration . newClient ( ) ;
123
123
const result = await configClient
124
124
. db ( )
@@ -135,7 +135,7 @@ describe('CSOT driver tests', metadata, () => {
135
135
expect ( result ) . to . have . property ( 'ok' , 1 ) ;
136
136
} ) ;
137
137
138
- afterEach ( async function ( ) {
138
+ afterEach ( async function ( ) {
139
139
const result = await configClient
140
140
. db ( )
141
141
. admin ( )
@@ -154,7 +154,7 @@ describe('CSOT driver tests', metadata, () => {
154
154
155
155
it ( 'throws a MongoOperationTimeoutError' , {
156
156
metadata : { requires : { mongodb : '>=4.4' , topology : '!load-balanced' } } ,
157
- test : async function ( ) {
157
+ test : async function ( ) {
158
158
const commandsStarted = [ ] ;
159
159
client = this . configuration . newClient ( undefined , { timeoutMS : 1 , monitorCommands : true } ) ;
160
160
@@ -183,7 +183,7 @@ describe('CSOT driver tests', metadata, () => {
183
183
let commandsSucceeded : CommandSucceededEvent [ ] ;
184
184
let commandsFailed : CommandFailedEvent [ ] ;
185
185
186
- beforeEach ( async function ( ) {
186
+ beforeEach ( async function ( ) {
187
187
client = this . configuration . newClient ( { timeoutMS : 500_000 , monitorCommands : true } ) ;
188
188
commandsSucceeded = [ ] ;
189
189
commandsFailed = [ ] ;
@@ -194,7 +194,7 @@ describe('CSOT driver tests', metadata, () => {
194
194
client . on ( 'commandFailed' , event => commandsFailed . push ( event ) ) ;
195
195
} ) ;
196
196
197
- afterEach ( async function ( ) {
197
+ afterEach ( async function ( ) {
198
198
await client
199
199
. db ( )
200
200
. collection ( 'a' )
@@ -216,7 +216,7 @@ describe('CSOT driver tests', metadata, () => {
216
216
}
217
217
} ;
218
218
219
- beforeEach ( async function ( ) {
219
+ beforeEach ( async function ( ) {
220
220
if ( semver . satisfies ( this . configuration . version , '>=4.4' ) )
221
221
await client . db ( 'admin' ) . command ( failpoint ) ;
222
222
else {
@@ -225,7 +225,7 @@ describe('CSOT driver tests', metadata, () => {
225
225
}
226
226
} ) ;
227
227
228
- afterEach ( async function ( ) {
228
+ afterEach ( async function ( ) {
229
229
if ( semver . satisfies ( this . configuration . version , '>=4.4' ) )
230
230
await client . db ( 'admin' ) . command ( { ...failpoint , mode : 'off' } ) ;
231
231
} ) ;
@@ -266,7 +266,7 @@ describe('CSOT driver tests', metadata, () => {
266
266
const readManyStub = sinon
267
267
// @ts -expect-error: readMany is private
268
268
. stub ( Connection . prototype , 'readMany' )
269
- . callsFake ( async function * ( ...args ) {
269
+ . callsFake ( async function * ( ...args ) {
270
270
const realIterator = readManyStub . wrappedMethod . call ( this , ...args ) ;
271
271
const cmd = commandSpy . lastCall . args . at ( 1 ) ;
272
272
if ( 'giveMeWriteErrors' in cmd ) {
@@ -309,7 +309,7 @@ describe('CSOT driver tests', metadata, () => {
309
309
}
310
310
} ;
311
311
312
- beforeEach ( async function ( ) {
312
+ beforeEach ( async function ( ) {
313
313
if ( semver . satisfies ( this . configuration . version , '>=4.4' ) )
314
314
await client . db ( 'admin' ) . command ( failpoint ) ;
315
315
else {
@@ -318,7 +318,7 @@ describe('CSOT driver tests', metadata, () => {
318
318
}
319
319
} ) ;
320
320
321
- afterEach ( async function ( ) {
321
+ afterEach ( async function ( ) {
322
322
if ( semver . satisfies ( this . configuration . version , '>=4.4' ) )
323
323
await client . db ( 'admin' ) . command ( { ...failpoint , mode : 'off' } ) ;
324
324
} ) ;
@@ -358,7 +358,7 @@ describe('CSOT driver tests', metadata, () => {
358
358
}
359
359
} ;
360
360
361
- beforeEach ( async function ( ) {
361
+ beforeEach ( async function ( ) {
362
362
internalClient = this . configuration . newClient ( ) ;
363
363
await internalClient
364
364
. db ( 'db' )
@@ -382,7 +382,7 @@ describe('CSOT driver tests', metadata, () => {
382
382
client . on ( 'commandSucceeded' , ev => commandSucceeded . push ( ev ) ) ;
383
383
} ) ;
384
384
385
- afterEach ( async function ( ) {
385
+ afterEach ( async function ( ) {
386
386
await internalClient
387
387
. db ( )
388
388
. admin ( )
@@ -396,7 +396,7 @@ describe('CSOT driver tests', metadata, () => {
396
396
it (
397
397
'must apply the configured timeoutMS to the initial operation execution' ,
398
398
metadata ,
399
- async function ( ) {
399
+ async function ( ) {
400
400
const cursor = client
401
401
. db ( 'db' )
402
402
. collection ( 'coll' )
@@ -412,7 +412,7 @@ describe('CSOT driver tests', metadata, () => {
412
412
}
413
413
) ;
414
414
415
- it ( 'refreshes the timeout for any getMores' , metadata , async function ( ) {
415
+ it ( 'refreshes the timeout for any getMores' , metadata , async function ( ) {
416
416
const cursor = client
417
417
. db ( 'db' )
418
418
. collection ( 'coll' )
@@ -434,7 +434,7 @@ describe('CSOT driver tests', metadata, () => {
434
434
it (
435
435
'does not append a maxTimeMS to the original command or getMores' ,
436
436
metadata ,
437
- async function ( ) {
437
+ async function ( ) {
438
438
const cursor = client
439
439
. db ( 'db' )
440
440
. collection ( 'coll' )
@@ -472,7 +472,7 @@ describe('CSOT driver tests', metadata, () => {
472
472
}
473
473
} ;
474
474
475
- beforeEach ( async function ( ) {
475
+ beforeEach ( async function ( ) {
476
476
internalClient = this . configuration . newClient ( ) ;
477
477
await internalClient
478
478
. db ( 'db' )
@@ -496,7 +496,7 @@ describe('CSOT driver tests', metadata, () => {
496
496
client . on ( 'commandSucceeded' , ev => commandSucceeded . push ( ev ) ) ;
497
497
} ) ;
498
498
499
- afterEach ( async function ( ) {
499
+ afterEach ( async function ( ) {
500
500
await internalClient
501
501
. db ( )
502
502
. admin ( )
@@ -508,7 +508,7 @@ describe('CSOT driver tests', metadata, () => {
508
508
context (
509
509
'when there are documents available from previously retrieved batch and timeout has expired' ,
510
510
( ) => {
511
- it ( 'returns documents without error' , metadata , async function ( ) {
511
+ it ( 'returns documents without error' , metadata , async function ( ) {
512
512
const cursor = client
513
513
. db ( 'db' )
514
514
. collection ( 'coll' )
@@ -531,7 +531,7 @@ describe('CSOT driver tests', metadata, () => {
531
531
}
532
532
) ;
533
533
context ( 'when a getMore is required and the timeout has expired' , ( ) => {
534
- it ( 'throws a MongoOperationTimeoutError' , metadata , async function ( ) {
534
+ it ( 'throws a MongoOperationTimeoutError' , metadata , async function ( ) {
535
535
const cursor = client
536
536
. db ( 'db' )
537
537
. collection ( 'coll' )
@@ -554,7 +554,7 @@ describe('CSOT driver tests', metadata, () => {
554
554
} ) ;
555
555
} ) ;
556
556
557
- it ( 'does not apply maxTimeMS to a getMore' , metadata , async function ( ) {
557
+ it ( 'does not apply maxTimeMS to a getMore' , metadata , async function ( ) {
558
558
const cursor = client
559
559
. db ( 'db' )
560
560
. collection ( 'coll' )
@@ -578,10 +578,13 @@ describe('CSOT driver tests', metadata, () => {
578
578
} ) ;
579
579
} ) ;
580
580
581
- describe ( 'Tailable cursors' , function ( ) {
581
+ describe ( 'Tailable cursors' , function ( ) {
582
582
let client : MongoClient ;
583
583
let internalClient : MongoClient ;
584
584
let commandStarted : CommandStartedEvent [ ] ;
585
+ const metadata : MongoDBMetadataUI = {
586
+ requires : { mongodb : '>=4.4' }
587
+ } ;
585
588
586
589
const failpoint : FailPoint = {
587
590
configureFailPoint : 'failCommand' ,
@@ -593,7 +596,7 @@ describe('CSOT driver tests', metadata, () => {
593
596
}
594
597
} ;
595
598
596
- beforeEach ( async function ( ) {
599
+ beforeEach ( async function ( ) {
597
600
internalClient = this . configuration . newClient ( ) ;
598
601
await internalClient
599
602
. db ( 'db' )
@@ -619,7 +622,7 @@ describe('CSOT driver tests', metadata, () => {
619
622
await client . connect ( ) ;
620
623
} ) ;
621
624
622
- afterEach ( async function ( ) {
625
+ afterEach ( async function ( ) {
623
626
await internalClient
624
627
. db ( )
625
628
. admin ( )
@@ -628,14 +631,14 @@ describe('CSOT driver tests', metadata, () => {
628
631
await client . close ( ) ;
629
632
} ) ;
630
633
631
- context ( 'when in ITERATION mode' , function ( ) {
632
- context ( 'awaitData cursors' , function ( ) {
634
+ context ( 'when in ITERATION mode' , function ( ) {
635
+ context ( 'awaitData cursors' , function ( ) {
633
636
let cursor : FindCursor ;
634
- afterEach ( async function ( ) {
637
+ afterEach ( async function ( ) {
635
638
if ( cursor ) await cursor . close ( ) ;
636
639
} ) ;
637
640
638
- it ( 'applies timeoutMS to initial command' , async function ( ) {
641
+ it ( 'applies timeoutMS to initial command' , metadata , async function ( ) {
639
642
cursor = client
640
643
. db ( 'db' )
641
644
. collection ( 'coll' )
@@ -647,7 +650,7 @@ describe('CSOT driver tests', metadata, () => {
647
650
expect ( maybeError ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
648
651
} ) ;
649
652
650
- it ( 'refreshes the timeout for subsequent getMores' , async function ( ) {
653
+ it ( 'refreshes the timeout for subsequent getMores' , async function ( ) {
651
654
cursor = client
652
655
. db ( 'db' )
653
656
. collection ( 'coll' )
@@ -659,7 +662,7 @@ describe('CSOT driver tests', metadata, () => {
659
662
}
660
663
} ) ;
661
664
662
- it ( 'does not use timeoutMS to compute maxTimeMS for getMores' , async function ( ) {
665
+ it ( 'does not use timeoutMS to compute maxTimeMS for getMores' , metadata , async function ( ) {
663
666
cursor = client
664
667
. db ( 'db' )
665
668
. collection ( 'coll' )
@@ -676,8 +679,8 @@ describe('CSOT driver tests', metadata, () => {
676
679
expect ( getMore ) . to . not . haveOwnProperty ( 'maxTimeMS' ) ;
677
680
} ) ;
678
681
679
- context ( 'when maxAwaitTimeMS is specified' , function ( ) {
680
- it ( 'sets maxTimeMS to the configured maxAwaitTimeMS value on getMores' , async function ( ) {
682
+ context ( 'when maxAwaitTimeMS is specified' , function ( ) {
683
+ it ( 'sets maxTimeMS to the configured maxAwaitTimeMS value on getMores' , metadata , async function ( ) {
681
684
cursor = client . db ( 'db' ) . collection ( 'coll' ) . find (
682
685
{ } ,
683
686
{
@@ -703,14 +706,14 @@ describe('CSOT driver tests', metadata, () => {
703
706
} ) ;
704
707
} ) ;
705
708
706
- context ( 'non-awaitData cursors' , function ( ) {
709
+ context ( 'non-awaitData cursors' , function ( ) {
707
710
let cursor : FindCursor ;
708
711
709
- afterEach ( async function ( ) {
712
+ afterEach ( async function ( ) {
710
713
if ( cursor ) await cursor . close ( ) ;
711
714
} ) ;
712
715
713
- it ( 'applies timeoutMS to initial command' , async function ( ) {
716
+ it ( 'applies timeoutMS to initial command' , metadata , async function ( ) {
714
717
cursor = client
715
718
. db ( 'db' )
716
719
. collection ( 'coll' )
@@ -722,7 +725,7 @@ describe('CSOT driver tests', metadata, () => {
722
725
expect ( maybeError ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
723
726
} ) ;
724
727
725
- it ( 'refreshes the timeout for subsequent getMores' , async function ( ) {
728
+ it ( 'refreshes the timeout for subsequent getMores' , metadata , async function ( ) {
726
729
cursor = client
727
730
. db ( 'db' )
728
731
. collection ( 'coll' )
@@ -734,7 +737,7 @@ describe('CSOT driver tests', metadata, () => {
734
737
}
735
738
} ) ;
736
739
737
- it ( 'does not append a maxTimeMS field to original command' , async function ( ) {
740
+ it ( 'does not append a maxTimeMS field to original command' , metadata , async function ( ) {
738
741
cursor = client
739
742
. db ( 'db' )
740
743
. collection ( 'coll' )
@@ -747,7 +750,7 @@ describe('CSOT driver tests', metadata, () => {
747
750
expect ( finds [ 0 ] . command . find ) . to . exist ;
748
751
expect ( finds [ 0 ] . command . maxTimeMS ) . to . not . exist ;
749
752
} ) ;
750
- it ( 'does not append a maxTimeMS field to subsequent getMores' , async function ( ) {
753
+ it ( 'does not append a maxTimeMS field to subsequent getMores' , metadata , async function ( ) {
751
754
cursor = client
752
755
. db ( 'db' )
753
756
. collection ( 'coll' )
@@ -775,11 +778,11 @@ describe('CSOT driver tests', metadata, () => {
775
778
describe ( 'passing a timeoutMS and a session with a timeoutContext' , ( ) => {
776
779
let client : MongoClient ;
777
780
778
- beforeEach ( async function ( ) {
781
+ beforeEach ( async function ( ) {
779
782
client = this . configuration . newClient ( { timeoutMS : 123 } ) ;
780
783
} ) ;
781
784
782
- afterEach ( async function ( ) {
785
+ afterEach ( async function ( ) {
783
786
await client . close ( ) ;
784
787
} ) ;
785
788
@@ -811,15 +814,15 @@ describe('CSOT driver tests', metadata, () => {
811
814
describe ( 'passing a timeoutMS and a session with an inherited timeoutMS' , ( ) => {
812
815
let client : MongoClient ;
813
816
814
- beforeEach ( async function ( ) {
817
+ beforeEach ( async function ( ) {
815
818
client = this . configuration . newClient ( { timeoutMS : 123 } ) ;
816
819
await client
817
820
. db ( 'db' )
818
821
. dropCollection ( 'coll' )
819
822
. catch ( ( ) => null ) ;
820
823
} ) ;
821
824
822
- afterEach ( async function ( ) {
825
+ afterEach ( async function ( ) {
823
826
await client . close ( ) ;
824
827
} ) ;
825
828
@@ -851,7 +854,7 @@ describe('CSOT driver tests', metadata, () => {
851
854
}
852
855
} ;
853
856
854
- beforeEach ( async function ( ) {
857
+ beforeEach ( async function ( ) {
855
858
if ( ! semver . satisfies ( this . configuration . version , '>=4.4' ) ) {
856
859
this . skipReason = 'Requires server version 4.4+' ;
857
860
this . skip ( ) ;
@@ -868,7 +871,7 @@ describe('CSOT driver tests', metadata, () => {
868
871
869
872
let client : MongoClient ;
870
873
871
- afterEach ( async function ( ) {
874
+ afterEach ( async function ( ) {
872
875
if ( semver . satisfies ( this . configuration . version , '>=4.4' ) ) {
873
876
const internalClient = this . configuration . newClient ( ) ;
874
877
await internalClient
@@ -882,7 +885,7 @@ describe('CSOT driver tests', metadata, () => {
882
885
it (
883
886
'timeoutMS is refreshed for abortTransaction and the timeout error is thrown from the operation' ,
884
887
metadata ,
885
- async function ( ) {
888
+ async function ( ) {
886
889
const commandsFailed = [ ] ;
887
890
const commandsStarted = [ ] ;
888
891
0 commit comments