The YAML and JSON files in this directory are platform-independent tests meant to exercise a driver's implementation of retryable reads. These tests utilize the Unified Test Format.
Several prose tests, which are not easily expressed in YAML, are also presented in this file. Those tests will need to be manually implemented by each driver.
Drivers should test that retries do not occur immediately when a SystemOverloadedError is encountered.
- Let
clientbe aMongoClient - Let
collectionbe a collection - Now, run transactions without backoff:
-
Configure the random number generator used for jitter to always return
0-- this effectively disables backoff. -
Configure the following failPoint:
{ configureFailPoint: 'failCommand', mode: 'alwaysOn', data: { failCommands: ['insert'], errorCode: 2, errorLabels: ['SystemOverloadedError', 'RetryableError'] } }
-
Insert the document
{ a: 1 }. Expect that the command errors. Measure the duration of the command execution.const start = performance.now(); expect( await coll.insertOne({ a: 1 }).catch(e => e) ).to.be.an.instanceof(MongoServerError); const end = performance.now();
-
Configure the random number generator used for jitter to always return
1. -
Execute step 3 again.
-
Compare the two time between the two runs.
assertTrue(with_backoff_time - no_backoff_time >= 2.1)
The sum of 5 backoffs is 3.1 seconds. There is a 1-second window to account for potential variance between the two runs.
-