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
test(ChangeStream): update changeStream spec tests / test runner
- update changeStream spec tests
- update spec-test runner to comply with tests
- Adds a default value for expectations array in case there are no expectations
- Parses expected values through Extended JSON to ensure that they are in canonical format
- fix result assertion in change stream spec test
- get rid of EJSONToJSON
- add fail point to spec tests.
- Skips a test that will not pass until later features are added
- fix flakey test in Node 10.16
- fix race condition in test runner
Fixes NODE-2017
Copy file name to clipboardExpand all lines: test/functional/spec/change-stream/README.rst
+62-14
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ Each YAML file has the following keys:
33
33
- ``description``: The name of the test.
34
34
- ``minServerVersion``: The minimum server version to run this test against. If not present, assume there is no minimum server version.
35
35
- ``maxServerVersion``: Reserved for later use
36
-
- ``failPoint``: Reserved for later use
36
+
- ``failPoint``(optional): The configureFailPoint command document to run to configure a fail point on the primary server.
37
37
- ``target``: The entity on which to run the change stream. Valid values are:
38
38
39
39
- ``collection``: Watch changes on collection ``database_name.collection_name``
@@ -44,10 +44,11 @@ Each YAML file has the following keys:
44
44
- ``changeStreamPipeline``: An array of additional aggregation pipeline stages to add to the change stream
45
45
- ``changeStreamOptions``: Additional options to add to the changeStream
46
46
- ``operations``: Array of documents, each describing an operation. Each document has the following fields:
47
+
47
48
- ``database``: Database against which to run the operation
48
49
- ``collection``: Collection against which to run the operation
49
-
- ``commandName``: Name of the command to run
50
-
- ``arguments``: Object of arguments for the command (ex: document to insert)
50
+
- ``name``: Name of the command to run
51
+
- ``arguments`` (optional): Object of arguments for the command (ex: document to insert)
51
52
52
53
- ``expectations``: Optional list of command-started events in Extended JSON format
53
54
- ``result``: Document with ONE of the following fields:
@@ -103,6 +104,9 @@ For each YAML file, for each element in ``tests``:
103
104
- Drop the database ``database2_name``
104
105
- Create the database ``database_name`` and the collection ``database_name.collection_name``
105
106
- Create the database ``database2_name`` and the collection ``database2_name.collection2_name``
107
+
- If the the ``failPoint`` field is present, configure the fail point on the primary server. See
108
+
`Server Fail Point <../../transactions/tests#server-fail-point>`_ in the
109
+
Transactions spec test documentation for more information.
106
110
107
111
- Create a new MongoClient ``client``
108
112
- 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``)
@@ -117,12 +121,12 @@ For each YAML file, for each element in ``tests``:
117
121
- If there was an error:
118
122
119
123
- Assert that an error was expected for the test.
120
-
- Assert that the error MATCHES ``results.error``
124
+
- Assert that the error MATCHES ``result.error``
121
125
122
126
- Else:
123
127
124
128
- Assert that no error was expected for the test
125
-
- Assert that the changes received from ``changeStream`` MATCH the results in ``results.success``
129
+
- Assert that the changes received from ``changeStream`` MATCH the results in ``result.success``
126
130
127
131
- If there are any ``expectations``
128
132
@@ -144,12 +148,56 @@ Prose Tests
144
148
145
149
The following tests have not yet been automated, but MUST still be tested
146
150
147
-
1. ``ChangeStream`` must continuously track the last seen ``resumeToken``
148
-
2. ``ChangeStream`` will throw an exception if the server response is missing the resume token
149
-
3. ``ChangeStream`` will automatically resume one time on a resumable error (including `not master`) with the initial pipeline and options, except for the addition/update of a ``resumeToken``.
150
-
4. ``ChangeStream`` will not attempt to resume on a server error
151
-
5. ``ChangeStream`` will perform server selection before attempting to resume, using initial ``readPreference``
152
-
6. Ensure that a cursor returned from an aggregate command with a cursor id and an initial empty batch is not closed on the driver side.
153
-
7. The ``killCursors`` command sent during the "Resume Process" must not be allowed to throw an exception.
154
-
8. ``$changeStream`` stage for ``ChangeStream`` against a server ``>=4.0`` that has not received any results yet MUST include a ``startAtOperationTime`` option when resuming a changestream.
155
-
9. ``ChangeStream`` will resume after a ``killCursors`` command is issued for its child cursor.
151
+
#. ``ChangeStream`` must continuously track the last seen ``resumeToken``
152
+
#. ``ChangeStream`` will throw an exception if the server response is missing the resume token (if wire version is < 8, this is a driver-side error; for 8+, this is a server-side error)
153
+
#. ``ChangeStream`` will automatically resume one time on a resumable error (including `not master`) with the initial pipeline and options, except for the addition/update of a ``resumeToken``.
154
+
#. ``ChangeStream`` will not attempt to resume on any error encountered while executing an ``aggregate`` command.
155
+
#. ``ChangeStream`` will not attempt to resume after encountering error code 11601 (Interrupted), 136 (CappedPositionLost), or 237 (CursorKilled) while executing a ``getMore`` command.
156
+
#. ``ChangeStream`` will perform server selection before attempting to resume, using initial ``readPreference``
157
+
#. Ensure that a cursor returned from an aggregate command with a cursor id and an initial empty batch is not closed on the driver side.
158
+
#. The ``killCursors`` command sent during the "Resume Process" must not be allowed to throw an exception.
159
+
#. ``$changeStream`` stage for ``ChangeStream`` against a server ``>=4.0`` and ``<4.0.7`` that has not received any results yet MUST include a ``startAtOperationTime`` option when resuming a changestream.
160
+
#. ``ChangeStream`` will resume after a ``killCursors`` command is issued for its child cursor.
161
+
#. - For a ``ChangeStream`` under these conditions:
162
+
- Running against a server ``>=4.0.7``.
163
+
- The batch is empty or has been iterated to the last document.
164
+
- Expected result:
165
+
- ``getResumeToken`` must return the ``postBatchResumeToken`` from the current command response.
166
+
#. - For a ``ChangeStream`` under these conditions:
167
+
- Running against a server ``<4.0.7``.
168
+
- The batch is empty or has been iterated to the last document.
169
+
- Expected result:
170
+
- ``getResumeToken`` must return the ``_id`` of the last document returned if one exists.
171
+
- ``getResumeToken`` must return ``startAfter`` from the initial aggregate if the option was specified.
172
+
- ``getResumeToken`` must return ``resumeAfter`` from the initial aggregate if the option was specified.
173
+
- If neither the ``startAfter`` nor ``resumeAfter`` options were specified, the ``getResumeToken`` result must be empty.
174
+
#. - For a ``ChangeStream`` under these conditions:
175
+
- The batch is not empty.
176
+
- The batch has been iterated up to but not including the last element.
177
+
- Expected result:
178
+
- ``getResumeToken`` must return the ``_id`` of the previous document returned.
179
+
#. - For a ``ChangeStream`` under these conditions:
180
+
- The batch is not empty.
181
+
- The batch hasn’t been iterated at all.
182
+
- Only the initial ``aggregate`` command has been executed.
183
+
- Expected result:
184
+
- ``getResumeToken`` must return ``startAfter`` from the initial aggregate if the option was specified.
185
+
- ``getResumeToken`` must return ``resumeAfter`` from the initial aggregate if the option was specified.
186
+
- If neither the ``startAfter`` nor ``resumeAfter`` options were specified, the ``getResumeToken`` result must be empty.
187
+
#. - For a ``ChangeStream`` under these conditions:
188
+
- Running against a server ``>=4.0.7``.
189
+
- The batch is not empty.
190
+
- The batch hasn’t been iterated at all.
191
+
- The stream has iterated beyond a previous batch and a ``getMore`` command has just been executed.
192
+
- Expected result:
193
+
- ``getResumeToken`` must return the ``postBatchResumeToken`` from the previous command response.
194
+
#. - For a ``ChangeStream`` under these conditions:
195
+
- Running against a server ``<4.0.7``.
196
+
- The batch is not empty.
197
+
- The batch hasn’t been iterated at all.
198
+
- The stream has iterated beyond a previous batch and a ``getMore`` command has just been executed.
199
+
- Expected result:
200
+
- ``getResumeToken`` must return the ``_id`` of the previous document returned if one exists.
201
+
- ``getResumeToken`` must return ``startAfter`` from the initial aggregate if the option was specified.
202
+
- ``getResumeToken`` must return ``resumeAfter`` from the initial aggregate if the option was specified.
203
+
- If neither the ``startAfter`` nor ``resumeAfter`` options were specified, the ``getResumeToken`` result must be empty.
0 commit comments