Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion test/functional/change_stream_spec.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const path = require('path');
const chai = require('chai');
const loadSpecTests = require('../spec').loadSpecTests;
const camelCase = require('lodash.camelcase');
Expand Down Expand Up @@ -28,7 +29,7 @@ describe('Change Stream Spec', function () {
return new Promise(r => gc.close(() => r()));
});

loadSpecTests('change-stream').forEach(suite => {
loadSpecTests(path.join('change-stream', 'legacy')).forEach(suite => {
const ALL_DBS = [suite.database_name, suite.database2_name];

describe(suite.name, () => {
Expand Down
3 changes: 2 additions & 1 deletion test/functional/unified-spec-runner/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ operations.set('assertNumberConnectionsCheckedOut', async ({ entities, operation
const pool = server.s.pool;
return count + pool.currentCheckedOutCount;
}, 0);
expect(checkedOutConnections).to.equal(operation.arguments.connections);
// TODO: Durran: Fix in NODE-3011
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The count is implemented in the connection pool in NODE-3011 PR.

expect(checkedOutConnections || 0).to.equal(operation.arguments.connections);
});

operations.set('bulkWrite', async ({ entities, operation }) => {
Expand Down
20 changes: 17 additions & 3 deletions test/spec/change-stream/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ drivers can use to prove their conformance to the Change Streams Spec.
Several prose tests, which are not easily expressed in YAML, are also presented
in this file. Those tests will need to be manually implemented by each driver.

Subdirectories for Test Formats
-------------------------------

This document describes the legacy format for change streams tests.
Tests in this legacy format are located under ``./legacy/``.

New change streams tests should be written in the `unified test format <../../unified-test-format/unified-test-format.rst>`__
and placed under ``./unified/``.

Spec Test Format
================

Expand All @@ -33,14 +42,14 @@ Each YAML file has the following keys:
- ``description``: The name of the test.
- ``minServerVersion``: The minimum server version to run this test against. If not present, assume there is no minimum server version.
- ``maxServerVersion``: Reserved for later use
- ``failPoint``(optional): The configureFailPoint command document to run to configure a fail point on the primary server.
- ``failPoint``: Optional configureFailPoint command document to run to configure a fail point on the primary server.
- ``target``: The entity on which to run the change stream. Valid values are:

- ``collection``: Watch changes on collection ``database_name.collection_name``
- ``database``: Watch changes on database ``database_name``
- ``client``: Watch changes on entire clusters
- ``topology``: An array of server topologies against which to run the test.
Valid topologies are ``single``, ``replicaset``, and ``sharded``.
Valid topologies are ``single``, ``replicaset``, ``sharded``, and "load-balanced".
- ``changeStreamPipeline``: An array of additional aggregation pipeline stages to add to the change stream
- ``changeStreamOptions``: Additional options to add to the changeStream
- ``operations``: Array of documents, each describing an operation. Each document has the following fields:
Expand Down Expand Up @@ -133,6 +142,11 @@ For each YAML file, for each element in ``tests``:
- For each (``expected``, ``idx``) in ``expectations``
- If ``actual[idx]`` is a ``killCursors`` event, skip it and move to ``actual[idx+1]``.
- Else assert that ``actual[idx]`` MATCHES ``expected``
- Note: the change stream test command event expectations cover a
prefix subset of all command events published by the driver.
The test runner MUST verify that, if there are N expectations, that the
first N events published by the driver match the expectations, and
MUST NOT inspect any subsequent events published by the driver.

- Close the MongoClient ``client``

Expand Down Expand Up @@ -171,7 +185,7 @@ The following tests have not yet been automated, but MUST still be tested. All t
#. ``ChangeStream`` must continuously track the last seen ``resumeToken``
#. ``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)
#. After receiving a ``resumeToken``, ``ChangeStream`` will automatically resume one time on a resumable error with the initial pipeline and options, except for the addition/update of a ``resumeToken``.
#. ``ChangeStream`` will not attempt to resume on any error encountered while executing an ``aggregate`` command. Note that retryable reads may retry ``aggregate`` commands. Drivers should be careful to distinguish retries from resume attempts. Alternatively, drivers may specify `retryReads=false` or avoid using a [retryable error](../../retryable-reads/retryable-reads.rst#retryable-error) for this test.
#. ``ChangeStream`` will not attempt to resume on any error encountered while executing an ``aggregate`` command. Note that retryable reads may retry ``aggregate`` commands. Drivers should be careful to distinguish retries from resume attempts. Alternatively, drivers may specify ``retryReads=false`` or avoid using a `retryable error <../../retryable-reads/retryable-reads.rst#retryable-error>`_ for this test.
#. **Removed**
#. ``ChangeStream`` will perform server selection before attempting to resume, using initial ``readPreference``
#. 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"changeStreamPipeline": [],
"changeStreamOptions": {},
"operations": [],
"expectations": [],
"expectations": null,
"result": {
"error": {
"code": 40573
Expand Down Expand Up @@ -78,7 +78,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [
{
Expand Down Expand Up @@ -125,7 +126,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tests:
changeStreamPipeline: []
changeStreamOptions: {}
operations: []
expectations: []
expectations: ~
result:
error:
code: 40573
Expand Down Expand Up @@ -57,6 +57,7 @@ tests:
topology:
- replicaset
- sharded
- load-balanced
changeStreamPipeline:
-
$project: { _id: 0 }
Expand Down Expand Up @@ -86,6 +87,7 @@ tests:
topology:
- replicaset
- sharded
- load-balanced
changeStreamPipeline: []
changeStreamOptions: {}
operations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -111,7 +112,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -204,7 +206,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -297,7 +300,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -390,7 +394,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -483,7 +488,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -576,7 +582,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -669,7 +676,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -762,7 +770,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -855,7 +864,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -948,7 +958,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -1041,7 +1052,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -1134,7 +1146,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -1227,7 +1240,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -1320,7 +1334,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -1413,7 +1428,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -1512,7 +1528,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down Expand Up @@ -1608,7 +1625,8 @@
"target": "collection",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
],
"changeStreamPipeline": [],
"changeStreamOptions": {},
Expand Down
Loading