You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: data/change-streams/README.rst
+19-5Lines changed: 19 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,15 @@ drivers can use to prove their conformance to the Change Streams Spec.
18
18
Several prose tests, which are not easily expressed in YAML, are also presented
19
19
in this file. Those tests will need to be manually implemented by each driver.
20
20
21
+
Subdirectories for Test Formats
22
+
-------------------------------
23
+
24
+
This document describes the legacy format for change streams tests.
25
+
Tests in this legacy format are located under ``./legacy/``.
26
+
27
+
New change streams tests should be written in the `unified test format <../../unified-test-format/unified-test-format.rst>`__
28
+
and placed under ``./unified/``.
29
+
21
30
Spec Test Format
22
31
================
23
32
@@ -35,12 +44,12 @@ Each YAML file has the following keys:
35
44
- ``maxServerVersion``: Reserved for later use
36
45
- ``failPoint``: Optional configureFailPoint command document to run to configure a fail point on the primary server.
37
46
- ``target``: The entity on which to run the change stream. Valid values are:
38
-
47
+
39
48
- ``collection``: Watch changes on collection ``database_name.collection_name``
40
49
- ``database``: Watch changes on database ``database_name``
41
50
- ``client``: Watch changes on entire clusters
42
51
- ``topology``: An array of server topologies against which to run the test.
43
-
Valid topologies are ``single``, ``replicaset``, and ``sharded``.
52
+
Valid topologies are ``single``, ``replicaset``, ``sharded``, and "load-balanced".
44
53
- ``changeStreamPipeline``: An array of additional aggregation pipeline stages to add to the change stream
45
54
- ``changeStreamOptions``: Additional options to add to the changeStream
46
55
- ``operations``: Array of documents, each describing an operation. Each document has the following fields:
@@ -68,7 +77,7 @@ The definition of MATCH or MATCHES in the Spec Test Runner is as follows:
68
77
Pseudocode implementation of ``actual`` MATCHES ``expected``:
69
78
70
79
::
71
-
80
+
72
81
If expected is "42" or 42:
73
82
Assert that actual exists (is not null or undefined)
74
83
Else:
@@ -112,7 +121,7 @@ For each YAML file, for each element in ``tests``:
112
121
Transactions spec test documentation for more information.
113
122
114
123
- Create a new MongoClient ``client``
115
-
- Begin monitoring all APM events for ``client``. (If the driver uses global listeners, filter out all events that do not originate with ``client``). Filter out any "internal" commands (e.g. ``isMaster``)
124
+
- Begin monitoring all APM events for ``client``. (If the driver uses global listeners, filter out all events that do not originate with ``client``). Filter out any "internal" commands (e.g. ``hello`` or legacy hello)
116
125
- Using ``client``, create a changeStream ``changeStream`` against the specified ``target``. Use ``changeStreamPipeline`` and ``changeStreamOptions`` if they are non-empty. Capture any error.
117
126
- If there was no error, use ``globalClient`` and run every operation in ``operations`` in serial against the server until all operations have been executed or an error is thrown. Capture any error.
118
127
- If there was no error and ``result.error`` is set, iterate ``changeStream`` once and capture any error.
@@ -133,6 +142,11 @@ For each YAML file, for each element in ``tests``:
133
142
- For each (``expected``, ``idx``) in ``expectations``
134
143
- If ``actual[idx]`` is a ``killCursors`` event, skip it and move to ``actual[idx+1]``.
135
144
- Else assert that ``actual[idx]`` MATCHES ``expected``
145
+
- Note: the change stream test command event expectations cover a
146
+
prefix subset of all command events published by the driver.
147
+
The test runner MUST verify that, if there are N expectations, that the
148
+
first N events published by the driver match the expectations, and
149
+
MUST NOT inspect any subsequent events published by the driver.
136
150
137
151
- Close the MongoClient ``client``
138
152
@@ -199,7 +213,7 @@ The following tests have not yet been automated, but MUST still be tested. All t
199
213
- If ``resumeAfter`` was not specified, the ``getResumeToken`` result must be empty.
200
214
201
215
#. For a ``ChangeStream`` under these conditions:
202
-
216
+
203
217
- The batch is not empty.
204
218
- The batch has been iterated up to but not including the last element.
0 commit comments