Skip to content

Commit 098eb6e

Browse files
authored
test(NODE-4316): sync latest cmap tests for pool pausing (#3293)
1 parent aa5f97e commit 098eb6e

File tree

55 files changed

+954
-23
lines changed

Some content is hidden

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

55 files changed

+954
-23
lines changed

test/integration/connection-monitoring-and-pooling/connection_monitoring_and_pooling.spec.test.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,34 @@ const LB_SKIP_TESTS: SkipDescription[] = [
1212
skipReason: 'cannot run against a load balanced environment'
1313
}));
1414

15+
const POOL_PAUSED_SKIP_TESTS: SkipDescription[] = [
16+
'clearing pool clears the WaitQueue',
17+
'pool clear halts background minPoolSize establishments',
18+
'clearing a paused pool emits no events',
19+
'after clear, cannot check out connections until pool ready',
20+
'error during minPoolSize population clears pool',
21+
'readying a ready pool emits no events',
22+
'pool starts as cleared and becomes ready'
23+
].map(description => ({
24+
description,
25+
skipIfCondition: 'always',
26+
skipReason: 'TODO(NODE-2994): implement pool pausing'
27+
}));
28+
1529
describe('Connection Monitoring and Pooling Spec Tests (Integration)', function () {
1630
const tests: CmapTest[] = loadSpecTests('connection-monitoring-and-pooling');
1731

1832
runCmapTestSuite(tests, {
19-
testsToSkip: LB_SKIP_TESTS.concat([
20-
{
21-
description: 'waiting on maxConnecting is limited by WaitQueueTimeoutMS',
22-
skipIfCondition: 'always',
23-
skipReason:
24-
'not applicable: waitQueueTimeoutMS limits connection establishment time in our driver'
25-
}
26-
])
33+
testsToSkip: LB_SKIP_TESTS.concat(
34+
[
35+
{
36+
description: 'waiting on maxConnecting is limited by WaitQueueTimeoutMS',
37+
skipIfCondition: 'always',
38+
skipReason:
39+
'not applicable: waitQueueTimeoutMS limits connection establishment time in our driver'
40+
}
41+
],
42+
POOL_PAUSED_SKIP_TESTS
43+
)
2744
});
2845
});

test/spec/connection-monitoring-and-pooling/README.rst

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,32 @@ Common Test Format
2424
Each YAML file has the following keys:
2525

2626
- ``version``: A version number indicating the expected format of the spec tests (current version = 1)
27-
- ``style``: A string indicating what style of tests this file contains. Currently ``unit`` is the only valid value
27+
- ``style``: A string indicating what style of tests this file contains. Contains one of the following:
28+
29+
- ``"unit"``: a test that may be run without connecting to a MongoDB deployment.
30+
- ``"integration"``: a test that MUST be run against a real MongoDB deployment.
31+
2832
- ``description``: A text description of what the test is meant to assert
2933

3034
Unit Test Format:
3135
=================
3236

3337
All Unit Tests have some of the following fields:
3438

35-
- ``poolOptions``: if present, connection pool options to use when creating a pool
39+
- ``poolOptions``: If present, connection pool options to use when creating a pool;
40+
both `standard ConnectionPoolOptions <https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#connection-pool-options-1>`__
41+
and the following test-specific options are allowed:
42+
43+
- ``backgroundThreadIntervalMS``: A time interval between the end of a
44+
`Background Thread Run <https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#background-thread>`__
45+
and the beginning of the next Run. If a Connection Pool does not implement a Background Thread, the Test Runner MUST ignore the option.
46+
If the option is not specified, an implementation is free to use any value it finds reasonable.
47+
48+
Possible values (0 is not allowed):
49+
50+
- A negative value: never begin a Run.
51+
- A positive value: the interval between Runs in milliseconds.
52+
3653
- ``operations``: A list of operations to perform. All operations support the following fields:
3754

3855
- ``name``: A string describing which operation to issue.
@@ -68,10 +85,11 @@ Valid Unit Test Operations are the following:
6885

6986
- ``target``: The name of the thread to wait for.
7087

71-
- ``waitForEvent(event, count)``: block the current thread until ``event`` has occurred ``count`` times
88+
- ``waitForEvent(event, count, timeout)``: block the current thread until ``event`` has occurred ``count`` times
7289

7390
- ``event``: The name of the event
7491
- ``count``: The number of times the event must occur (counting from the start of the test)
92+
- ``timeout``: If specified, time out with an error after waiting for this many milliseconds without seeing the required events
7593

7694
- ``label = pool.checkOut()``: call ``checkOut`` on pool, returning the checked out connection
7795

@@ -83,6 +101,35 @@ Valid Unit Test Operations are the following:
83101

84102
- ``pool.clear()``: call ``clear`` on Pool
85103
- ``pool.close()``: call ``close`` on Pool
104+
- ``pool.ready()``: call ``ready`` on Pool
105+
106+
107+
Integration Test Format
108+
=======================
109+
110+
The integration test format is identical to the unit test format with
111+
the addition of the following fields to each test:
112+
113+
- ``runOn`` (optional): An array of server version and/or topology requirements
114+
for which the tests can be run. If the test environment satisfies one or more
115+
of these requirements, the tests may be executed; otherwise, this test should
116+
be skipped. If this field is omitted, the tests can be assumed to have no
117+
particular requirements and should be executed. Each element will have some or
118+
all of the following fields:
119+
120+
- ``minServerVersion`` (optional): The minimum server version (inclusive)
121+
required to successfully run the tests. If this field is omitted, it should
122+
be assumed that there is no lower bound on the required server version.
123+
124+
- ``maxServerVersion`` (optional): The maximum server version (inclusive)
125+
against which the tests can be run successfully. If this field is omitted,
126+
it should be assumed that there is no upper bound on the required server
127+
version.
128+
129+
- ``failPoint``: optional, a document containing a ``configureFailPoint``
130+
command to run against the endpoint being used for the test.
131+
132+
- ``poolOptions.appName`` (optional): appName attribute to be set in connections, which will be affected by the fail point.
86133

87134
Spec Test Match Function
88135
========================
@@ -122,11 +169,10 @@ For each YAML file with ``style: unit``:
122169
- If ``poolOptions`` is specified, use those options to initialize both pools
123170
- The returned pool must have an ``address`` set as a string value.
124171

125-
- Execute each ``operation`` in ``operations``
172+
- Process each ``operation`` in ``operations`` (on the main thread)
126173

127-
- If a ``thread`` is specified, execute in that corresponding thread. Otherwise, execute in the main thread.
174+
- If a ``thread`` is specified, the main thread MUST schedule the operation to execute in the corresponding thread. Otherwise, execute the operation directly in the main thread.
128175

129-
- Wait for the main thread to finish executing all of its operations
130176
- If ``error`` is presented
131177

132178
- Assert that an actual error ``actualError`` was thrown by the main thread
@@ -145,6 +191,30 @@ For each YAML file with ``style: unit``:
145191

146192
It is important to note that the ``ignore`` list is used for calculating ``actualEvents``, but is NOT used for the ``waitForEvent`` command
147193

194+
Integration Test Runner
195+
=======================
196+
197+
The steps to run the integration tests are the same as those used to run the
198+
unit tests with the following modifications:
199+
200+
- The integration tests MUST be run against an actual endpoint. If the
201+
deployment being tested contains multiple endpoints, then the runner MUST
202+
only use one of them to run the tests against.
203+
204+
- For each test, if `failPoint` is specified, its value is a
205+
``configureFailPoint`` command. Run the command on the admin database of the
206+
endpoint being tested to enable the fail point.
207+
208+
- At the end of each test, any enabled fail point MUST be disabled to avoid
209+
spurious failures in subsequent tests. The fail point may be disabled like
210+
so::
211+
212+
db.adminCommand({
213+
configureFailPoint: <fail point name>,
214+
mode: "off"
215+
});
216+
217+
148218
Prose Tests
149219
===========
150220

test/spec/connection-monitoring-and-pooling/connection-must-have-id.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"style": "unit",
44
"description": "must have an ID number associated with it",
55
"operations": [
6+
{
7+
"name": "ready"
8+
},
69
{
710
"name": "checkOut"
811
},
@@ -42,6 +45,7 @@
4245
],
4346
"ignore": [
4447
"ConnectionPoolCreated",
48+
"ConnectionPoolReady",
4549
"ConnectionPoolClosed",
4650
"ConnectionReady"
4751
]

test/spec/connection-monitoring-and-pooling/connection-must-have-id.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: 1
22
style: unit
33
description: must have an ID number associated with it
44
operations:
5+
- name: ready
56
- name: checkOut
67
- name: checkOut
78
events:
@@ -23,5 +24,6 @@ events:
2324
address: 42
2425
ignore:
2526
- ConnectionPoolCreated
27+
- ConnectionPoolReady
2628
- ConnectionPoolClosed
2729
- ConnectionReady

test/spec/connection-monitoring-and-pooling/connection-must-order-ids.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"style": "unit",
44
"description": "must have IDs assigned in order of creation",
55
"operations": [
6+
{
7+
"name": "ready"
8+
},
69
{
710
"name": "checkOut"
811
},
@@ -42,6 +45,7 @@
4245
],
4346
"ignore": [
4447
"ConnectionPoolCreated",
48+
"ConnectionPoolReady",
4549
"ConnectionPoolClosed",
4650
"ConnectionReady"
4751
]

test/spec/connection-monitoring-and-pooling/connection-must-order-ids.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: 1
22
style: unit
33
description: must have IDs assigned in order of creation
44
operations:
5+
- name: ready
56
- name: checkOut
67
- name: checkOut
78
events:
@@ -23,5 +24,6 @@ events:
2324
address: 42
2425
ignore:
2526
- ConnectionPoolCreated
27+
- ConnectionPoolReady
2628
- ConnectionPoolClosed
2729
- ConnectionReady

test/spec/connection-monitoring-and-pooling/pool-checkin-destroy-closed.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"style": "unit",
44
"description": "must destroy checked in connection if pool has been closed",
55
"operations": [
6+
{
7+
"name": "ready"
8+
},
69
{
710
"name": "checkOut",
811
"label": "conn"
@@ -39,6 +42,7 @@
3942
],
4043
"ignore": [
4144
"ConnectionPoolCreated",
45+
"ConnectionPoolReady",
4246
"ConnectionCreated",
4347
"ConnectionReady",
4448
"ConnectionCheckOutStarted"

test/spec/connection-monitoring-and-pooling/pool-checkin-destroy-closed.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: 1
22
style: unit
33
description: must destroy checked in connection if pool has been closed
44
operations:
5+
- name: ready
56
- name: checkOut
67
label: conn
78
- name: close
@@ -22,6 +23,7 @@ events:
2223
address: 42
2324
ignore:
2425
- ConnectionPoolCreated
26+
- ConnectionPoolReady
2527
- ConnectionCreated
2628
- ConnectionReady
2729
- ConnectionCheckOutStarted

test/spec/connection-monitoring-and-pooling/pool-checkin-destroy-stale.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"style": "unit",
44
"description": "must destroy checked in connection if it is stale",
55
"operations": [
6+
{
7+
"name": "ready"
8+
},
69
{
710
"name": "checkOut",
811
"label": "conn"
@@ -39,6 +42,7 @@
3942
],
4043
"ignore": [
4144
"ConnectionPoolCreated",
45+
"ConnectionPoolReady",
4246
"ConnectionCreated",
4347
"ConnectionReady",
4448
"ConnectionCheckOutStarted"

test/spec/connection-monitoring-and-pooling/pool-checkin-destroy-stale.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: 1
22
style: unit
33
description: must destroy checked in connection if it is stale
44
operations:
5+
- name: ready
56
- name: checkOut
67
label: conn
78
- name: clear
@@ -22,6 +23,7 @@ events:
2223
address: 42
2324
ignore:
2425
- ConnectionPoolCreated
26+
- ConnectionPoolReady
2527
- ConnectionCreated
2628
- ConnectionReady
2729
- ConnectionCheckOutStarted

test/spec/connection-monitoring-and-pooling/pool-checkin-make-available.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"style": "unit",
44
"description": "must make valid checked in connection available",
55
"operations": [
6+
{
7+
"name": "ready"
8+
},
69
{
710
"name": "checkOut",
811
"label": "conn"
@@ -34,6 +37,7 @@
3437
],
3538
"ignore": [
3639
"ConnectionPoolCreated",
40+
"ConnectionPoolReady",
3741
"ConnectionCreated",
3842
"ConnectionReady",
3943
"ConnectionCheckOutStarted"

test/spec/connection-monitoring-and-pooling/pool-checkin-make-available.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: 1
22
style: unit
33
description: must make valid checked in connection available
44
operations:
5+
- name: ready
56
- name: checkOut
67
label: conn
78
- name: checkIn
@@ -19,6 +20,7 @@ events:
1920
address: 42
2021
ignore:
2122
- ConnectionPoolCreated
23+
- ConnectionPoolReady
2224
- ConnectionCreated
2325
- ConnectionReady
24-
- ConnectionCheckOutStarted
26+
- ConnectionCheckOutStarted

test/spec/connection-monitoring-and-pooling/pool-checkin.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"style": "unit",
44
"description": "must have a method of allowing the driver to check in a connection",
55
"operations": [
6+
{
7+
"name": "ready"
8+
},
69
{
710
"name": "checkOut",
811
"label": "conn"
@@ -21,6 +24,7 @@
2124
],
2225
"ignore": [
2326
"ConnectionPoolCreated",
27+
"ConnectionPoolReady",
2428
"ConnectionCreated",
2529
"ConnectionReady",
2630
"ConnectionClosed",

test/spec/connection-monitoring-and-pooling/pool-checkin.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: 1
22
style: unit
33
description: must have a method of allowing the driver to check in a connection
44
operations:
5+
- name: ready
56
- name: checkOut
67
label: conn
78
- name: checkIn
@@ -12,6 +13,7 @@ events:
1213
address: 42
1314
ignore:
1415
- ConnectionPoolCreated
16+
- ConnectionPoolReady
1517
- ConnectionCreated
1618
- ConnectionReady
1719
- ConnectionClosed

test/spec/connection-monitoring-and-pooling/pool-checkout-connection.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"style": "unit",
44
"description": "must be able to check out a connection",
55
"operations": [
6+
{
7+
"name": "ready"
8+
},
69
{
710
"name": "checkOut"
811
}
@@ -29,6 +32,7 @@
2932
}
3033
],
3134
"ignore": [
35+
"ConnectionPoolReady",
3236
"ConnectionPoolCreated"
3337
]
3438
}

0 commit comments

Comments
 (0)