Skip to content

Commit b67af3c

Browse files
authored
test(NODE-3011): lb support spec test changes (#2906)
* test: lb support spec test changes * test: don't use only in srv test
1 parent fa4352d commit b67af3c

File tree

315 files changed

+10133
-890
lines changed

Some content is hidden

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

315 files changed

+10133
-890
lines changed

test/functional/change_stream_spec.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
const path = require('path');
34
const chai = require('chai');
45
const loadSpecTests = require('../spec').loadSpecTests;
56
const camelCase = require('lodash.camelcase');
@@ -28,7 +29,7 @@ describe('Change Stream Spec', function () {
2829
return new Promise(r => gc.close(() => r()));
2930
});
3031

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

3435
describe(suite.name, () => {

test/functional/unified-spec-runner/operations.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ operations.set('assertNumberConnectionsCheckedOut', async ({ entities, operation
180180
const pool = server.s.pool;
181181
return count + pool.currentCheckedOutCount;
182182
}, 0);
183-
expect(checkedOutConnections).to.equal(operation.arguments.connections);
183+
// TODO: Durran: Fix in NODE-3011
184+
expect(checkedOutConnections || 0).to.equal(operation.arguments.connections);
184185
});
185186

186187
operations.set('bulkWrite', async ({ entities, operation }) => {

test/spec/change-stream/README.rst

+17-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ drivers can use to prove their conformance to the Change Streams Spec.
1818
Several prose tests, which are not easily expressed in YAML, are also presented
1919
in this file. Those tests will need to be manually implemented by each driver.
2020

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+
2130
Spec Test Format
2231
================
2332

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

3948
- ``collection``: Watch changes on collection ``database_name.collection_name``
4049
- ``database``: Watch changes on database ``database_name``
4150
- ``client``: Watch changes on entire clusters
4251
- ``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".
4453
- ``changeStreamPipeline``: An array of additional aggregation pipeline stages to add to the change stream
4554
- ``changeStreamOptions``: Additional options to add to the changeStream
4655
- ``operations``: Array of documents, each describing an operation. Each document has the following fields:
@@ -133,6 +142,11 @@ For each YAML file, for each element in ``tests``:
133142
- For each (``expected``, ``idx``) in ``expectations``
134143
- If ``actual[idx]`` is a ``killCursors`` event, skip it and move to ``actual[idx+1]``.
135144
- 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.
136150

137151
- Close the MongoClient ``client``
138152

@@ -171,7 +185,7 @@ The following tests have not yet been automated, but MUST still be tested. All t
171185
#. ``ChangeStream`` must continuously track the last seen ``resumeToken``
172186
#. ``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)
173187
#. 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``.
174-
#. ``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.
188+
#. ``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.
175189
#. **Removed**
176190
#. ``ChangeStream`` will perform server selection before attempting to resume, using initial ``readPreference``
177191
#. 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.

test/spec/change-stream/change-streams-errors.json renamed to test/spec/change-stream/legacy/change-streams-errors.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"changeStreamPipeline": [],
1515
"changeStreamOptions": {},
1616
"operations": [],
17-
"expectations": [],
17+
"expectations": null,
1818
"result": {
1919
"error": {
2020
"code": 40573
@@ -78,7 +78,8 @@
7878
"target": "collection",
7979
"topology": [
8080
"replicaset",
81-
"sharded"
81+
"sharded",
82+
"load-balanced"
8283
],
8384
"changeStreamPipeline": [
8485
{
@@ -125,7 +126,8 @@
125126
"target": "collection",
126127
"topology": [
127128
"replicaset",
128-
"sharded"
129+
"sharded",
130+
"load-balanced"
129131
],
130132
"changeStreamPipeline": [],
131133
"changeStreamOptions": {},

test/spec/change-stream/change-streams-errors.yml renamed to test/spec/change-stream/legacy/change-streams-errors.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tests:
1212
changeStreamPipeline: []
1313
changeStreamOptions: {}
1414
operations: []
15-
expectations: []
15+
expectations: ~
1616
result:
1717
error:
1818
code: 40573
@@ -57,6 +57,7 @@ tests:
5757
topology:
5858
- replicaset
5959
- sharded
60+
- load-balanced
6061
changeStreamPipeline:
6162
-
6263
$project: { _id: 0 }
@@ -86,6 +87,7 @@ tests:
8687
topology:
8788
- replicaset
8889
- sharded
90+
- load-balanced
8991
changeStreamPipeline: []
9092
changeStreamOptions: {}
9193
operations:

test/spec/change-stream/change-streams-resume-errorLabels.json renamed to test/spec/change-stream/legacy/change-streams-resume-errorLabels.json

+36-18
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"target": "collection",
1919
"topology": [
2020
"replicaset",
21-
"sharded"
21+
"sharded",
22+
"load-balanced"
2223
],
2324
"changeStreamPipeline": [],
2425
"changeStreamOptions": {},
@@ -111,7 +112,8 @@
111112
"target": "collection",
112113
"topology": [
113114
"replicaset",
114-
"sharded"
115+
"sharded",
116+
"load-balanced"
115117
],
116118
"changeStreamPipeline": [],
117119
"changeStreamOptions": {},
@@ -204,7 +206,8 @@
204206
"target": "collection",
205207
"topology": [
206208
"replicaset",
207-
"sharded"
209+
"sharded",
210+
"load-balanced"
208211
],
209212
"changeStreamPipeline": [],
210213
"changeStreamOptions": {},
@@ -297,7 +300,8 @@
297300
"target": "collection",
298301
"topology": [
299302
"replicaset",
300-
"sharded"
303+
"sharded",
304+
"load-balanced"
301305
],
302306
"changeStreamPipeline": [],
303307
"changeStreamOptions": {},
@@ -390,7 +394,8 @@
390394
"target": "collection",
391395
"topology": [
392396
"replicaset",
393-
"sharded"
397+
"sharded",
398+
"load-balanced"
394399
],
395400
"changeStreamPipeline": [],
396401
"changeStreamOptions": {},
@@ -483,7 +488,8 @@
483488
"target": "collection",
484489
"topology": [
485490
"replicaset",
486-
"sharded"
491+
"sharded",
492+
"load-balanced"
487493
],
488494
"changeStreamPipeline": [],
489495
"changeStreamOptions": {},
@@ -576,7 +582,8 @@
576582
"target": "collection",
577583
"topology": [
578584
"replicaset",
579-
"sharded"
585+
"sharded",
586+
"load-balanced"
580587
],
581588
"changeStreamPipeline": [],
582589
"changeStreamOptions": {},
@@ -669,7 +676,8 @@
669676
"target": "collection",
670677
"topology": [
671678
"replicaset",
672-
"sharded"
679+
"sharded",
680+
"load-balanced"
673681
],
674682
"changeStreamPipeline": [],
675683
"changeStreamOptions": {},
@@ -762,7 +770,8 @@
762770
"target": "collection",
763771
"topology": [
764772
"replicaset",
765-
"sharded"
773+
"sharded",
774+
"load-balanced"
766775
],
767776
"changeStreamPipeline": [],
768777
"changeStreamOptions": {},
@@ -855,7 +864,8 @@
855864
"target": "collection",
856865
"topology": [
857866
"replicaset",
858-
"sharded"
867+
"sharded",
868+
"load-balanced"
859869
],
860870
"changeStreamPipeline": [],
861871
"changeStreamOptions": {},
@@ -948,7 +958,8 @@
948958
"target": "collection",
949959
"topology": [
950960
"replicaset",
951-
"sharded"
961+
"sharded",
962+
"load-balanced"
952963
],
953964
"changeStreamPipeline": [],
954965
"changeStreamOptions": {},
@@ -1041,7 +1052,8 @@
10411052
"target": "collection",
10421053
"topology": [
10431054
"replicaset",
1044-
"sharded"
1055+
"sharded",
1056+
"load-balanced"
10451057
],
10461058
"changeStreamPipeline": [],
10471059
"changeStreamOptions": {},
@@ -1134,7 +1146,8 @@
11341146
"target": "collection",
11351147
"topology": [
11361148
"replicaset",
1137-
"sharded"
1149+
"sharded",
1150+
"load-balanced"
11381151
],
11391152
"changeStreamPipeline": [],
11401153
"changeStreamOptions": {},
@@ -1227,7 +1240,8 @@
12271240
"target": "collection",
12281241
"topology": [
12291242
"replicaset",
1230-
"sharded"
1243+
"sharded",
1244+
"load-balanced"
12311245
],
12321246
"changeStreamPipeline": [],
12331247
"changeStreamOptions": {},
@@ -1320,7 +1334,8 @@
13201334
"target": "collection",
13211335
"topology": [
13221336
"replicaset",
1323-
"sharded"
1337+
"sharded",
1338+
"load-balanced"
13241339
],
13251340
"changeStreamPipeline": [],
13261341
"changeStreamOptions": {},
@@ -1413,7 +1428,8 @@
14131428
"target": "collection",
14141429
"topology": [
14151430
"replicaset",
1416-
"sharded"
1431+
"sharded",
1432+
"load-balanced"
14171433
],
14181434
"changeStreamPipeline": [],
14191435
"changeStreamOptions": {},
@@ -1512,7 +1528,8 @@
15121528
"target": "collection",
15131529
"topology": [
15141530
"replicaset",
1515-
"sharded"
1531+
"sharded",
1532+
"load-balanced"
15161533
],
15171534
"changeStreamPipeline": [],
15181535
"changeStreamOptions": {},
@@ -1608,7 +1625,8 @@
16081625
"target": "collection",
16091626
"topology": [
16101627
"replicaset",
1611-
"sharded"
1628+
"sharded",
1629+
"load-balanced"
16121630
],
16131631
"changeStreamPipeline": [],
16141632
"changeStreamOptions": {},

0 commit comments

Comments
 (0)