Skip to content

Commit 85fa23f

Browse files
authored
DRIVERS-1710: Convert retryable reads spec tests to unified test format (#1536)
* Add retryable-reads to unified test format Makefile Regarding GridFS tests: Drivers may differ in how they query the chunks collection. For instance, PHPLIB queries the chunk's n field with $gte in addition to files_id. Rather than use $$matchAsRoot (schema version 1.13+) to emulate the legacy test behavior of ignoring extra fields, the commandStartedEvent assertion was relaxed and expectResult was introduced to assert that the file is read successfully. * Remove legacy test files and docs for legacy test format This also renumbers the prose tests
1 parent 345c243 commit 85fa23f

File tree

170 files changed

+35563
-22847
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+35563
-22847
lines changed

source/retryable-reads/tests/README.rst

Lines changed: 17 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -9,192 +9,18 @@ Retryable Reads Tests
99
Introduction
1010
============
1111

12-
The YAML and JSON files in the ``legacy`` and ``unified`` sub-directories are platform-independent tests
13-
that drivers can use to prove their conformance to the Retryable Reads spec. Tests in the
14-
``unified`` directory are written using the `Unified Test Format <../../unified-test-format/unified-test-format.md>`_.
15-
Tests in the ``legacy`` directory are written using the format described below.
12+
The YAML and JSON files in this directory are platform-independent tests meant
13+
to exercise a driver's implementation of retryable reads. These tests utilize
14+
the [Unified Test Format](../../unified-test-format/unified-test-format.md).
1615

17-
Prose tests, which are not easily expressed in YAML, are also presented
16+
Several prose tests, which are not easily expressed in YAML, are also presented
1817
in this file. Those tests will need to be manually implemented by each driver.
1918

20-
Tests will require a MongoClient created with options defined in the tests.
21-
Integration tests will require a running MongoDB cluster with server versions
22-
4.0 or later.
19+
Prose Tests
20+
===========
2321

24-
N.B. The spec specifies 3.6 as the minimum server version: however,
25-
``failCommand`` is not supported on 3.6, so for now, testing requires MongoDB
26-
4.0. Once `DRIVERS-560`_ is resolved, we will attempt to adapt its live failure
27-
integration tests to test Retryable Reads on MongoDB 3.6.
28-
29-
.. _DRIVERS-560: https://jira.mongodb.org/browse/DRIVERS-560
30-
31-
Server Fail Point
32-
=================
33-
34-
See: `Server Fail Point`_ in the Transactions spec test suite.
35-
36-
.. _Server Fail Point: ../../transactions/tests#server-fail-point
37-
38-
Disabling Fail Point after Test Execution
39-
-----------------------------------------
40-
41-
After each test that configures a fail point, drivers should disable the
42-
``failCommand`` fail point to avoid spurious failures in
43-
subsequent tests. The fail point may be disabled like so::
44-
45-
db.runCommand({
46-
configureFailPoint: "failCommand",
47-
mode: "off"
48-
});
49-
50-
Network Error Tests
51-
===================
52-
53-
Network error tests are expressed in YAML and should be run against a standalone,
54-
shard cluster, or single-node replica set.
55-
56-
57-
Test Format
58-
-----------
59-
60-
Each YAML file has the following keys:
61-
62-
- ``runOn`` (optional): An array of server version and/or topology requirements
63-
for which the tests can be run. If the test environment satisfies one or more
64-
of these requirements, the tests may be executed; otherwise, this file should
65-
be skipped. If this field is omitted, the tests can be assumed to have no
66-
particular requirements and should be executed. Each element will have some or
67-
all of the following fields:
68-
69-
- ``minServerVersion`` (optional): The minimum server version (inclusive)
70-
required to successfully run the tests. If this field is omitted, it should
71-
be assumed that there is no lower bound on the required server version.
72-
73-
- ``maxServerVersion`` (optional): The maximum server version (inclusive)
74-
against which the tests can be run successfully. If this field is omitted,
75-
it should be assumed that there is no upper bound on the required server
76-
version.
77-
78-
- ``topology`` (optional): An array of server topologies against which the
79-
tests can be run successfully. Valid topologies are "single",
80-
"replicaset", "sharded", and "load-balanced". If this field is omitted,
81-
the default is all topologies (i.e. ``["single", "replicaset", "sharded",
82-
"load-balanced"]``).
83-
84-
- ``serverless``: (optional): Whether or not the test should be run on Atlas
85-
Serverless instances. Valid values are "require", "forbid", and "allow". If
86-
"require", the test MUST only be run on Atlas Serverless instances. If
87-
"forbid", the test MUST NOT be run on Atlas Serverless instances. If omitted
88-
or "allow", this option has no effect.
89-
90-
The test runner MUST be informed whether or not Atlas Serverless is being
91-
used in order to determine if this requirement is met (e.g. through an
92-
environment variable or configuration option).
93-
94-
Note: the Atlas Serverless proxy imitates mongos, so the test runner is not
95-
capable of determining if Atlas Serverless is in use by issuing commands
96-
such as ``buildInfo`` or ``hello``. Furthermore, connections to Atlas
97-
Serverless use a load balancer, so the topology will appear as
98-
"load-balanced".
99-
100-
- ``database_name`` and ``collection_name``: Optional. The database and
101-
collection to use for testing.
102-
103-
- ``bucket_name``: Optional. The GridFS bucket name to use for testing.
104-
105-
- ``data``: The data that should exist in the collection(s) under test before
106-
each test run. This will typically be an array of documents to be inserted
107-
into the collection under test (i.e. ``collection_name``); however, this field
108-
may also be an object mapping collection names to arrays of documents to be
109-
inserted into the specified collection.
110-
111-
- ``tests``: An array of tests that are to be run independently of each other.
112-
Each test will have some or all of the following fields:
113-
114-
- ``description``: The name of the test.
115-
116-
- ``clientOptions``: Optional, parameters to pass to MongoClient().
117-
118-
- ``useMultipleMongoses`` (optional): If ``true``, and the topology type is
119-
``Sharded``, the MongoClient for this test should be initialized with multiple
120-
mongos seed addresses. If ``false`` or omitted, only a single mongos address
121-
should be specified.
122-
123-
If ``true``, the topology type is ``LoadBalanced``, and Atlas Serverless is
124-
not being used, the MongoClient for this test should be initialized with the
125-
URI of the load balancer fronting multiple servers. If ``false`` or omitted,
126-
the MongoClient for this test should be initialized with the URI of the load
127-
balancer fronting a single server.
128-
129-
``useMultipleMongoses`` only affects ``Sharded`` and ``LoadBalanced``
130-
topologies (excluding Atlas Serverless).
131-
132-
- ``skipReason``: Optional, string describing why this test should be skipped.
133-
134-
- ``failPoint``: Optional, a server fail point to enable, expressed as the
135-
configureFailPoint command to run on the admin database.
136-
137-
- ``operations``: An array of documents describing an operation to be
138-
executed. Each document has the following fields:
139-
140-
- ``name``: The name of the operation on ``object``.
141-
142-
- ``object``: The name of the object to perform the operation on. Can be
143-
"database", "collection", "client", or "gridfsbucket."
144-
145-
- ``arguments``: Optional, the names and values of arguments.
146-
147-
- ``result``: Optional. The return value from the operation, if any. This
148-
field may be a scalar (e.g. in the case of a count), a single document, or
149-
an array of documents in the case of a multi-document read.
150-
151-
- ``error``: Optional. If ``true``, the test should expect an error or
152-
exception.
153-
154-
- ``expectations``: Optional list of command-started events.
155-
156-
GridFS Tests
157-
------------
158-
159-
GridFS tests are denoted by when the YAML file contains ``bucket_name``.
160-
The ``data`` field will also be an object, which maps collection names
161-
(e.g. ``fs.files``) to an array of documents that should be inserted into
162-
the specified collection.
163-
164-
``fs.files`` and ``fs.chunks`` should be created in the database
165-
specified by ``database_name``. This could be done via inserts or by
166-
creating GridFSBuckets—using the GridFS ``bucketName`` (see
167-
`GridFSBucket spec`_) specified by ``bucket_name`` field in the YAML
168-
file—and calling ``upload_from_stream_with_id`` with the appropriate
169-
data.
170-
171-
``Download`` tests should be tested against ``GridFS.download_to_stream``.
172-
``DownloadByName`` tests should be tested against
173-
``GridFS.download_to_stream_by_name``.
174-
175-
176-
.. _GridFSBucket spec: https://github.com/mongodb/specifications/blob/master../../gridfs/gridfs-spec.md#configurable-gridfsbucket-class
177-
178-
179-
Speeding Up Tests
180-
-----------------
181-
182-
Drivers can greatly reduce the execution time of tests by setting `heartbeatFrequencyMS`_
183-
and `minHeartbeatFrequencyMS`_ (internally) to a small value (e.g. 5ms), below what
184-
is normally permitted in the SDAM spec. If a test specifies an explicit value for
185-
heartbeatFrequencyMS (e.g. client or URI options), drivers MUST use that value.
186-
187-
.. _minHeartbeatFrequencyMS: ../../server-discovery-and-monitoring/server-discovery-and-monitoring.rst#minheartbeatfrequencyms
188-
.. _heartbeatFrequencyMS: ../../server-discovery-and-monitoring/server-discovery-and-monitoring.rst#heartbeatfrequencyms
189-
190-
Optional Enumeration Commands
191-
=============================
192-
193-
A driver only needs to test the optional enumeration commands it has chosen to
194-
implement (e.g. ``Database.listCollectionNames()``).
195-
196-
PoolClearedError Retryability Test
197-
==================================
22+
1. PoolClearedError Retryability Test
23+
-------------------------------------
19824

19925
This test will be used to ensure drivers properly retry after encountering PoolClearedErrors.
20026
It MUST be implemented by any driver that implements the CMAP specification.
@@ -232,8 +58,8 @@ This test requires MongoDB 4.2.9+ for ``blockConnection`` support in the failpoi
23258

23359
9. Disable the failpoint.
23460

235-
Retrying Reads in a Sharded Cluster
236-
===================================
61+
2. Retrying Reads in a Sharded Cluster
62+
--------------------------------------
23763

23864
These tests will be used to ensure drivers properly retry reads on a different
23965
mongos.
@@ -244,8 +70,8 @@ different mongos due to normal SDAM behavior of randomized suitable server
24470
selection". Verify relevant code paths are correctly executed by the tests using
24571
external means such as a logging, debugger, code coverage tool, etc.
24672

247-
Retryable Reads Are Retried on a Different mongos When One is Available
248-
-----------------------------------------------------------------------
73+
2.1 Retryable Reads Are Retried on a Different mongos When One is Available
74+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24975

25076
This test MUST be executed against a sharded cluster that has at least two
25177
mongos instances, supports ``retryReads=true``, and has enabled the
@@ -278,8 +104,8 @@ mongos instances, supports ``retryReads=true``, and has enabled the
278104
7. Disable the fail point on both ``s0`` and ``s1``.
279105

280106

281-
Retryable Reads Are Retried on the Same mongos When No Others are Available
282-
---------------------------------------------------------------------------
107+
2.2 Retryable Reads Are Retried on the Same mongos When No Others are Available
108+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
283109

284110
This test MUST be executed against a sharded cluster that supports
285111
``retryReads=true`` and has enabled the ``configureFailPoint`` command
@@ -316,10 +142,12 @@ This test MUST be executed against a sharded cluster that supports
316142
Changelog
317143
=========
318144

145+
:2024-03-06: Convert legacy retryable reads tests to unified format.
146+
319147
:2024-02-21: Update mongos redirection prose tests to workaround SDAM behavior
320148
preventing execution of deprioritization code paths.
321149

322-
:2023-08-26 Add prose tests for retrying in a sharded cluster.
150+
:2023-08-26: Add prose tests for retrying in a sharded cluster.
323151

324152
:2022-04-22: Clarifications to ``serverless`` and ``useMultipleMongoses``.
325153

source/retryable-reads/tests/legacy/aggregate-merge.json

Lines changed: 0 additions & 98 deletions
This file was deleted.

source/retryable-reads/tests/legacy/aggregate-merge.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)