Skip to content

Commit de58ec2

Browse files
committed
minor: sync new crud tests
1 parent 88e99fd commit de58ec2

File tree

91 files changed

+8689
-127
lines changed

Some content is hidden

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

91 files changed

+8689
-127
lines changed

src/test/spec/json/crud/README.rst

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@ version requirements as noted by the ``runOn`` section, if provided.
1919
Subdirectories for Test Formats
2020
-------------------------------
2121

22-
This document describes a current test format, which should be used for any new
23-
CRUD tests. Additionally, it refers to a "legacy" format, which dates back to
24-
the initial version of the CRUD specification. Until such time that all original
25-
tests have been ported to the current format, tests in each format will be
26-
grouped in their own subdirectory:
22+
This document describes two legacy formats for CRUD tests: legacy-v1, which dates back
23+
to the first version of the CRUD specification, and legacy-v2, which was an update to
24+
the initial format. New CRUD tests should be written in the `unified test format <../../../../unified-test-format/unified-test-format.rst>`_
25+
and placed under ``unified/``. Until such time that all original tests have been ported
26+
to the unified test format, tests in each format will be grouped in their own subdirectory:
2727

28-
- ``v1/``: Legacy format tests
29-
- ``v2/``: Current format tests
28+
- ``v1/``: Legacy-v1 format tests
29+
- ``v2/``: Legacy-v2 format tests
30+
- ``unified/``: Tests using the `unified test format <../../../../unified-test-format/unified-test-format.rst>`_
3031

3132
Since some drivers may not have a unified test runner capable of executing tests
32-
in both formats, segregating tests in this manner will make it easier for
33+
in all three formats, segregating tests in this manner will make it easier for
3334
drivers to sync and feed test files to different test runners.
3435

35-
Test Format
36-
===========
36+
Legacy-v2 Test Format
37+
=====================
3738

3839
*Note: this section pertains to test files in the "v2" directory.*
3940

@@ -128,17 +129,17 @@ Each YAML file has the following keys:
128129
present then use the collection under test.
129130

130131
- ``data``: The data that should exist in the collection after the
131-
operation has been run.
132+
operation has been run, sorted by "_id".
132133

133-
Legacy Test Format for Single Operations
134-
----------------------------------------
134+
Legacy-v1 Test Format for Single Operations
135+
-------------------------------------------
135136

136137
*Note: this section pertains to test files in the "v1" directory.*
137138

138139
The test format above supports both multiple operations and APM expectations,
139140
and is consistent with the formats used by other specifications. Previously, the
140141
CRUD spec tests used a simplified format that only allowed for executing a
141-
single operation. Notable differences from the current format are as follows:
142+
single operation. Notable differences from the legacy-v2 format are as follows:
142143

143144
- Instead of a ``tests[i].operations`` array, a single operation was defined as
144145
a document in ``tests[i].operation``. That document consisted of only the
@@ -156,9 +157,9 @@ single operation. Notable differences from the current format are as follows:
156157
field is not present, it should be assumed that there is no corresponding bound
157158
on the required server version.
158159

159-
The legacy format should not conflict with the newer, multi-operation format
160+
The legacy-v1 format should not conflict with the newer, multi-operation format
160161
used by other specs (e.g. Transactions). It is possible to create a unified test
161-
runner capable of executing both formats (as some drivers do).
162+
runner capable of executing both legacy formats (as some drivers do).
162163

163164
Error Assertions for Bulk Write Operations
164165
==========================================
@@ -172,7 +173,9 @@ messages into the bulk write exception's top-level message.
172173
Test Runner Implementation
173174
==========================
174175

175-
This section provides guidance for implementing a test runner.
176+
This section provides guidance for implementing a test runner for legacy-v1 and
177+
legacy-v2 tests. See the `unified test format spec <../../../../unified-test-format/unified-test-format.rst>`_ for how to run tests under
178+
``unified/``.
176179

177180
Before running the tests:
178181

@@ -246,6 +249,8 @@ For each test file:
246249

247250
- If the ``outcome`` field is present, assert the contents of the specified
248251
collection using ``globalMongoClient``.
252+
Note the server does not guarantee that documents returned by a find
253+
command will be in inserted order. This find MUST sort by ``{_id:1}``.
249254

250255
Evaluating Matches
251256
------------------
@@ -286,6 +291,14 @@ Note that in the case of result objects for some CRUD operations, ``expected``
286291
may condition additional, optional fields (see:
287292
`Optional Fields in Expected Result Objects`_).
288293

294+
Fields that must NOT be present in Actual Documents
295+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296+
297+
Some command-started events in ``expectations`` include ``null`` values for
298+
optional fields such as ``allowDiskUse``.
299+
Tests MUST assert that the actual command **omits** any field that has a
300+
``null`` value in the expected command.
301+
289302
Optional Fields in Expected Result Objects
290303
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291304

@@ -294,3 +307,35 @@ specification, such as ``insertedId`` (for InsertOneResult), ``insertedIds``
294307
(for InsertManyResult), and ``upsertedCount`` (for UpdateResult). Drivers that
295308
do not implement these fields should ignore them when comparing ``actual`` with
296309
``expected``.
310+
311+
Prose Tests
312+
===========
313+
314+
The following tests have not yet been automated, but MUST still be tested.
315+
316+
"errInfo" is propagated
317+
-----------------------
318+
Test that a writeConcernError "errInfo" is propagated to the user in whatever way is idiomatic to the driver (exception, error object, etc.). Using a 4.0+ server, set the following failpoint:
319+
320+
.. code:: javascript
321+
322+
{
323+
"configureFailPoint": "failCommand",
324+
"data": {
325+
"failCommands": ["insert"],
326+
"writeConcernError": {
327+
"code": 100,
328+
"codeName": "UnsatisfiableWriteConcern",
329+
"errmsg": "Not enough data-bearing nodes",
330+
"errInfo": {
331+
"writeConcern": {
332+
"w": 2,
333+
"wtimeout": 0,
334+
"provenance": "clientSupplied"
335+
}
336+
}
337+
}
338+
},
339+
"mode": { "times": 1 }
340+
}
341+
Then, perform an insert on the same database. Assert that an error occurs and that the "errInfo" is accessible and matches the one set in the failpoint.

0 commit comments

Comments
 (0)