@@ -262,15 +262,173 @@ debugger, code coverage tool, etc.
262262
2632637. Disable the fail point on ` s0` .
264264
265+ ### 6. Test error propagation after encountering multiple errors.
266+
267+ These tests MUST :
268+
269+ - be implemented by any driver that implements the Command Monitoring specification.
270+ - only run against replica sets as mongos does not propagate the NoWritesPerformed label to the drivers.
271+ - be run against server versions 6.0 and above.
272+ - be implemented by any driver that has implemented the Client Backpressure specification.
273+
274+ Additionally, this test requires drivers to set a fail point after an ` insertOne` operation but before the subsequent
275+ retry . Drivers that are unable to set a failCommand after the CommandFailedEvent SHOULD use mocking or write a unit test
276+ to cover the same sequence of events.
277+
278+ #### Case 1 : Test that drivers return the correct error when receiving only errors without ` NoWritesPerformed`
279+
280+ 1. Create a client with ` retryWrites=true` .
281+
282+ 2. Configure a fail point with error code ` 91` (ShutdownInProgress) with the ` RetryableError` and
283+ ` SystemOverloadedError` error labels:
284+
285+ ` ` ` javascript
286+ {
287+ configureFailPoint: "failCommand",
288+ mode: {times: 1},
289+ data: {
290+ failCommands: ["insert"],
291+ errorLabels: ["RetryableError", "SystemOverloadedError"],
292+ errorCode: 91
293+ }
294+ }
295+ ` ` `
296+
297+ 3. Via the command monitoring CommandFailedEvent, configure a fail point with error code ` 10107` (NotWritablePrimary):
298+
299+ ` ` ` javascript
300+ {
301+ configureFailPoint: "failCommand",
302+ mode: "alwaysOn",
303+ data: {
304+ failCommands: ["insert"],
305+ errorCode: 10107,
306+ errorLabels: ["RetryableError", "SystemOverloadedError"]
307+ }
308+ }
309+ ` ` `
310+
311+ Configure the ` 10107` fail point command only if the the failed event is for the ` 91` error configured in step 2.
312+
313+ 4. Attempt an ` insertOne` operation on any record for any database and collection . Expect the ` insertOne` to fail with a
314+ server error . Assert that the error code of the server error is ` 10107` .
315+
316+ 5. Disable the fail point:
317+
318+ ` ` ` javascript
319+ {
320+ configureFailPoint: "failCommand",
321+ mode: "off"
322+ }
323+ ` ` `
324+
325+ #### Case 2 : Test that drivers return the correct error when receiving only errors with ` NoWritesPerformed`
326+
327+ 1. Create a client with ` retryWrites=true` .
328+
329+ 2. Configure a fail point with error code ` 91` (ShutdownInProgress) with the ` RetryableError` and
330+ ` SystemOverloadedError` error labels:
331+
332+ ` ` ` javascript
333+ {
334+ configureFailPoint: "failCommand",
335+ mode: {times: 1},
336+ data: {
337+ failCommands: ["insert"],
338+ errorLabels: ["RetryableError", "SystemOverloadedError", "NoWritesPerformed"],
339+ errorCode: 91
340+ }
341+ }
342+ ` ` `
343+
344+ 3. Via the command monitoring CommandFailedEvent, configure a fail point with error code ` 10107` (NotWritablePrimary)
345+ and a NoWritesPerformed label:
346+
347+ ` ` ` javascript
348+ {
349+ configureFailPoint: "failCommand",
350+ mode: "alwaysOn",
351+ data: {
352+ failCommands: ["insert"],
353+ errorCode: 10107,
354+ errorLabels: ["RetryableError", "SystemOverloadedError", "NoWritesPerformed"]
355+ }
356+ }
357+ ` ` `
358+
359+ Configure the ` 10107` fail point command only if the the failed event is for the ` 91` error configured in step 2.
360+
361+ 4. Attempt an ` insertOne` operation on any record for any database and collection . Expect the ` insertOne` to fail with a
362+ server error . Assert that the error code of the server error is 91.
363+
364+ 5. Disable the fail point:
365+
366+ ` ` ` javascript
367+ {
368+ configureFailPoint: "failCommand",
369+ mode: "off"
370+ }
371+ ` ` `
372+
373+ #### Case 3 : Test that drivers return the correct error when receiving some errors with ` NoWritesPerformed` and some without ` NoWritesPerformed`
374+
375+ 1. Create a client with ` retryWrites=true` and ` monitorCommands=true` .
376+
377+ 2. Configure the client to listen to CommandFailedEvents . In the attached listener, configure a fail point with error
378+ code ` 91` (NotWritablePrimary) and the ` NoWritesPerformed` , ` RetryableError` and ` SystemOverloadedError` labels:
379+
380+ ` ` ` javascript
381+ {
382+ configureFailPoint: "failCommand",
383+ mode: {times: 1},
384+ data: {
385+ failCommands: ["insert"],
386+ errorLabels: ["RetryableError", "SystemOverloadedError", "NoWritesPerformed"],
387+ errorCode: 91
388+ }
389+ }
390+ ` ` `
391+
392+ 3. Configure a fail point with error code ` 91` (ShutdownInProgress) with the ` RetryableError` and
393+ ` SystemOverloadedError` error labels but without the ` NoWritesPerformed` error label:
394+
395+ ` ` ` javascript
396+ {
397+ configureFailPoint: "failCommand",
398+ mode: {times: 1},
399+ data: {
400+ failCommands: ["insert"],
401+ errorLabels: ["RetryableError", "SystemOverloadedError"],
402+ errorCode: 91
403+ }
404+ }
405+ ` ` `
406+
407+ 4. Attempt an ` insertOne` operation on any record for any database and collection . Expect the ` insertOne` to fail with a
408+ server error . Assert that the error code of the server error is 91. Assert that the error does not contain the
409+ error label ` NoWritesPerformed` .
410+
411+ 5. Disable the fail point:
412+
413+ ` ` ` javascript
414+ {
415+ configureFailPoint: "failCommand",
416+ mode: "off"
417+ }
418+ ` ` `
419+
265420## Changelog
266421
422+ - 2026 - 02 - 03 : Add tests for error propagation behavior when multiple errors are encountered.
423+
267424- 2024 - 10 - 29 : Convert command construction tests to unified format.
268425
269426- 2024 - 05 - 30 : Migrated from reStructuredText to Markdown.
270427
271428- 2024 - 02 - 27 : Convert legacy retryable writes tests to unified format.
272429
273- - 2024 - 02 - 21 : Update prose test 4 and 5 to workaround SDAM behavior preventing execution of deprioritization code paths.
430+ - 2024 - 02 - 21 : Update prose tests 4 and 5 to workaround SDAM behavior preventing execution of deprioritization code
431+ paths.
274432
275433- 2024 - 01 - 05 : Fix typo in prose test title.
276434
0 commit comments