Skip to content

Commit c51e737

Browse files
authored
DRIVERS-1096 Convert command monitoring tests to unified format (#1221)
1 parent 09ee1eb commit c51e737

Some content is hidden

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

42 files changed

+2814
-2569
lines changed

source/command-monitoring/command-monitoring.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Command Monitoring
1111
:Status: Approved
1212
:Type: Standards
1313
:Minimum Server Version: 2.4
14-
:Last Modified: 2021-08-30
14+
:Last Modified: 2022-05-18
1515
:Version: 1.10.0
1616

1717
.. contents::
@@ -505,9 +505,12 @@ Changelog
505505
15 APR 2021:
506506
- Added ``serviceId`` field to events.
507507

508-
5 MAY 2021
508+
5 MAY 2021:
509509
- Updated to use hello and legacy hello.
510510

511511
30 AUG 2021:
512512
- Added ``serverConnectionId`` field to ``CommandStartedEvent``, ``CommandSucceededEvent`` and
513513
``CommandFailedEvent``.
514+
515+
18 MAY 2022:
516+
- Converted legacy tests to the unified test format.

source/command-monitoring/tests/README.rst

Lines changed: 1 addition & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -12,120 +12,4 @@ Command Monitoring
1212
Testing
1313
=======
1414

15-
Tests in ``unified`` are implemented in the `Unified Test Format <../../unified-test-format/unified-test-format.rst>`__ and require
16-
schema version 1.0. Tests in ``legacy`` should be run as described below.
17-
18-
Tests are provided in YML and JSON format to assert proper upconversion of commands.
19-
20-
Database and Collection Names
21-
-----------------------------
22-
23-
The collection under test is specified in each test file with the fields
24-
``database_name`` and ``collection_name``.
25-
26-
Data
27-
----
28-
29-
The ``data`` at the beginning of each test file is the data that should exist in the
30-
collection under test before each test run.
31-
32-
Expectations
33-
------------
34-
35-
Fake Placeholder Values
36-
```````````````````````
37-
38-
When an attribute in an expectation contains the value ``"42"``, ``42`` or ``""``, this is a fake
39-
placeholder value indicating that a special case MUST be tested that could not be
40-
expressed in a YAML or JSON test. These cases are as follows:
41-
42-
Cursor Matching
43-
^^^^^^^^^^^^^^^
44-
45-
When encountering a ``cursor`` or ``getMore`` value of ``"42"`` in a test, the driver MUST assert
46-
that the values are equal to each other and greater than zero.
47-
48-
Errors
49-
^^^^^^
50-
51-
For write errors, ``code`` values of ``42`` MUST assert that the value is present and
52-
greater than zero. ``errmsg`` values of ``""`` MUST assert that the value is not empty
53-
(a string of length greater than 1).
54-
55-
OK Values
56-
^^^^^^^^^
57-
58-
The server is inconsistent on whether the ok values returned are integers or doubles so
59-
for simplicity the tests specify all expected values as doubles. Server 'ok' values of
60-
integers MUST be converted to doubles for comparison with the expected values.
61-
62-
Additional Values
63-
`````````````````
64-
65-
The expected events provide the minimum data that is required and can be tested. It is
66-
possible for more values to be present in the events, such as extra data provided when
67-
using sharded clusters or ``nModified`` field in updates. The driver MUST assert the
68-
expected data is present and also MUST allow for additional data to be present as well
69-
at the top level of the command document or reply document.
70-
71-
For example, say the client sends a causally-consistent "distinct" command with
72-
readConcern level "majority", like::
73-
74-
{
75-
"distinct": "collection",
76-
"key": "key",
77-
"readConcern":{
78-
"afterClusterTime": {"$timestamp":{"t":1522336030,"i":1}},
79-
"level":"majority"
80-
},
81-
"$clusterTime": {
82-
"clusterTime": { "$timestamp": { "i": 1, "t": 1522335530 } },
83-
"signature": {
84-
"hash": { "$binary": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "$type": "00" },
85-
"keyId": { "$numberLong": "0" }
86-
}
87-
},
88-
"lsid": {
89-
"id": { "$binary": "RaigP3oASqu+galPvRAfcg==", "$type": "04" }
90-
}
91-
}
92-
93-
Then it would pass a command-started event like the following YAML, because the
94-
fields not mentioned in the YAML are ignored::
95-
96-
command:
97-
distinct: collection
98-
key: key
99-
100-
However, if there are fields in command subdocuments that are not mentioned in
101-
the YAML, then the command does *not* pass the test::
102-
103-
command:
104-
distinct: collection
105-
key: key
106-
# Fails because the expected readConcern has no "afterClusterTime".
107-
readConcern:
108-
level: majority
109-
110-
Ignoring Tests Based On Server Version or Topology Type
111-
```````````````````````````````````````````````````````
112-
113-
Due to variations in server behavior, some tests may not be valid and MUST NOT be run on
114-
certain server versions or topology types. These tests are indicated with any of the
115-
following fields, which will be optionally provided at the ``description`` level of each
116-
test:
117-
118-
- ``ignore_if_server_version_greater_than`` (optional): If specified, the test MUST be
119-
skipped if the minor version of the server is greater than this minor version. The
120-
server's patch version MUST NOT be considered. For example, a value of ``3.0`` implies
121-
that the test can run on server version ``3.0.15`` but not ``3.1.0``.
122-
123-
- ``ignore_if_server_version_less_than`` (optional): If specified, the test MUST be
124-
skipped if the minor version of the server is less than this minor version. The
125-
server's patch version MUST NOT be considered. For example, a value of ``3.2`` implies
126-
that the test can run on server version ``3.2.0`` but not ``3.0.15``.
127-
128-
- ``ignore_if_topology_type`` (optional): An array of server topologies for which the test
129-
MUST be skipped. Valid topologies are "single", "replicaset", and "sharded".
130-
131-
Tests that have none of these fields MUST be run on all supported server versions.
15+
Tests in ``unified`` are implemented in the `Unified Test Format <../../unified-test-format/unified-test-format.rst>`__.

source/command-monitoring/tests/legacy/bulkWrite.json

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

source/command-monitoring/tests/legacy/bulkWrite.yml

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

0 commit comments

Comments
 (0)