@@ -157,6 +157,8 @@ describe('Retryable Reads Spec Prose', () => {
157157 const commandSucceededEvents : CommandSucceededEvent [ ] = [ ] ;
158158
159159 beforeEach ( async function ( ) {
160+ // 1. Create a client `client` with `retryReads=true`, `readPreference=primaryPreferred`, and command event monitoring
161+ // enabled.
160162 client = this . configuration . newClient ( {
161163 retryReads : true ,
162164 readPreference : 'primaryPreferred' ,
@@ -168,6 +170,18 @@ describe('Retryable Reads Spec Prose', () => {
168170
169171 await client . connect ( ) ;
170172
173+ /*
174+ * 2. Configure the following fail point for `client`:
175+ {
176+ configureFailPoint: "failCommand",
177+ mode: { times: 1 },
178+ data: {
179+ failCommands: ["find"],
180+ errorLabels: ["RetryableError", "SystemOverloadedError"]
181+ errorCode: 6
182+ }
183+ }
184+ * */
171185 await client . db ( 'admin' ) . command ( {
172186 configureFailPoint : 'failCommand' ,
173187 mode : { times : 1 } ,
@@ -178,6 +192,7 @@ describe('Retryable Reads Spec Prose', () => {
178192 }
179193 } ) ;
180194
195+ // 3. Reset the command event monitor to clear the failpoint command from its stored events.
181196 commandFailedEvents . length = 0 ;
182197 commandSucceededEvents . length = 0 ;
183198 } ) ;
@@ -188,10 +203,14 @@ describe('Retryable Reads Spec Prose', () => {
188203 } ) ;
189204
190205 it ( 'retries on a different server when SystemOverloadedError' , TEST_METADATA , async ( ) => {
206+ // 4. Execute a `find` command with `client`.
191207 await client . db ( 'test' ) . collection ( 'test' ) . find ( ) . toArray ( ) ;
192208
209+ // 5. Assert that one failed command event and one successful command event occurred.
193210 expect ( commandFailedEvents ) . to . have . lengthOf ( 1 ) ;
194211 expect ( commandSucceededEvents ) . to . have . lengthOf ( 1 ) ;
212+
213+ // 6. Assert that both events occurred on different servers.
195214 expect ( commandFailedEvents [ 0 ] . address ) . to . not . equal ( commandSucceededEvents [ 0 ] . address ) ;
196215 } ) ;
197216 } ) ;
@@ -202,6 +221,8 @@ describe('Retryable Reads Spec Prose', () => {
202221 const commandSucceededEvents : CommandSucceededEvent [ ] = [ ] ;
203222
204223 beforeEach ( async function ( ) {
224+ // 1. Create a client `client` with `retryReads=true`, `readPreference=primaryPreferred`, and command event monitoring
225+ // enabled.
205226 client = this . configuration . newClient ( {
206227 retryReads : true ,
207228 readPreference : 'primaryPreferred' ,
@@ -213,6 +234,18 @@ describe('Retryable Reads Spec Prose', () => {
213234
214235 await client . connect ( ) ;
215236
237+ /*
238+ * 2. Configure the following fail point for `client`:
239+ {
240+ configureFailPoint: "failCommand",
241+ mode: { times: 1 },
242+ data: {
243+ failCommands: ["find"],
244+ errorLabels: ["RetryableError"]
245+ errorCode: 6
246+ }
247+ }
248+ * */
216249 await client . db ( 'admin' ) . command ( {
217250 configureFailPoint : 'failCommand' ,
218251 mode : { times : 1 } ,
@@ -223,6 +256,7 @@ describe('Retryable Reads Spec Prose', () => {
223256 }
224257 } ) ;
225258
259+ // 3. Reset the command event monitor to clear the failpoint command from its stored events.
226260 commandFailedEvents . length = 0 ;
227261 commandSucceededEvents . length = 0 ;
228262 } ) ;
@@ -233,10 +267,14 @@ describe('Retryable Reads Spec Prose', () => {
233267 } ) ;
234268
235269 it ( 'retries on the same server when no SystemOverloadedError' , TEST_METADATA , async ( ) => {
270+ // 4. Execute a `find` command with `client`.
236271 await client . db ( 'test' ) . collection ( 'test' ) . find ( ) . toArray ( ) ;
237272
273+ // 5. Assert that one failed command event and one successful command event occurred.
238274 expect ( commandFailedEvents ) . to . have . lengthOf ( 1 ) ;
239275 expect ( commandSucceededEvents ) . to . have . lengthOf ( 1 ) ;
276+
277+ // 6. Assert that both events occurred on the same server.
240278 expect ( commandFailedEvents [ 0 ] . address ) . to . equal ( commandSucceededEvents [ 0 ] . address ) ;
241279 } ) ;
242280 } ) ;
0 commit comments