@@ -72,7 +72,7 @@ describe('Connection Pool', function () {
7272 } ) ;
7373 } ) ;
7474
75- const metadata : MongoDBMetadataUI = { requires : { mongodb : '>=4.4' , topology : 'single' } } ;
75+ const metadata : MongoDBMetadataUI = { requires : { mongodb : '>=4.4' } } ;
7676
7777 describe ( 'ConnectionCheckedInEvent' , metadata , function ( ) {
7878 let client : MongoClient ;
@@ -89,13 +89,13 @@ describe('Connection Pool', function () {
8989 configureFailPoint : 'failCommand' ,
9090 mode : 'alwaysOn' ,
9191 data : {
92- failCommands : [ 'insert ' ] ,
92+ failCommands : [ 'find ' ] ,
9393 blockConnection : true ,
9494 blockTimeMS : 500
9595 }
9696 } ) ;
9797
98- client = this . configuration . newClient ( ) ;
98+ client = this . configuration . newClient ( { } , { readPreference : 'secondaryPreferred' } ) ;
9999 await client . connect ( ) ;
100100 await Promise . all ( Array . from ( { length : 100 } , ( ) => client . db ( ) . command ( { ping : 1 } ) ) ) ;
101101 } ) ;
@@ -120,37 +120,37 @@ describe('Connection Pool', function () {
120120 . on ( 'connectionCheckedIn' , pushToClientEvents )
121121 . on ( 'connectionClosed' , pushToClientEvents ) ;
122122
123- const inserts = Promise . allSettled ( [
124- client . db ( 'test' ) . collection ( 'test' ) . insertOne ( { a : 1 } ) ,
125- client . db ( 'test' ) . collection ( 'test' ) . insertOne ( { a : 1 } ) ,
126- client . db ( 'test' ) . collection ( 'test' ) . insertOne ( { a : 1 } )
123+ const finds = Promise . allSettled ( [
124+ client . db ( 'test' ) . collection ( 'test' ) . findOne ( { a : 1 } ) ,
125+ client . db ( 'test' ) . collection ( 'test' ) . findOne ( { a : 1 } ) ,
126+ client . db ( 'test' ) . collection ( 'test' ) . findOne ( { a : 1 } )
127127 ] ) ;
128128
129- // wait until all pings are pending on the server
129+ // wait until all finds are pending on the server
130130 while ( allClientEvents . filter ( e => e . name === 'connectionCheckedOut' ) . length < 3 ) {
131131 await sleep ( 1 ) ;
132132 }
133133
134- const insertConnectionIds = allClientEvents
134+ const findConnectionIds = allClientEvents
135135 . filter ( e => e . name === 'connectionCheckedOut' )
136136 . map ( ( { address, connectionId } ) => `${ address } + ${ connectionId } ` ) ;
137137
138138 await client . close ( ) ;
139139
140- const insertCheckInAndCloses = allClientEvents
140+ const findCheckInAndCloses = allClientEvents
141141 . filter ( e => e . name === 'connectionCheckedIn' || e . name === 'connectionClosed' )
142142 . filter ( ( { address, connectionId } ) =>
143- insertConnectionIds . includes ( `${ address } + ${ connectionId } ` )
143+ findConnectionIds . includes ( `${ address } + ${ connectionId } ` )
144144 ) ;
145145
146- expect ( insertCheckInAndCloses ) . to . have . lengthOf ( 6 ) ;
146+ expect ( findCheckInAndCloses ) . to . have . lengthOf ( 6 ) ;
147147
148148 // check that each check-in is followed by a close (not proceeded by one)
149- expect ( insertCheckInAndCloses . map ( e => e . name ) ) . to . deep . equal (
149+ expect ( findCheckInAndCloses . map ( e => e . name ) ) . to . deep . equal (
150150 Array . from ( { length : 3 } , ( ) => [ 'connectionCheckedIn' , 'connectionClosed' ] ) . flat ( 1 )
151151 ) ;
152152
153- await inserts ;
153+ await finds ;
154154 }
155155 ) ;
156156 } ) ;
0 commit comments