diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/README.rst b/specifications/connection-monitoring-and-pooling/tests/cmap-format/README.rst deleted file mode 100644 index 5bb72dd0fe6..00000000000 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/README.rst +++ /dev/null @@ -1,215 +0,0 @@ -.. role:: javascript(code) - :language: javascript - -=================================================================== -Connection Monitoring and Pooling (CMAP) Unit and Integration Tests -=================================================================== - -.. contents:: - --------- - -Introduction -============ - -The YAML and JSON files in this directory are platform-independent tests that -drivers can use to prove their conformance to the Connection Monitoring and Pooling (CMAP) Spec. - -Common Test Format -================== - -Each YAML file has the following keys: - -- ``version``: A version number indicating the expected format of the spec tests (current version = 1) -- ``style``: A string indicating what style of tests this file contains. Contains one of the following: - - - ``"unit"``: a test that may be run without connecting to a MongoDB deployment. - - ``"integration"``: a test that MUST be run against a real MongoDB deployment. - -- ``description``: A text description of what the test is meant to assert - -Unit Test Format: -================= - -All Unit Tests have some of the following fields: - -- ``poolOptions``: If present, connection pool options to use when creating a pool; - both `standard ConnectionPoolOptions `__ - and the following test-specific options are allowed: - - - ``backgroundThreadIntervalMS``: A time interval between the end of a - `Background Thread Run `__ - and the beginning of the next Run. If a Connection Pool does not implement a Background Thread, the Test Runner MUST ignore the option. - If the option is not specified, an implementation is free to use any value it finds reasonable. - - Possible values (0 is not allowed): - - - A negative value: never begin a Run. - - A positive value: the interval between Runs in milliseconds. - -- ``operations``: A list of operations to perform. All operations support the following fields: - - - ``name``: A string describing which operation to issue. - - ``thread``: The name of the thread in which to run this operation. If not specified, runs in the default thread - -- ``error``: Indicates that the main thread is expected to error during this test. An error may include of the following fields: - - - ``type``: the type of error emitted - - ``message``: the message associated with that error - - ``address``: Address of pool emitting error - -- ``events``: An array of all connection monitoring events expected to occur while running ``operations``. An event may contain any of the following fields - - - ``type``: The type of event emitted - - ``address``: The address of the pool emitting the event - - ``connectionId``: The id of a connection associated with the event - - ``options``: Options used to create the pool - - ``reason``: A reason giving mroe information on why the event was emitted - -- ``ignore``: An array of event names to ignore - -Valid Unit Test Operations are the following: - -- ``start(target)``: Starts a new thread named ``target`` - - - ``target``: The name of the new thread to start - -- ``wait(ms)``: Sleep the current thread for ``ms`` milliseconds - - - ``ms``: The number of milliseconds to sleep the current thread for - -- ``waitForThread(target)``: wait for thread ``target`` to finish executing. Propagate any errors to the main thread. - - - ``target``: The name of the thread to wait for. - -- ``waitForEvent(event, count, timeout)``: block the current thread until ``event`` has occurred ``count`` times - - - ``event``: The name of the event - - ``count``: The number of times the event must occur (counting from the start of the test) - - ``timeout``: If specified, time out with an error after waiting for this many milliseconds without seeing the required events - -- ``label = pool.checkOut()``: call ``checkOut`` on pool, returning the checked out connection - - - ``label``: If specified, associate this label with the returned connection, so that it may be referenced in later operations - -- ``pool.checkIn(connection)``: call ``checkIn`` on pool - - - ``connection``: A string label identifying which connection to check in. Should be a label that was previously set with ``checkOut`` - -- ``pool.clear()``: call ``clear`` on Pool - - - ``interruptInUseConnections``: Determines whether "in use" connections should be also interrupted - -- ``pool.close()``: call ``close`` on Pool -- ``pool.ready()``: call ``ready`` on Pool - - -Integration Test Format -======================= - -The integration test format is identical to the unit test format with -the addition of the following fields to each test: - -- ``runOn`` (optional): An array of server version and/or topology requirements - for which the tests can be run. If the test environment satisfies one or more - of these requirements, the tests may be executed; otherwise, this test should - be skipped. If this field is omitted, the tests can be assumed to have no - particular requirements and should be executed. Each element will have some or - all of the following fields: - - - ``minServerVersion`` (optional): The minimum server version (inclusive) - required to successfully run the tests. If this field is omitted, it should - be assumed that there is no lower bound on the required server version. - - - ``maxServerVersion`` (optional): The maximum server version (inclusive) - against which the tests can be run successfully. If this field is omitted, - it should be assumed that there is no upper bound on the required server - version. - -- ``failPoint``: optional, a document containing a ``configureFailPoint`` - command to run against the endpoint being used for the test. - -- ``poolOptions.appName`` (optional): appName attribute to be set in connections, which will be affected by the fail point. - -Spec Test Match Function -======================== - -The definition of MATCH or MATCHES in the Spec Test Runner is as follows: - -- MATCH takes two values, ``expected`` and ``actual`` -- Notation is "Assert [actual] MATCHES [expected] -- Assertion passes if ``expected`` is a subset of ``actual``, with the values ``42`` and ``"42"`` acting as placeholders for "any value" - -Pseudocode implementation of ``actual`` MATCHES ``expected``: - -:: - - If expected is "42" or 42: - Assert that actual exists (is not null or undefined) - Else: - Assert that actual is of the same JSON type as expected - If expected is a JSON array: - For every idx/value in expected: - Assert that actual[idx] MATCHES value - Else if expected is a JSON object: - For every key/value in expected - Assert that actual[key] MATCHES value - Else: - Assert that expected equals actual - -Unit Test Runner: -================= - -For the unit tests, the behavior of a Connection is irrelevant beyond the need to asserting ``connection.id``. Drivers MAY use a mock connection class for testing the pool behavior in unit tests - -For each YAML file with ``style: unit``: - -- Create a Pool ``pool``, subscribe and capture any Connection Monitoring events emitted in order. - - - If ``poolOptions`` is specified, use those options to initialize both pools - - The returned pool must have an ``address`` set as a string value. - -- Process each ``operation`` in ``operations`` (on the main thread) - - - 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. - -- If ``error`` is presented - - - Assert that an actual error ``actualError`` was thrown by the main thread - - Assert that ``actualError`` MATCHES ``error`` - -- Else: - - - Assert that no errors were thrown by the main thread - -- calculate ``actualEvents`` as every Connection Event emitted whose ``type`` is not in ``ignore`` -- if ``events`` is not empty, then for every ``idx``/``expectedEvent`` in ``events`` - - - Assert that ``actualEvents[idx]`` exists - - Assert that ``actualEvents[idx]`` MATCHES ``expectedEvent`` - - -It is important to note that the ``ignore`` list is used for calculating ``actualEvents``, but is NOT used for the ``waitForEvent`` command - -Integration Test Runner -======================= - -The steps to run the integration tests are the same as those used to run the -unit tests with the following modifications: - -- The integration tests MUST be run against an actual endpoint. If the - deployment being tested contains multiple endpoints, then the runner MUST - only use one of them to run the tests against. - -- For each test, if `failPoint` is specified, its value is a - ``configureFailPoint`` command. Run the command on the admin database of the - endpoint being tested to enable the fail point. - -- At the end of each test, any enabled fail point MUST be disabled to avoid - spurious failures in subsequent tests. The fail point may be disabled like - so:: - - db.adminCommand({ - configureFailPoint: , - mode: "off" - }); diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-checkout-returned-connection-maxConnecting.json b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-checkout-returned-connection-maxConnecting.json index 965d56f6d84..10b526e0c32 100644 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-checkout-returned-connection-maxConnecting.json +++ b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-checkout-returned-connection-maxConnecting.json @@ -23,6 +23,7 @@ } }, "poolOptions": { + "maxConnecting": 2, "maxPoolSize": 10, "waitQueueTimeoutMS": 5000 }, @@ -72,9 +73,8 @@ "connection": "conn0" }, { - "name": "waitForEvent", - "event": "ConnectionCheckedOut", - "count": 4 + "name": "wait", + "ms": 100 } ], "events": [ @@ -104,14 +104,6 @@ "type": "ConnectionCheckedOut", "connectionId": 1, "address": 42 - }, - { - "type": "ConnectionCheckedOut", - "address": 42 - }, - { - "type": "ConnectionCheckedOut", - "address": 42 } ], "ignore": [ diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-checkout-returned-connection-maxConnecting.yml b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-checkout-returned-connection-maxConnecting.yml index dab6e557d8c..5e2b5890a86 100644 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-checkout-returned-connection-maxConnecting.yml +++ b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-checkout-returned-connection-maxConnecting.yml @@ -15,6 +15,7 @@ failPoint: blockConnection: true blockTimeMS: 750 poolOptions: + maxConnecting: 2 maxPoolSize: 10 waitQueueTimeoutMS: 5000 operations: @@ -45,14 +46,13 @@ operations: count: 4 - name: wait ms: 100 - # check original connection back in, so the thread that isn't - # currently establishing will become unblocked. Then wait for - # all threads to complete. + # Check original connection back in, so one of the waiting threads can check + # out the idle connection before the two new connections are ready. - name: checkIn connection: conn0 - - name: waitForEvent - event: ConnectionCheckedOut - count: 4 + # Wait for 100ms to let one of the blocked checkOut operations complete. + - name: wait + ms: 100 events: # main thread checking out a Connection and holding it - type: ConnectionCreated @@ -69,15 +69,13 @@ events: - type: ConnectionCheckedIn connectionId: 1 address: 42 - # remaining thread checking out the returned Connection + # Another thread checks out the returned Connection before the two new + # connections are checked out. - type: ConnectionCheckedOut connectionId: 1 address: 42 - # first two threads finishing Connection establishment - - type: ConnectionCheckedOut - address: 42 - - type: ConnectionCheckedOut - address: 42 + # Events after this can come in different orders but still be valid. + # See DRIVERS-2223 for details. ignore: - ConnectionPoolReady - ConnectionClosed diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-close-in-use.json b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-close-in-use.json deleted file mode 100644 index f893cf5fd93..00000000000 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-close-in-use.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "version": 1, - "style": "unit", - "description": "Pool clear MUST support lazily closing in use connections", - "poolOptions": { - "backgroundThreadIntervalMS": 100 - }, - "operations": [ - { - "name": "ready" - }, - { - "name": "checkOut" - }, - { - "name": "checkOut" - }, - { - "name": "clear", - "closeInUseConnections": true - }, - { - "name": "waitForEvent", - "event": "ConnectionPoolCleared", - "count": 1, - "timeout": 1000 - - }, - { - "name": "waitForEvent", - "event": "ConnectionClosed", - "count": 2, - "timeout": 1000 - }, - { - "name": "close" - } - ], - "events": [ - { - "type": "ConnectionCheckedOut", - "connectionId": 1, - "address": 42 - }, - { - "type": "ConnectionCheckedOut", - "connectionId": 2, - "address": 42 - }, - { - "type": "ConnectionClosed", - "reason": "stale", - "address": 42 - }, - { - "type": "ConnectionClosed", - "reason": "stale", - "address": 42 - }, - { - "type": "ConnectionPoolClosed", - "address": 42 - } - ], - "ignore": [ - "ConnectionCreated", - "ConnectionPoolReady", - "ConnectionReady", - "ConnectionCheckOutStarted", - "ConnectionPoolCreated", - "ConnectionPoolCleared" - ] -} diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-close-in-use.yml b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-close-in-use.yml deleted file mode 100644 index 7b0123bf513..00000000000 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-close-in-use.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: 1 -style: unit -description: Pool clear MUST support lazily closing in use connections -poolOptions: - backgroundThreadIntervalMS: 100 -operations: - - name: ready - - name: checkOut - - name: checkOut - - name: clear - closeInUseConnections: true - - name: waitForEvent - event: ConnectionPoolCleared - count: 1 - timeout: 1000 - - name: waitForEvent - event: ConnectionClosed - count: 2 - timeout: 1000 - - name: close -events: - - type: ConnectionCheckedOut - connectionId: 1 - address: 42 - - type: ConnectionCheckedOut - connectionId: 2 - address: 42 - - type: ConnectionClosed - reason: stale - address: 42 - - type: ConnectionClosed - reason: stale - address: 42 - - type: ConnectionPoolClosed - address: 42 -ignore: - - ConnectionCreated - - ConnectionPoolReady - - ConnectionReady - - ConnectionCheckOutStarted - - ConnectionPoolCreated - - ConnectionPoolCleared diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-interrupting-pending-connections.json b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-interrupting-pending-connections.json new file mode 100644 index 00000000000..c1fd7463294 --- /dev/null +++ b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-interrupting-pending-connections.json @@ -0,0 +1,77 @@ +{ + "version": 1, + "style": "integration", + "description": "clear with interruptInUseConnections = true closes pending connections", + "runOn": [ + { + "minServerVersion": "4.9.0" + } + ], + "failPoint": { + "configureFailPoint": "failCommand", + "mode": "alwaysOn", + "data": { + "failCommands": [ + "isMaster", + "hello" + ], + "closeConnection": false, + "blockConnection": true, + "blockTimeMS": 10000 + } + }, + "poolOptions": { + "minPoolSize": 0 + }, + "operations": [ + { + "name": "ready" + }, + { + "name": "start", + "target": "thread1" + }, + { + "name": "checkOut", + "thread": "thread1" + }, + { + "name": "waitForEvent", + "event": "ConnectionCreated", + "count": 1 + }, + { + "name": "clear", + "interruptInUseConnections": true + }, + { + "name": "waitForEvent", + "event": "ConnectionCheckOutFailed", + "count": 1 + } + ], + "events": [ + { + "type": "ConnectionCheckOutStarted" + }, + { + "type": "ConnectionCreated" + }, + { + "type": "ConnectionPoolCleared", + "interruptInUseConnections": true + }, + { + "type": "ConnectionClosed" + }, + { + "type": "ConnectionCheckOutFailed" + } + ], + "ignore": [ + "ConnectionCheckedIn", + "ConnectionCheckedOut", + "ConnectionPoolCreated", + "ConnectionPoolReady" + ] +} diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-interrupting-pending-connections.yml b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-interrupting-pending-connections.yml new file mode 100644 index 00000000000..ea0bbc7d4ef --- /dev/null +++ b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-interrupting-pending-connections.yml @@ -0,0 +1,42 @@ +version: 1 +style: integration +description: clear with interruptInUseConnections = true closes pending connections +runOn: + - + minServerVersion: "4.9.0" +failPoint: + configureFailPoint: failCommand + mode: "alwaysOn" + data: + failCommands: ["isMaster","hello"] + closeConnection: false + blockConnection: true + blockTimeMS: 10000 +poolOptions: + minPoolSize: 0 +operations: + - name: ready + - name: start + target: thread1 + - name: checkOut + thread: thread1 + - name: waitForEvent + event: ConnectionCreated + count: 1 + - name: clear + interruptInUseConnections: true + - name: waitForEvent + event: ConnectionCheckOutFailed + count: 1 +events: + - type: ConnectionCheckOutStarted + - type: ConnectionCreated + - type: ConnectionPoolCleared + interruptInUseConnections: true + - type: ConnectionClosed + - type: ConnectionCheckOutFailed +ignore: + - ConnectionCheckedIn + - ConnectionCheckedOut + - ConnectionPoolCreated + - ConnectionPoolReady diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-closeInUseConnections-false.json b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-interruptInUseConnections-false.json similarity index 84% rename from specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-closeInUseConnections-false.json rename to specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-interruptInUseConnections-false.json index e96752044ed..3d7536951d5 100644 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-closeInUseConnections-false.json +++ b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-interruptInUseConnections-false.json @@ -1,7 +1,7 @@ { "version": 1, "style": "unit", - "description": "Pool clear SHOULD schedule the next background thread run immediately (closeInUseConnections: false)", + "description": "Pool clear SHOULD schedule the next background thread run immediately (interruptInUseConnections = false)", "poolOptions": { "backgroundThreadIntervalMS": 10000 }, @@ -22,13 +22,13 @@ }, { "name": "clear", - "closeInUseConnections": false + "interruptInUseConnections": false }, { "name": "waitForEvent", "event": "ConnectionPoolCleared", "count": 1, - "timeout": 1000 + "timeout": 1000 }, { "name": "waitForEvent", @@ -56,6 +56,10 @@ "connectionId": 2, "address": 42 }, + { + "type": "ConnectionPoolCleared", + "interruptInUseConnections": false + }, { "type": "ConnectionClosed", "connectionId": 2, @@ -72,7 +76,6 @@ "ConnectionPoolReady", "ConnectionReady", "ConnectionCheckOutStarted", - "ConnectionPoolCreated", - "ConnectionPoolCleared" + "ConnectionPoolCreated" ] } diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-closeInUseConnections-false.yml b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-interruptInUseConnections-false.yml similarity index 85% rename from specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-closeInUseConnections-false.yml rename to specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-interruptInUseConnections-false.yml index ada99961d6a..dcaafec8b57 100644 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-closeInUseConnections-false.yml +++ b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run-interruptInUseConnections-false.yml @@ -1,6 +1,6 @@ version: 1 style: unit -description: Pool clear SHOULD schedule the next background thread run immediately (closeInUseConnections: false) +description: Pool clear SHOULD schedule the next background thread run immediately (interruptInUseConnections = false) poolOptions: # ensure it's not involved by default backgroundThreadIntervalMS: 10000 @@ -12,7 +12,7 @@ operations: - name: checkIn connection: conn - name: clear - closeInUseConnections: false + interruptInUseConnections: false - name: waitForEvent event: ConnectionPoolCleared count: 1 @@ -32,6 +32,8 @@ events: - type: ConnectionCheckedIn connectionId: 2 address: 42 + - type: ConnectionPoolCleared + interruptInUseConnections: false - type: ConnectionClosed connectionId: 2 reason: stale @@ -44,4 +46,3 @@ ignore: - ConnectionReady - ConnectionCheckOutStarted - ConnectionPoolCreated - - ConnectionPoolCleared diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run.json b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run.json deleted file mode 100644 index a0706c9c570..00000000000 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "version": 1, - "style": "unit", - "description": "Pool clear SHOULD schedule the next background thread run immediately", - "poolOptions": { - "backgroundThreadIntervalMS": 10000 - }, - "operations": [ - { - "name": "ready" - }, - { - "name": "checkOut" - }, - { - "name": "checkOut", - "label": "conn" - }, - { - "name": "clear", - "closeInUseConnections": true - }, - { - "name": "waitForEvent", - "event": "ConnectionPoolCleared", - "count": 1, - "timeout": 1000 - }, - { - "name": "waitForEvent", - "event": "ConnectionClosed", - "count": 2, - "timeout": 1000 - }, - { - "name": "close" - } - ], - "events": [ - { - "type": "ConnectionCheckedOut", - "connectionId": 1, - "address": 42 - }, - { - "type": "ConnectionCheckedOut", - "connectionId": 2, - "address": 42 - }, - { - "type": "ConnectionClosed", - "connectionId": 1, - "reason": "stale", - "address": 42 - }, - { - "type": "ConnectionClosed", - "connectionId": 2, - "reason": "stale", - "address": 42 - }, - { - "type": "ConnectionPoolClosed", - "address": 42 - } - ], - "ignore": [ - "ConnectionCreated", - "ConnectionPoolReady", - "ConnectionReady", - "ConnectionCheckOutStarted", - "ConnectionPoolCreated", - "ConnectionPoolCleared" - ] -} diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run.yml b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run.yml deleted file mode 100644 index a855cb30243..00000000000 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-clear-schedule-run.yml +++ /dev/null @@ -1,46 +0,0 @@ -version: 1 -style: unit -description: Pool clear SHOULD schedule the next background thread run immediately -poolOptions: - # ensure it's not involved by default - backgroundThreadIntervalMS: 10000 -operations: - - name: ready - - name: checkOut - - name: checkOut - label: conn - - name: clear - closeInUseConnections: true - - name: waitForEvent - event: ConnectionPoolCleared - count: 1 - timeout: 1000 - - name: waitForEvent - event: ConnectionClosed - count: 2 - timeout: 1000 - - name: close -events: - - type: ConnectionCheckedOut - connectionId: 1 - address: 42 - - type: ConnectionCheckedOut - connectionId: 2 - address: 42 - - type: ConnectionClosed - connectionId: 1 - reason: stale - address: 42 - - type: ConnectionClosed - connectionId: 2 - reason: stale - address: 42 - - type: ConnectionPoolClosed - address: 42 -ignore: - - ConnectionCreated - - ConnectionPoolReady - - ConnectionReady - - ConnectionCheckOutStarted - - ConnectionPoolCreated - - ConnectionPoolCleared diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-create-min-size-error.json b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-create-min-size-error.json index 509b2a2356c..fe7489f401a 100644 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-create-min-size-error.json +++ b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-create-min-size-error.json @@ -17,7 +17,7 @@ "isMaster", "hello" ], - "closeConnection": true, + "errorCode": 91, "appName": "poolCreateMinSizeErrorTest" } }, diff --git a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-create-min-size-error.yml b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-create-min-size-error.yml index f43c4ee154f..42cf6e32a38 100644 --- a/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-create-min-size-error.yml +++ b/specifications/connection-monitoring-and-pooling/tests/cmap-format/pool-create-min-size-error.yml @@ -11,7 +11,7 @@ failPoint: mode: { times: 50 } data: failCommands: ["isMaster","hello"] - closeConnection: true + errorCode: 91 appName: "poolCreateMinSizeErrorTest" poolOptions: minPoolSize: 1 diff --git a/specifications/load-balancers/tests/cursors.json b/specifications/load-balancers/tests/cursors.json index 8454f130df6..b11bf2c6fae 100644 --- a/specifications/load-balancers/tests/cursors.json +++ b/specifications/load-balancers/tests/cursors.json @@ -222,7 +222,10 @@ "reply": { "cursor": { "id": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "firstBatch": { "$$type": "array" @@ -239,7 +242,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": "coll0" }, @@ -333,7 +339,10 @@ "reply": { "cursor": { "id": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "firstBatch": { "$$type": "array" @@ -475,7 +484,10 @@ "reply": { "cursor": { "id": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "firstBatch": { "$$type": "array" @@ -492,7 +504,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": "coll0" }, @@ -605,7 +620,10 @@ "reply": { "cursor": { "id": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "firstBatch": { "$$type": "array" @@ -750,7 +768,10 @@ "reply": { "cursor": { "id": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "firstBatch": { "$$type": "array" @@ -767,7 +788,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": "coll0" }, @@ -858,7 +882,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": "coll0" }, @@ -950,7 +977,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": { "$$type": "string" @@ -1100,7 +1130,10 @@ "commandStartedEvent": { "command": { "getMore": { - "$$type": "long" + "$$type": [ + "int", + "long" + ] }, "collection": "coll0" }, diff --git a/specifications/load-balancers/tests/cursors.yml b/specifications/load-balancers/tests/cursors.yml index 283d2663d52..1b558affe17 100644 --- a/specifications/load-balancers/tests/cursors.yml +++ b/specifications/load-balancers/tests/cursors.yml @@ -126,14 +126,14 @@ tests: commandSucceededEvent: reply: cursor: - id: { $$type: long } + id: { $$type: [ int, long ] } firstBatch: { $$type: array } ns: { $$type: string } commandName: find - &getMoreStarted commandStartedEvent: command: - getMore: { $$type: long } + getMore: { $$type: [ int, long ] } collection: *collection0Name commandName: getMore - &getMoreSucceeded @@ -386,7 +386,7 @@ tests: # is not equal to *collection0Name as the command is not executed against a collection. - commandStartedEvent: command: - getMore: { $$type: long } + getMore: { $$type: [ int, long ] } collection: { $$type: string } commandName: getMore - *getMoreSucceeded diff --git a/specifications/load-balancers/tests/sdam-error-handling.json b/specifications/load-balancers/tests/sdam-error-handling.json index 47323fae4f3..2107afe5b3f 100644 --- a/specifications/load-balancers/tests/sdam-error-handling.json +++ b/specifications/load-balancers/tests/sdam-error-handling.json @@ -282,7 +282,7 @@ "isMaster", "hello" ], - "closeConnection": true, + "errorCode": 11600, "appName": "lbSDAMErrorTestClient" } } @@ -297,7 +297,7 @@ } }, "expectError": { - "isClientError": true + "isError": true } } ], diff --git a/specifications/load-balancers/tests/sdam-error-handling.yml b/specifications/load-balancers/tests/sdam-error-handling.yml index b81d811dc85..c5a69339e34 100644 --- a/specifications/load-balancers/tests/sdam-error-handling.yml +++ b/specifications/load-balancers/tests/sdam-error-handling.yml @@ -153,14 +153,14 @@ tests: mode: { times: 1 } data: failCommands: [isMaster, hello] - closeConnection: true + errorCode: 11600 appName: *singleClientAppName - name: insertOne object: *singleColl arguments: document: { x: 1 } expectError: - isClientError: true + isError: true expectEvents: - client: *singleClient eventType: cmap diff --git a/specifications/server-discovery-and-monitoring/tests/unified/auth-error.json b/specifications/server-discovery-and-monitoring/tests/unified/auth-error.json index 5c78ecfe503..62d26494c7c 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/auth-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/auth-error.json @@ -1,6 +1,6 @@ { "description": "auth-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/auth-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/auth-error.yml index b2dfc4eccc4..febf4a46dc3 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/auth-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/auth-error.yml @@ -1,6 +1,6 @@ description: auth-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/auth-misc-command-error.json b/specifications/server-discovery-and-monitoring/tests/unified/auth-misc-command-error.json index 6e1b645461e..fd62fe604e9 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/auth-misc-command-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/auth-misc-command-error.json @@ -1,6 +1,6 @@ { "description": "auth-misc-command-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/auth-misc-command-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/auth-misc-command-error.yml index 94d41d66167..9969ca92d4c 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/auth-misc-command-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/auth-misc-command-error.yml @@ -1,7 +1,7 @@ --- description: auth-misc-command-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/auth-network-error.json b/specifications/server-discovery-and-monitoring/tests/unified/auth-network-error.json index 7606d2db7ab..84763af32e4 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/auth-network-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/auth-network-error.json @@ -1,6 +1,6 @@ { "description": "auth-network-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/auth-network-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/auth-network-error.yml index 9073a927ce7..cdf77c56dfc 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/auth-network-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/auth-network-error.yml @@ -1,7 +1,7 @@ --- description: auth-network-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/auth-network-timeout-error.json b/specifications/server-discovery-and-monitoring/tests/unified/auth-network-timeout-error.json index 22066e8baeb..3cf9576eba9 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/auth-network-timeout-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/auth-network-timeout-error.json @@ -1,6 +1,6 @@ { "description": "auth-network-timeout-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/auth-network-timeout-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/auth-network-timeout-error.yml index 8b29a1e670c..49b91d8373a 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/auth-network-timeout-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/auth-network-timeout-error.yml @@ -1,7 +1,7 @@ --- description: auth-network-timeout-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/auth-shutdown-error.json b/specifications/server-discovery-and-monitoring/tests/unified/auth-shutdown-error.json index 5dd7b5bb6fe..b9e503af66e 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/auth-shutdown-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/auth-shutdown-error.json @@ -1,6 +1,6 @@ { "description": "auth-shutdown-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/auth-shutdown-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/auth-shutdown-error.yml index 87a937d3811..f0bb4d17dfd 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/auth-shutdown-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/auth-shutdown-error.yml @@ -1,7 +1,7 @@ --- description: auth-shutdown-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-error-fail.json b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-error-fail.json new file mode 100644 index 00000000000..f41b76459cb --- /dev/null +++ b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-error-fail.json @@ -0,0 +1,140 @@ +{ + "description": "backpressure-network-error-fail", + "schemaVersion": "1.17", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "backpressure-network-error-fail", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "apply backpressure on network connection errors during connection establishment", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "serverHeartbeatSucceededEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "heartbeatFrequencyMS": 1000000, + "serverMonitoringMode": "poll", + "appname": "backpressureNetworkErrorFailTest" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "backpressure-network-error-fail" + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverHeartbeatSucceededEvent": {} + }, + "count": 1 + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": "alwaysOn", + "data": { + "failCommands": [ + "isMaster", + "hello" + ], + "appName": "backpressureNetworkErrorFailTest", + "closeConnection": true + } + } + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "expectError": { + "isError": true, + "errorLabelsContain": [ + "SystemOverloadedError", + "RetryableError" + ] + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "cmap", + "events": [] + } + ] + } + ] +} diff --git a/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-error-fail.yml b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-error-fail.yml new file mode 100644 index 00000000000..54e30302115 --- /dev/null +++ b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-error-fail.yml @@ -0,0 +1,80 @@ +description: backpressure-network-error-fail +schemaVersion: "1.17" +runOnRequirements: + - minServerVersion: "4.4" + serverless: forbid + topologies: + - single + - replicaset + - sharded +createEntities: + - client: + id: setupClient + useMultipleMongoses: false +initialData: + - collectionName: backpressure-network-error-fail + databaseName: sdam-tests + documents: + - _id: 1 + - _id: 2 +tests: + - description: apply backpressure on network connection errors during connection establishment + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: client + useMultipleMongoses: false + observeEvents: + - serverHeartbeatSucceededEvent + - poolClearedEvent + uriOptions: + retryWrites: false + heartbeatFrequencyMS: 1000000 + serverMonitoringMode: poll + appname: backpressureNetworkErrorFailTest + - database: + id: database + client: client + databaseName: sdam-tests + - collection: + id: collection + database: database + collectionName: backpressure-network-error-fail + - name: waitForEvent + object: testRunner + arguments: + client: client + event: + serverHeartbeatSucceededEvent: {} + count: 1 + - name: failPoint + object: testRunner + arguments: + client: setupClient + failPoint: + configureFailPoint: failCommand + mode: alwaysOn + data: + failCommands: + - isMaster + - hello + appName: backpressureNetworkErrorFailTest + closeConnection: true + - name: insertMany + object: collection + arguments: + documents: + - _id: 3 + - _id: 4 + expectError: + isError: true + errorLabelsContain: + - SystemOverloadedError + - RetryableError + expectEvents: + - client: client + eventType: cmap + events: [] diff --git a/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-timeout-fail.json b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-timeout-fail.json new file mode 100644 index 00000000000..a97c7a329ff --- /dev/null +++ b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-timeout-fail.json @@ -0,0 +1,143 @@ +{ + "description": "backpressure-network-timeout-error", + "schemaVersion": "1.17", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "single", + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "initialData": [ + { + "collectionName": "backpressure-network-timeout-error", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "apply backpressure on network timeout error during connection establishment", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeEvents": [ + "serverDescriptionChangedEvent", + "poolClearedEvent" + ], + "uriOptions": { + "retryWrites": false, + "heartbeatFrequencyMS": 1000000, + "appname": "backpressureNetworkTimeoutErrorTest", + "serverMonitoringMode": "poll", + "connectTimeoutMS": 250, + "socketTimeoutMS": 250 + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "backpressure-network-timeout-error" + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": {} + }, + "count": 1 + } + }, + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": "alwaysOn", + "data": { + "failCommands": [ + "isMaster", + "hello" + ], + "blockConnection": true, + "blockTimeMS": 500, + "appName": "backpressureNetworkTimeoutErrorTest" + } + } + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "expectError": { + "isError": true, + "errorLabelsContain": [ + "SystemOverloadedError", + "RetryableError" + ] + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "cmap", + "events": [] + } + ] + } + ] +} diff --git a/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-timeout-fail.yml b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-timeout-fail.yml new file mode 100644 index 00000000000..6a61eba3add --- /dev/null +++ b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-network-timeout-fail.yml @@ -0,0 +1,83 @@ +description: backpressure-network-timeout-error +schemaVersion: "1.17" +runOnRequirements: + - minServerVersion: "4.4" + serverless: forbid + topologies: + - single + - replicaset + - sharded +createEntities: + - client: + id: setupClient + useMultipleMongoses: false +initialData: + - collectionName: backpressure-network-timeout-error + databaseName: sdam-tests + documents: + - _id: 1 + - _id: 2 +tests: + - description: apply backpressure on network timeout error during connection establishment + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: client + useMultipleMongoses: false + observeEvents: + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + heartbeatFrequencyMS: 1000000 + appname: backpressureNetworkTimeoutErrorTest + serverMonitoringMode: poll + connectTimeoutMS: 250 + socketTimeoutMS: 250 + - database: + id: database + client: client + databaseName: sdam-tests + - collection: + id: collection + database: database + collectionName: backpressure-network-timeout-error + - name: waitForEvent + object: testRunner + arguments: + client: client + event: + serverDescriptionChangedEvent: {} + count: 1 + - name: failPoint + object: testRunner + arguments: + client: setupClient + failPoint: + configureFailPoint: failCommand + mode: alwaysOn + data: + failCommands: + - isMaster + - hello + blockConnection: true + blockTimeMS: 500 + appName: backpressureNetworkTimeoutErrorTest + - name: insertMany + object: collection + arguments: + documents: + - _id: 3 + - _id: 4 + expectError: + isError: true + errorLabelsContain: + - SystemOverloadedError + - RetryableError + expectEvents: + - client: client + eventType: cmap + events: [] diff --git a/specifications/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.json b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.json new file mode 100644 index 00000000000..f0597124b79 --- /dev/null +++ b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.json @@ -0,0 +1,106 @@ +{ + "description": "backpressure-server-description-unchanged-on-min-pool-size-population-error", + "schemaVersion": "1.17", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "single" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient", + "useMultipleMongoses": false + } + } + ], + "tests": [ + { + "description": "the server description is not changed on handshake error during minPoolSize population", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "skip": 1 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "authErrorTest", + "closeConnection": true + } + } + } + }, + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeEvents": [ + "serverDescriptionChangedEvent", + "connectionClosedEvent" + ], + "uriOptions": { + "appname": "authErrorTest", + "minPoolSize": 5, + "maxConnecting": 1, + "serverMonitoringMode": "poll", + "heartbeatFrequencyMS": 1000000 + } + } + } + ] + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "serverDescriptionChangedEvent": {} + }, + "count": 1 + } + }, + { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "connectionClosedEvent": {} + }, + "count": 1 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "sdam", + "events": [ + { + "serverDescriptionChangedEvent": {} + } + ] + } + ] + } + ] +} diff --git a/specifications/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.yml new file mode 100644 index 00000000000..e1d98dae208 --- /dev/null +++ b/specifications/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.yml @@ -0,0 +1,62 @@ +description: backpressure-server-description-unchanged-on-min-pool-size-population-error +schemaVersion: "1.17" +runOnRequirements: + - minServerVersion: "4.4" + serverless: forbid + topologies: + - single +createEntities: + - client: + id: setupClient + useMultipleMongoses: false +tests: + - description: the server description is not changed on handshake error during minPoolSize population + operations: + - name: failPoint + object: testRunner + arguments: + client: setupClient + failPoint: + configureFailPoint: failCommand + mode: + skip: 1 + data: + failCommands: + - hello + - isMaster + appName: authErrorTest + closeConnection: true + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: client + observeEvents: + - serverDescriptionChangedEvent + - connectionClosedEvent + uriOptions: + appname: authErrorTest + minPoolSize: 5 + maxConnecting: 1 + serverMonitoringMode: poll + heartbeatFrequencyMS: 1000000 + - name: waitForEvent + object: testRunner + arguments: + client: client + event: + serverDescriptionChangedEvent: {} + count: 1 + - name: waitForEvent + object: testRunner + arguments: + client: client + event: + connectionClosedEvent: {} + count: 1 + expectEvents: + - client: client + eventType: sdam + events: + - serverDescriptionChangedEvent: {} diff --git a/specifications/server-discovery-and-monitoring/tests/unified/cancel-server-check.json b/specifications/server-discovery-and-monitoring/tests/unified/cancel-server-check.json index 896cc8d0871..a60ccfcb414 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/cancel-server-check.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/cancel-server-check.json @@ -1,6 +1,6 @@ { "description": "cancel-server-check", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.0", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/cancel-server-check.yml b/specifications/server-discovery-and-monitoring/tests/unified/cancel-server-check.yml index 67d96706e14..af467925469 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/cancel-server-check.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/cancel-server-check.yml @@ -1,7 +1,7 @@ --- description: cancel-server-check -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # General failCommand requirements (this file does not use appName diff --git a/specifications/server-discovery-and-monitoring/tests/unified/connectTimeoutMS.json b/specifications/server-discovery-and-monitoring/tests/unified/connectTimeoutMS.json index 67a4d9da1d3..d3e860a9cb2 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/connectTimeoutMS.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/connectTimeoutMS.json @@ -1,6 +1,6 @@ { "description": "connectTimeoutMS", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/connectTimeoutMS.yml b/specifications/server-discovery-and-monitoring/tests/unified/connectTimeoutMS.yml index ef6d1150a77..7c610623eb1 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/connectTimeoutMS.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/connectTimeoutMS.yml @@ -1,7 +1,7 @@ --- description: connectTimeoutMS -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/find-network-error.json b/specifications/server-discovery-and-monitoring/tests/unified/find-network-error.json index 651466bfa6d..c1b6db40ca3 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/find-network-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/find-network-error.json @@ -1,6 +1,6 @@ { "description": "find-network-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/find-network-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/find-network-error.yml index deae09a19f7..f97d799a2a3 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/find-network-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/find-network-error.yml @@ -1,7 +1,7 @@ --- description: find-network-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/find-network-timeout-error.json b/specifications/server-discovery-and-monitoring/tests/unified/find-network-timeout-error.json index 2bde6daa5df..e5ac9f21aa7 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/find-network-timeout-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/find-network-timeout-error.json @@ -1,6 +1,6 @@ { "description": "find-network-timeout-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/find-network-timeout-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/find-network-timeout-error.yml index 30c4809ccf6..e00b7a2be09 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/find-network-timeout-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/find-network-timeout-error.yml @@ -1,7 +1,7 @@ --- description: find-network-timeout-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/find-shutdown-error.json b/specifications/server-discovery-and-monitoring/tests/unified/find-shutdown-error.json index 624ad352fc9..6e5a2cac055 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/find-shutdown-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/find-shutdown-error.json @@ -1,6 +1,6 @@ { "description": "find-shutdown-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/find-shutdown-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/find-shutdown-error.yml index f2da705d9e1..395215244b4 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/find-shutdown-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/find-shutdown-error.yml @@ -1,7 +1,7 @@ --- description: find-shutdown-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/hello-command-error.json b/specifications/server-discovery-and-monitoring/tests/unified/hello-command-error.json index be3dd8abf42..87958cb2c0b 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/hello-command-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/hello-command-error.json @@ -1,6 +1,6 @@ { "description": "hello-command-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4.7", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/hello-command-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/hello-command-error.yml index ec695a26676..1c9c0792202 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/hello-command-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/hello-command-error.yml @@ -1,7 +1,7 @@ --- description: hello-command-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # Require SERVER-49336 for failCommand + appName on the initial handshake. diff --git a/specifications/server-discovery-and-monitoring/tests/unified/hello-network-error.json b/specifications/server-discovery-and-monitoring/tests/unified/hello-network-error.json index ebb6c245f8e..15ed2b605e2 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/hello-network-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/hello-network-error.json @@ -1,6 +1,6 @@ { "description": "hello-network-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4.7", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/hello-network-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/hello-network-error.yml index da43b62d804..5f29194fc69 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/hello-network-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/hello-network-error.yml @@ -1,7 +1,7 @@ --- description: hello-network-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # Require SERVER-49336 for failCommand + appName on the initial handshake. diff --git a/specifications/server-discovery-and-monitoring/tests/unified/hello-timeout.json b/specifications/server-discovery-and-monitoring/tests/unified/hello-timeout.json index dfa6b48d66b..fe7cf4e78d1 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/hello-timeout.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/hello-timeout.json @@ -1,6 +1,6 @@ { "description": "hello-timeout", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/hello-timeout.yml b/specifications/server-discovery-and-monitoring/tests/unified/hello-timeout.yml index efab836e654..2a3374d1e75 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/hello-timeout.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/hello-timeout.yml @@ -1,7 +1,7 @@ --- description: hello-timeout -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/insert-network-error.json b/specifications/server-discovery-and-monitoring/tests/unified/insert-network-error.json index e4ba6684ae2..bfe41a4cb66 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/insert-network-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/insert-network-error.json @@ -1,6 +1,6 @@ { "description": "insert-network-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/insert-network-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/insert-network-error.yml index fc9c2f4921e..fcedf543579 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/insert-network-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/insert-network-error.yml @@ -1,7 +1,7 @@ --- description: insert-network-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/insert-shutdown-error.json b/specifications/server-discovery-and-monitoring/tests/unified/insert-shutdown-error.json index 3c724fa5e4c..af7c6c987af 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/insert-shutdown-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/insert-shutdown-error.json @@ -1,6 +1,6 @@ { "description": "insert-shutdown-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/insert-shutdown-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/insert-shutdown-error.yml index 1ec920a6bcc..ae32229ffa2 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/insert-shutdown-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/insert-shutdown-error.yml @@ -1,7 +1,7 @@ --- description: insert-shutdown-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # failCommand appName requirements diff --git a/specifications/server-discovery-and-monitoring/tests/unified/logging-replicaset.json b/specifications/server-discovery-and-monitoring/tests/unified/logging-replicaset.json index e6738225cd0..fe6ac60b685 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/logging-replicaset.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/logging-replicaset.json @@ -357,6 +357,7 @@ }, "durationMS": { "$$type": [ + "double", "int", "long" ] @@ -398,6 +399,7 @@ }, "durationMS": { "$$type": [ + "double", "int", "long" ] @@ -439,6 +441,7 @@ }, "durationMS": { "$$type": [ + "double", "int", "long" ] @@ -589,6 +592,7 @@ }, "durationMS": { "$$type": [ + "double", "int", "long" ] diff --git a/specifications/server-discovery-and-monitoring/tests/unified/logging-replicaset.yml b/specifications/server-discovery-and-monitoring/tests/unified/logging-replicaset.yml index a0b856ec726..0e7cc770678 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/logging-replicaset.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/logging-replicaset.yml @@ -176,7 +176,7 @@ tests: serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } serverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } reply: $$matchAsDocument: "$$matchAsRoot": @@ -191,7 +191,7 @@ tests: serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } serverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } reply: $$matchAsDocument: "$$matchAsRoot": @@ -206,7 +206,7 @@ tests: serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } serverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } reply: $$matchAsDocument: "$$matchAsRoot": @@ -285,5 +285,5 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } failure: { $$exists: true } \ No newline at end of file diff --git a/specifications/server-discovery-and-monitoring/tests/unified/logging-sharded.json b/specifications/server-discovery-and-monitoring/tests/unified/logging-sharded.json index 61b27f5be0b..3788708ab08 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/logging-sharded.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/logging-sharded.json @@ -324,6 +324,7 @@ }, "durationMS": { "$$type": [ + "double", "int", "long" ] @@ -475,6 +476,7 @@ }, "durationMS": { "$$type": [ + "double", "int", "long" ] diff --git a/specifications/server-discovery-and-monitoring/tests/unified/logging-sharded.yml b/specifications/server-discovery-and-monitoring/tests/unified/logging-sharded.yml index 19870878b9f..65309b6bb49 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/logging-sharded.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/logging-sharded.yml @@ -164,7 +164,7 @@ tests: serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } serverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } reply: $$matchAsDocument: "$$matchAsRoot": @@ -244,5 +244,5 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } failure: { $$exists: true } \ No newline at end of file diff --git a/specifications/server-discovery-and-monitoring/tests/unified/logging-standalone.json b/specifications/server-discovery-and-monitoring/tests/unified/logging-standalone.json index 1ee6dbe8995..0682a1a4fb2 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/logging-standalone.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/logging-standalone.json @@ -339,6 +339,7 @@ }, "durationMS": { "$$type": [ + "double", "int", "long" ] @@ -500,6 +501,7 @@ }, "durationMS": { "$$type": [ + "double", "int", "long" ] diff --git a/specifications/server-discovery-and-monitoring/tests/unified/logging-standalone.yml b/specifications/server-discovery-and-monitoring/tests/unified/logging-standalone.yml index 80cf98a20e5..b243abf6f68 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/logging-standalone.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/logging-standalone.yml @@ -169,7 +169,7 @@ tests: serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } serverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } reply: $$matchAsDocument: "$$matchAsRoot": @@ -254,5 +254,5 @@ tests: serverHost: { $$type: string } serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } - durationMS: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } failure: { $$exists: true } \ No newline at end of file diff --git a/specifications/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json b/specifications/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json index 41834d9161e..555b37d0b9d 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/minPoolSize-error.json @@ -1,6 +1,6 @@ { "description": "minPoolSize-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4.7", @@ -27,7 +27,7 @@ ], "tests": [ { - "description": "Network error on minPoolSize background creation", + "description": "Server error on minPoolSize background creation", "operations": [ { "name": "failPoint", @@ -45,7 +45,7 @@ "isMaster" ], "appName": "SDAMminPoolSizeError", - "closeConnection": true + "errorCode": 91 } } } diff --git a/specifications/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml index 8377558167c..8a471877088 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/minPoolSize-error.yml @@ -1,7 +1,7 @@ --- description: minPoolSize-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # Require SERVER-49336 for failCommand + appName on the initial handshake. @@ -21,7 +21,7 @@ initialData: &initialData documents: [] tests: - - description: Network error on minPoolSize background creation + - description: Server error on minPoolSize background creation operations: # Configure the initial monitor handshake to succeed but the # first or second background minPoolSize establishments to fail. @@ -38,7 +38,7 @@ tests: - hello - isMaster appName: SDAMminPoolSizeError - closeConnection: true + errorCode: 91 - name: createEntities object: testRunner arguments: diff --git a/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-checkout-error.json b/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-checkout-error.json index 126ee545333..7e6c7c8df4d 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-checkout-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-checkout-error.json @@ -143,154 +143,6 @@ ] } ] - }, - { - "description": "Pool is cleared before connection is closed (handshake error)", - "runOnRequirements": [ - { - "topologies": [ - "single" - ] - } - ], - "operations": [ - { - "name": "createEntities", - "object": "testRunner", - "arguments": { - "entities": [ - { - "client": { - "id": "client", - "useMultipleMongoses": false, - "observeEvents": [ - "connectionCheckOutStartedEvent", - "poolClearedEvent", - "connectionClosedEvent", - "topologyDescriptionChangedEvent" - ], - "uriOptions": { - "retryWrites": false, - "appname": "authErrorTest", - "minPoolSize": 0, - "serverMonitoringMode": "poll", - "heartbeatFrequencyMS": 1000000 - } - } - }, - { - "database": { - "id": "database", - "client": "client", - "databaseName": "foo" - } - }, - { - "collection": { - "id": "collection", - "database": "database", - "collectionName": "bar" - } - } - ] - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "topologyDescriptionChangedEvent": { - "previousDescription": { - "type": "Unknown" - }, - "newDescription": { - "type": "Single" - } - } - }, - "count": 1 - } - }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "authErrorTest", - "closeConnection": true - } - } - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - "expectError": { - "isError": true - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "poolClearedEvent": {} - }, - "count": 1 - } - }, - { - "name": "waitForEvent", - "object": "testRunner", - "arguments": { - "client": "client", - "event": { - "connectionClosedEvent": {} - }, - "count": 1 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "cmap", - "events": [ - { - "connectionCheckOutStartedEvent": {} - }, - { - "poolClearedEvent": {} - }, - { - "connectionClosedEvent": {} - } - ] - } - ] } ] } diff --git a/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-checkout-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-checkout-error.yml index 8df74b6a6f5..5f7c48b5210 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-checkout-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-checkout-error.yml @@ -84,93 +84,3 @@ tests: - connectionCheckOutStartedEvent: {} - poolClearedEvent: {} - connectionClosedEvent: {} - - - description: Pool is cleared before connection is closed (handshake error) - runOnRequirements: - - topologies: [ single ] - operations: - - name: createEntities - object: testRunner - arguments: - entities: - - client: - id: &client client - useMultipleMongoses: false - observeEvents: - - connectionCheckOutStartedEvent - - poolClearedEvent - - connectionClosedEvent - - topologyDescriptionChangedEvent - uriOptions: - retryWrites: false - appname: authErrorTest - minPoolSize: 0 - # ensure that once we've connected to the server, the failCommand won't - # be triggered by monitors and will only be triggered by handshakes - serverMonitoringMode: poll - heartbeatFrequencyMS: 1000000 - - database: - id: &database database - client: *client - databaseName: foo - - collection: - id: &collection collection - database: *database - collectionName: bar - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - topologyDescriptionChangedEvent: - previousDescription: - type: "Unknown" - newDescription: - type: "Single" - count: 1 - - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - hello - - isMaster - appName: authErrorTest - closeConnection: true - - - name: insertMany - object: *collection - arguments: - documents: - - _id: 3 - - _id: 4 - expectError: - isError: true - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - poolClearedEvent: {} - count: 1 - - name: waitForEvent - object: testRunner - arguments: - client: *client - event: - connectionClosedEvent: {} - count: 1 - expectEvents: - - client: *client - eventType: cmap - events: - - connectionCheckOutStartedEvent: {} - - poolClearedEvent: {} - - connectionClosedEvent: {} - diff --git a/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.json b/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.json index 11c6be5bc16..a0139bd0331 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.json @@ -56,7 +56,7 @@ "client": { "id": "client", "observeEvents": [ - "connectionCreatedEvent", + "poolReadyEvent", "poolClearedEvent", "connectionClosedEvent" ], @@ -75,7 +75,7 @@ "arguments": { "client": "client", "event": { - "poolClearedEvent": {} + "poolReadyEvent": {} }, "count": 1 } @@ -86,33 +86,48 @@ "arguments": { "client": "client", "event": { - "connectionClosedEvent": {} + "poolClearedEvent": {} }, "count": 1 } - } - ], - "expectEvents": [ + }, { - "client": "client", - "eventType": "cmap", - "events": [ - { - "connectionCreatedEvent": {} - }, - { - "poolClearedEvent": {} - }, - { + "name": "waitForEvent", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { "connectionClosedEvent": {} - } - ] + }, + "count": 1 + } } ] }, { - "description": "Pool is cleared on handshake error during minPoolSize population", + "description": "Pool is not cleared on handshake error during minPoolSize population", "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "setupClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "skip": 1 + }, + "data": { + "failCommands": [ + "hello", + "isMaster" + ], + "appName": "authErrorTest", + "closeConnection": true + } + } + } + }, { "name": "createEntities", "object": "testRunner", @@ -122,11 +137,9 @@ "client": { "id": "client", "observeEvents": [ - "topologyDescriptionChangedEvent", - "connectionCreatedEvent", + "poolReadyEvent", "poolClearedEvent", - "connectionClosedEvent", - "connectionReadyEvent" + "connectionClosedEvent" ], "uriOptions": { "appname": "authErrorTest", @@ -146,83 +159,32 @@ "arguments": { "client": "client", "event": { - "topologyDescriptionChangedEvent": { - "previousDescription": { - "type": "Unknown" - }, - "newDescription": { - "type": "Single" - } - } + "poolReadyEvent": {} }, "count": 1 } }, - { - "name": "failPoint", - "object": "testRunner", - "arguments": { - "client": "setupClient", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "hello", - "isMaster" - ], - "appName": "authErrorTest", - "closeConnection": true - } - } - } - }, { "name": "waitForEvent", "object": "testRunner", "arguments": { "client": "client", "event": { - "poolClearedEvent": {} + "connectionClosedEvent": {} }, "count": 1 } }, { - "name": "waitForEvent", + "name": "assertEventCount", "object": "testRunner", "arguments": { "client": "client", "event": { - "connectionClosedEvent": {} - }, - "count": 1 - } - } - ], - "expectEvents": [ - { - "client": "client", - "eventType": "cmap", - "events": [ - { - "connectionCreatedEvent": {} - }, - { - "connectionReadyEvent": {} - }, - { - "connectionCreatedEvent": {} - }, - { "poolClearedEvent": {} }, - { - "connectionClosedEvent": {} - } - ] + "count": 0 + } } ] } diff --git a/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.yml index 7e7ef0c590b..2c8e32a410e 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/pool-clear-min-pool-size-error.yml @@ -40,12 +40,21 @@ tests: - client: id: &client client observeEvents: - - connectionCreatedEvent + - poolReadyEvent - poolClearedEvent - connectionClosedEvent uriOptions: appname: authErrorTest minPoolSize: 1 + + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolReadyEvent: {} + count: 1 + - name: waitForEvent object: testRunner arguments: @@ -53,6 +62,7 @@ tests: event: poolClearedEvent: {} count: 1 + - name: waitForEvent object: testRunner arguments: @@ -60,16 +70,24 @@ tests: event: connectionClosedEvent: {} count: 1 - expectEvents: - - client: *client - eventType: cmap - events: - - connectionCreatedEvent: {} - - poolClearedEvent: {} - - connectionClosedEvent: {} - - description: Pool is cleared on handshake error during minPoolSize population + - description: Pool is not cleared on handshake error during minPoolSize population operations: + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + skip: 1 # skip one to let monitoring thread to move pool to ready state + data: + failCommands: + - hello + - isMaster + appName: authErrorTest + closeConnection: true + - name: createEntities object: testRunner arguments: @@ -77,11 +95,9 @@ tests: - client: id: &client client observeEvents: - - topologyDescriptionChangedEvent - - connectionCreatedEvent + - poolReadyEvent - poolClearedEvent - connectionClosedEvent - - connectionReadyEvent uriOptions: appname: authErrorTest minPoolSize: 5 @@ -96,49 +112,21 @@ tests: arguments: client: *client event: - topologyDescriptionChangedEvent: - previousDescription: - type: "Unknown" - newDescription: - type: "Single" + poolReadyEvent: {} count: 1 - - name: failPoint - object: testRunner - arguments: - client: *setupClient - failPoint: - configureFailPoint: failCommand - mode: - times: 1 - data: - failCommands: - - hello - - isMaster - appName: authErrorTest - closeConnection: true - - name: waitForEvent object: testRunner arguments: client: *client event: - poolClearedEvent: {} + connectionClosedEvent: {} count: 1 - - name: waitForEvent + + - name: assertEventCount object: testRunner arguments: client: *client event: - connectionClosedEvent: {} - count: 1 - expectEvents: - - client: *client - eventType: cmap - events: - - connectionCreatedEvent: {} - - connectionReadyEvent: {} - - connectionCreatedEvent: {} - - poolClearedEvent: {} - - connectionClosedEvent: {} - + poolClearedEvent: {} + count: 0 diff --git a/specifications/server-discovery-and-monitoring/tests/unified/pool-cleared-error.json b/specifications/server-discovery-and-monitoring/tests/unified/pool-cleared-error.json index 9a7dfd901c5..b7f6924f2ba 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/pool-cleared-error.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/pool-cleared-error.json @@ -1,6 +1,6 @@ { "description": "pool-cleared-error", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.9", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/pool-cleared-error.yml b/specifications/server-discovery-and-monitoring/tests/unified/pool-cleared-error.yml index 07bfc0c0d54..f3bad7959eb 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/pool-cleared-error.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/pool-cleared-error.yml @@ -1,7 +1,7 @@ --- description: pool-cleared-error -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # This test requires retryable writes, failCommand appName, and @@ -200,7 +200,7 @@ tests: event: poolClearedEvent: {} count: 1 - # Perform an operation to ensure the node still useable. + # Perform an operation to ensure the node still usable. - name: insertOne object: *collection arguments: diff --git a/specifications/server-discovery-and-monitoring/tests/unified/rediscover-quickly-after-step-down.json b/specifications/server-discovery-and-monitoring/tests/unified/rediscover-quickly-after-step-down.json index c7c2494857a..3147a07a1e6 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/rediscover-quickly-after-step-down.json +++ b/specifications/server-discovery-and-monitoring/tests/unified/rediscover-quickly-after-step-down.json @@ -1,6 +1,6 @@ { "description": "rediscover-quickly-after-step-down", - "schemaVersion": "1.10", + "schemaVersion": "1.4", "runOnRequirements": [ { "minServerVersion": "4.4", diff --git a/specifications/server-discovery-and-monitoring/tests/unified/rediscover-quickly-after-step-down.yml b/specifications/server-discovery-and-monitoring/tests/unified/rediscover-quickly-after-step-down.yml index e5b49de35d7..f3e7509160e 100644 --- a/specifications/server-discovery-and-monitoring/tests/unified/rediscover-quickly-after-step-down.yml +++ b/specifications/server-discovery-and-monitoring/tests/unified/rediscover-quickly-after-step-down.yml @@ -1,7 +1,7 @@ --- description: rediscover-quickly-after-step-down -schemaVersion: "1.10" +schemaVersion: "1.4" runOnRequirements: # 4.4 is required for streaming. diff --git a/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs b/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs index 4ea159e8182..e45b041b8cd 100644 --- a/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs +++ b/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs @@ -282,6 +282,12 @@ private void OpenHelper(OperationContext operationContext) { _description ??= handshakeDescription; var wrappedException = WrapExceptionIfRequired(operationContext, ex, "opening a connection to the server"); + if (handshakeDescription == null) + { + // Should apply Backpressure error labels on network errors only during the connection establishment or the `hello` message. + AddBackpressureErrorLabelsIfRequired(wrappedException); + } + helper.FailedOpeningConnection(wrappedException ?? ex); if (wrappedException == null) { throw; } else { throw wrappedException; } } @@ -315,6 +321,12 @@ private async Task OpenHelperAsync(OperationContext operationContext) { _description ??= handshakeDescription; var wrappedException = WrapExceptionIfRequired(operationContext, ex, "opening a connection to the server"); + if (handshakeDescription == null) + { + // Should apply Backpressure error labels on network errors only during the connection establishment or the `hello` message. + AddBackpressureErrorLabelsIfRequired(wrappedException); + } + helper.FailedOpeningConnection(wrappedException ?? ex); if (wrappedException == null) { throw; } else { throw wrappedException; } } @@ -581,6 +593,15 @@ public async Task SendMessageAsync(OperationContext operationContext, RequestMes } // private methods + private void AddBackpressureErrorLabelsIfRequired(MongoConnectionException exception) + { + if (exception.ContainsTimeoutException || exception.InnerException is IOException) + { + exception.AddErrorLabel("SystemOverloadedError"); + exception.AddErrorLabel("RetryableError"); + } + } + private bool ShouldBeCompressed(RequestMessage message) { return _sendCompressorType.HasValue && message.MayBeCompressed; @@ -664,7 +685,7 @@ private void ThrowIfDisposed() } } - private Exception WrapExceptionIfRequired(OperationContext operationContext, Exception ex, string action) + private MongoConnectionException WrapExceptionIfRequired(OperationContext operationContext, Exception ex, string action) { if (ex is TimeoutException && operationContext.IsRootContextTimeoutConfigured()) { @@ -681,6 +702,11 @@ ex is OperationCanceledException || return null; } + if (ex is MongoConnectionException mongoConnectionException) + { + return mongoConnectionException; + } + var message = string.Format("An exception occurred while {0}.", action); return new MongoConnectionException(_connectionId, message, ex); } diff --git a/src/MongoDB.Driver/Core/Misc/Feature.cs b/src/MongoDB.Driver/Core/Misc/Feature.cs index 2136f31736d..04e62523e6f 100644 --- a/src/MongoDB.Driver/Core/Misc/Feature.cs +++ b/src/MongoDB.Driver/Core/Misc/Feature.cs @@ -76,6 +76,7 @@ public class Feature private static readonly Feature __hintForDeleteOperations = new Feature("HintForDeleteOperations", WireVersion.Server44); private static readonly HintForFindAndModifyFeature __hintForFindAndModifyFeature = new HintForFindAndModifyFeature("HintForFindAndModify", WireVersion.Server44); private static readonly Feature __hintForUpdateAndReplaceOperations = new Feature("HintForUpdateAndReplaceOperations", WireVersion.Server42); + private static readonly Feature __ingressConnectionEstablishmentRateLimiter = new Feature("IngressConnectionEstablishmentRateLimiter", WireVersion.Server80); private static readonly Feature __keepConnectionPoolWhenNotPrimaryConnectionException = new Feature("KeepConnectionPoolWhenNotWritablePrimaryConnectionException", WireVersion.Server42); private static readonly Feature __keepConnectionPoolWhenReplSetStepDown = new Feature("KeepConnectionPoolWhenReplSetStepDown", WireVersion.Server42); private static readonly Feature __legacyWireProtocol = new Feature("LegacyWireProtocol", WireVersion.Zero, WireVersion.Server51); @@ -368,6 +369,11 @@ public class Feature [Obsolete("This property will be removed in a later release.")] public static Feature HintForUpdateAndReplaceOperations => __hintForUpdateAndReplaceOperations; + /// + /// Ingress Connection Establishment Rate Limiter feature + /// + public static Feature IngressConnectionEstablishmentRateLimiter => __ingressConnectionEstablishmentRateLimiter; + /// /// Gets the keep connection pool when NotPrimary connection exception feature. /// diff --git a/src/MongoDB.Driver/Core/Servers/DefaultServer.cs b/src/MongoDB.Driver/Core/Servers/DefaultServer.cs index eb744f2e993..0f2661e1e61 100644 --- a/src/MongoDB.Driver/Core/Servers/DefaultServer.cs +++ b/src/MongoDB.Driver/Core/Servers/DefaultServer.cs @@ -98,7 +98,7 @@ protected override void HandleBeforeHandshakeCompletesException(Exception ex) var (invalidateAndClear, cancelCheck) = ex switch { MongoAuthenticationException => (invalidateAndClear: true, cancelCheck: false), - _ => (invalidateAndClear: connectionException.IsNetworkException || connectionException.ContainsTimeoutException, + _ => (invalidateAndClear: (connectionException.IsNetworkException || connectionException.ContainsTimeoutException) && !connectionException.HasErrorLabel("SystemOverloadedError"), cancelCheck: connectionException.IsNetworkException && !connectionException.ContainsTimeoutException) }; diff --git a/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs index 7ade86c99c3..fd019f9a924 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs @@ -180,15 +180,8 @@ public void RetryableWrites(JsonDrivenTestCase testCase) [Category("SDAM", "SupportLoadBalancing")] [UnifiedTestsTheory("server_discovery_and_monitoring.tests.unified")] - public void ServerDiscoveryAndMonitoring(JsonDrivenTestCase testCase) - { - if (testCase.Name.Contains("pool-clear-")) - { - throw new SkipException("This test is flaky and is skipped while being investigated."); - } - + public void ServerDiscoveryAndMonitoring(JsonDrivenTestCase testCase) => Run(testCase, IsSdamLogValid, new SdamRunnerEventsProcessor(testCase.Name)); - } [Category("SupportLoadBalancing")] [UnifiedTestsTheory("server_selection.tests.logging")] diff --git a/tests/MongoDB.Driver.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs index 36167447d7d..663a27d2d77 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs @@ -269,6 +269,11 @@ private void AssertEvent(object actualEvent, BsonDocument expectedEvent) throw new NotImplementedException(); } } + + if (expectedEvent.TryGetValue("interruptInUseConnections", out var interruptInUseConnections)) + { + actualEvent.CloseInUseConnections().Should().Be(interruptInUseConnections.ToBoolean()); + } } private void AssertEvents(BsonDocument test, EventCapturer eventCapturer, Func eventsFilter) @@ -281,7 +286,7 @@ private void AssertEvents(BsonDocument test, EventCapturer eventCapturer, Func CreateTestCases(BsonDocument internal static class CmapEventsReflector { + public static bool CloseInUseConnections(this object @event) + { + return (bool)Reflector.GetPropertyValue(@event, nameof(CloseInUseConnections), BindingFlags.Public | BindingFlags.Instance); + } + public static ConnectionId ConnectionId(this object @event) { return (ConnectionId)Reflector.GetPropertyValue(@event, nameof(ConnectionId), BindingFlags.Public | BindingFlags.Instance); diff --git a/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/prose-tests/ServerDiscoveryProseTests.cs b/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/prose-tests/ServerDiscoveryProseTests.cs index 928823a8570..e962ff77af9 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/prose-tests/ServerDiscoveryProseTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/prose-tests/ServerDiscoveryProseTests.cs @@ -17,9 +17,13 @@ using System.Linq; using System.Net; using System.Threading; +using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; +using MongoDB.Bson.TestHelpers; +using MongoDB.Driver.Core; using MongoDB.Driver.Core.Clusters; +using MongoDB.Driver.Core.Events; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; using MongoDB.Driver.Core.TestHelpers.Logging; @@ -86,6 +90,63 @@ public void Topology_secondary_discovery_with_directConnection_false_should_work } } + // https://github.com/mongodb/specifications/blob/a8d34be0df234365600a9269af5a463f581562fd/source/server-discovery-and-monitoring/server-discovery-and-monitoring-tests.md?plain=1#L176 + [Theory] + [ParameterAttributeData] + public async Task Connection_Pool_Backpressure([Values(true, false)]bool async) + { + RequireServer.Check().Supports(Feature.IngressConnectionEstablishmentRateLimiter); + + var setupClient = DriverTestConfiguration.Client; + var adminDatabase = setupClient.GetDatabase(DatabaseNamespace.Admin.DatabaseName); + + adminDatabase.RunCommand( + @"{ + setParameter : 1, + ingressConnectionEstablishmentRateLimiterEnabled: true, + ingressConnectionEstablishmentRatePerSec: 20, + ingressConnectionEstablishmentBurstCapacitySecs: 1, + ingressConnectionEstablishmentMaxQueueDepth: 1 + }"); + + try + { + var eventCapturer = new EventCapturer() + .Capture() + .Capture(); + + using var client = DriverTestConfiguration.CreateMongoClient(settings => + { + settings.MaxConnecting = 100; + settings.LoggingSettings = LoggingSettings; + settings.ClusterConfigurator = c => c.Subscribe(eventCapturer); + }); + + var collection = client.GetDatabase("test").GetCollection("test"); + collection.InsertOne(new BsonDocument()); + + _ = await ThreadingUtilities.ExecuteTasksOnNewThreadsCollectExceptions(100, async i => + { + await Task.Yield(); + var filter = "{ $where : \"function() { sleep(2000); return true; }\" }"; + _ = async ? await collection.FindAsync(filter) : collection.FindSync(filter); + }, Timeout.Infinite); + + eventCapturer.Events.Count(e => e is ConnectionPoolCheckingOutConnectionFailedEvent).Should().BeGreaterOrEqualTo(10); + eventCapturer.Events.Should().NotContain(e => e is ConnectionPoolClearedEvent); + } + finally + { + Thread.Sleep(1000); + + adminDatabase.RunCommand( + @"{ + setParameter : 1, + ingressConnectionEstablishmentRateLimiterEnabled: false + }"); + } + } + // private methods private string CreateConnectionString(DnsEndPoint endpoint, bool? directConnection, string replicaSetName) {