diff --git a/.evergreen/combine-coverage.sh b/.evergreen/combine-coverage.sh index 7db4a6cbc..92d2f1f1f 100644 --- a/.evergreen/combine-coverage.sh +++ b/.evergreen/combine-coverage.sh @@ -15,7 +15,7 @@ fi createvirtualenv "$PYTHON_BINARY" covenv # Keep in sync with run-tests.sh # coverage >=5 is needed for relative_files=true. -pip install -q "coverage>=5,<=7.5" +pip install -q "coverage[toml]>=5,<=7.5" pip list ls -la coverage/ diff --git a/.evergreen/config.yml b/.evergreen/config.yml index af9a49659..8f32b8a1b 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -2854,7 +2854,7 @@ buildvariants: matrix_spec: platform: rhel7 # Python 3.10+ requires OpenSSL 1.1.1+ - python-version: ["3.8", "3.9", "pypy3.9", "pypy3.10"] + python-version: ["3.8", "3.9"] auth-ssl: "*" display_name: "OpenSSL 1.0.2 ${python-version} ${platform} ${auth-ssl}" tasks: @@ -3153,7 +3153,7 @@ buildvariants: - name: testazurekms-variant display_name: "Azure KMS" - run_on: rhel87-small + run_on: debian11-small tasks: - name: testazurekms_task_group batchtime: 20160 # Use a batchtime of 14 days as suggested by the CSFLE test README diff --git a/.evergreen/utils.sh b/.evergreen/utils.sh index f881d9190..ff186c6e1 100755 --- a/.evergreen/utils.sh +++ b/.evergreen/utils.sh @@ -67,7 +67,6 @@ createvirtualenv () { export PIP_QUIET=1 python -m pip install --upgrade pip - python -m pip install --upgrade hatch } # Usage: diff --git a/pymongo/network_layer.py b/pymongo/network_layer.py index 6087b1aa8..f1c378b9b 100644 --- a/pymongo/network_layer.py +++ b/pymongo/network_layer.py @@ -18,32 +18,111 @@ from __future__ import annotations import asyncio import socket import struct +import sys +from asyncio import AbstractEventLoop, Future from typing import ( - TYPE_CHECKING, Union, ) from pymongo import ssl_support -if TYPE_CHECKING: - from pymongo.pyopenssl_context import _sslConn +try: + from ssl import SSLError, SSLSocket + + _HAVE_SSL = True +except ImportError: + _HAVE_SSL = False + +try: + from pymongo.pyopenssl_context import ( + BLOCKING_IO_LOOKUP_ERROR, + BLOCKING_IO_READ_ERROR, + BLOCKING_IO_WRITE_ERROR, + _sslConn, + ) + + _HAVE_PYOPENSSL = True +except ImportError: + _HAVE_PYOPENSSL = False + _sslConn = SSLSocket # type: ignore + from pymongo.ssl_support import ( # type: ignore[assignment] + BLOCKING_IO_LOOKUP_ERROR, + BLOCKING_IO_READ_ERROR, + BLOCKING_IO_WRITE_ERROR, + ) _UNPACK_HEADER = struct.Struct(" None: - timeout = socket.gettimeout() - socket.settimeout(0.0) +async def async_sendall(sock: Union[socket.socket, _sslConn], buf: bytes) -> None: + timeout = sock.gettimeout() + sock.settimeout(0.0) loop = asyncio.get_event_loop() try: - await asyncio.wait_for(loop.sock_sendall(socket, buf), timeout=timeout) # type: ignore[arg-type] + if _HAVE_SSL and isinstance(sock, (SSLSocket, _sslConn)): + if sys.platform == "win32": + await asyncio.wait_for(_async_sendall_ssl_windows(sock, buf), timeout=timeout) + else: + await asyncio.wait_for(_async_sendall_ssl(sock, buf, loop), timeout=timeout) + else: + await asyncio.wait_for(loop.sock_sendall(sock, buf), timeout=timeout) # type: ignore[arg-type] finally: - socket.settimeout(timeout) + sock.settimeout(timeout) -def sendall(socket: Union[socket.socket, _sslConn], buf: bytes) -> None: - socket.sendall(buf) +async def _async_sendall_ssl( + sock: Union[socket.socket, _sslConn], buf: bytes, loop: AbstractEventLoop +) -> None: + fd = sock.fileno() + sent = 0 + + def _is_ready(fut: Future) -> None: + loop.remove_writer(fd) + loop.remove_reader(fd) + if fut.done(): + return + fut.set_result(None) + + while sent < len(buf): + try: + sent += sock.send(buf) + except BLOCKING_IO_ERRORS as exc: + fd = sock.fileno() + # Check for closed socket. + if fd == -1: + raise SSLError("Underlying socket has been closed") from None + if isinstance(exc, BLOCKING_IO_READ_ERROR): + fut = loop.create_future() + loop.add_reader(fd, _is_ready, fut) + await fut + if isinstance(exc, BLOCKING_IO_WRITE_ERROR): + fut = loop.create_future() + loop.add_writer(fd, _is_ready, fut) + await fut + if _HAVE_PYOPENSSL and isinstance(exc, BLOCKING_IO_LOOKUP_ERROR): + fut = loop.create_future() + loop.add_reader(fd, _is_ready, fut) + loop.add_writer(fd, _is_ready, fut) + await fut + + +# The default Windows asyncio event loop does not support loop.add_reader/add_writer: https://docs.python.org/3/library/asyncio-platforms.html#asyncio-platform-support +async def _async_sendall_ssl_windows(sock: Union[socket.socket, _sslConn], buf: bytes) -> None: + view = memoryview(buf) + total_length = len(buf) + total_sent = 0 + while total_sent < total_length: + try: + sent = sock.send(view[total_sent:]) + except BLOCKING_IO_ERRORS: + await asyncio.sleep(0.5) + sent = 0 + total_sent += sent + + +def sendall(sock: Union[socket.socket, _sslConn], buf: bytes) -> None: + sock.sendall(buf) diff --git a/pymongo/pyopenssl_context.py b/pymongo/pyopenssl_context.py index c1b85af12..4f6f6f4a8 100644 --- a/pymongo/pyopenssl_context.py +++ b/pymongo/pyopenssl_context.py @@ -90,6 +90,9 @@ def _is_ip_address(address: Any) -> bool: # According to the docs for socket.send it can raise # WantX509LookupError and should be retried. BLOCKING_IO_ERRORS = (_SSL.WantReadError, _SSL.WantWriteError, _SSL.WantX509LookupError) +BLOCKING_IO_READ_ERROR = _SSL.WantReadError +BLOCKING_IO_WRITE_ERROR = _SSL.WantWriteError +BLOCKING_IO_LOOKUP_ERROR = _SSL.WantX509LookupError def _ragged_eof(exc: BaseException) -> bool: diff --git a/pymongo/ssl_context.py b/pymongo/ssl_context.py index 1a0424208..ee32145c0 100644 --- a/pymongo/ssl_context.py +++ b/pymongo/ssl_context.py @@ -30,6 +30,8 @@ IS_PYOPENSSL = False # Errors raised by SSL sockets when in non-blocking mode. BLOCKING_IO_ERRORS = (_ssl.SSLWantReadError, _ssl.SSLWantWriteError) +BLOCKING_IO_READ_ERROR = _ssl.SSLWantReadError +BLOCKING_IO_WRITE_ERROR = _ssl.SSLWantWriteError # Base Exception class SSLError = _ssl.SSLError diff --git a/pymongo/ssl_support.py b/pymongo/ssl_support.py index 6a5dd278d..580d71f9b 100644 --- a/pymongo/ssl_support.py +++ b/pymongo/ssl_support.py @@ -53,6 +53,9 @@ if HAVE_SSL: IPADDR_SAFE = True SSLError = _ssl.SSLError BLOCKING_IO_ERRORS = _ssl.BLOCKING_IO_ERRORS + BLOCKING_IO_READ_ERROR = _ssl.BLOCKING_IO_READ_ERROR + BLOCKING_IO_WRITE_ERROR = _ssl.BLOCKING_IO_WRITE_ERROR + BLOCKING_IO_LOOKUP_ERROR = BLOCKING_IO_READ_ERROR def get_ssl_context( certfile: Optional[str], diff --git a/test/__init__.py b/test/__init__.py index b603ae0a5..b8394bd13 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -728,9 +728,9 @@ class ClientContext: def require_failCommand_appName(self, func): """Run a test only if the server supports the failCommand appName.""" - # SERVER-47195 + # SERVER-47195 and SERVER-49336. return self._require( - lambda: (self.test_commands_enabled and self.version >= (4, 4, -1)), + lambda: (self.test_commands_enabled and self.version >= (4, 4, 7)), "failCommand appName must be supported", func=func, ) diff --git a/test/asynchronous/__init__.py b/test/asynchronous/__init__.py index 878ef81ba..4098d9af8 100644 --- a/test/asynchronous/__init__.py +++ b/test/asynchronous/__init__.py @@ -730,9 +730,9 @@ class AsyncClientContext: def require_failCommand_appName(self, func): """Run a test only if the server supports the failCommand appName.""" - # SERVER-47195 + # SERVER-47195 and SERVER-49336. return self._require( - lambda: (self.test_commands_enabled and self.version >= (4, 4, -1)), + lambda: (self.test_commands_enabled and self.version >= (4, 4, 7)), "failCommand appName must be supported", func=func, ) diff --git a/test/connection_monitoring/pool-checkin-make-available.json b/test/connection_monitoring/pool-checkin-make-available.json index 41c522ae6..3f37f188c 100644 --- a/test/connection_monitoring/pool-checkin-make-available.json +++ b/test/connection_monitoring/pool-checkin-make-available.json @@ -22,7 +22,8 @@ { "type": "ConnectionCheckedOut", "connectionId": 1, - "address": 42 + "address": 42, + "duration": 42 }, { "type": "ConnectionCheckedIn", @@ -32,7 +33,8 @@ { "type": "ConnectionCheckedOut", "connectionId": 1, - "address": 42 + "address": 42, + "duration": 42 } ], "ignore": [ diff --git a/test/connection_monitoring/pool-checkout-connection.json b/test/connection_monitoring/pool-checkout-connection.json index d89b34260..c7e8914d4 100644 --- a/test/connection_monitoring/pool-checkout-connection.json +++ b/test/connection_monitoring/pool-checkout-connection.json @@ -23,12 +23,14 @@ { "type": "ConnectionReady", "connectionId": 1, - "address": 42 + "address": 42, + "duration": 42 }, { "type": "ConnectionCheckedOut", "connectionId": 1, - "address": 42 + "address": 42, + "duration": 42 } ], "ignore": [ diff --git a/test/connection_monitoring/pool-checkout-error-closed.json b/test/connection_monitoring/pool-checkout-error-closed.json index ee2926e1c..614403ef5 100644 --- a/test/connection_monitoring/pool-checkout-error-closed.json +++ b/test/connection_monitoring/pool-checkout-error-closed.json @@ -38,7 +38,8 @@ { "type": "ConnectionCheckedOut", "address": 42, - "connectionId": 42 + "connectionId": 42, + "duration": 42 }, { "type": "ConnectionCheckedIn", @@ -56,6 +57,7 @@ { "type": "ConnectionCheckOutFailed", "address": 42, + "duration": 42, "reason": "poolClosed" } ], diff --git a/test/connection_monitoring/pool-checkout-maxConnecting-timeout.json b/test/connection_monitoring/pool-checkout-maxConnecting-timeout.json index 84ddf8fdb..4d9fda1a6 100644 --- a/test/connection_monitoring/pool-checkout-maxConnecting-timeout.json +++ b/test/connection_monitoring/pool-checkout-maxConnecting-timeout.json @@ -89,7 +89,8 @@ { "type": "ConnectionCheckOutFailed", "reason": "timeout", - "address": 42 + "address": 42, + "duration": 42 } ], "ignore": [ diff --git a/test/connection_monitoring/pool-clear-clears-waitqueue.json b/test/connection_monitoring/pool-clear-clears-waitqueue.json index d4aef928c..e6077f12a 100644 --- a/test/connection_monitoring/pool-clear-clears-waitqueue.json +++ b/test/connection_monitoring/pool-clear-clears-waitqueue.json @@ -59,7 +59,8 @@ }, { "type": "ConnectionCheckedOut", - "address": 42 + "address": 42, + "duration": 42 }, { "type": "ConnectionCheckOutStarted", @@ -76,17 +77,20 @@ { "type": "ConnectionCheckOutFailed", "reason": "connectionError", - "address": 42 + "address": 42, + "duration": 42 }, { "type": "ConnectionCheckOutFailed", "reason": "connectionError", - "address": 42 + "address": 42, + "duration": 42 }, { "type": "ConnectionCheckOutFailed", "reason": "connectionError", - "address": 42 + "address": 42, + "duration": 42 } ], "ignore": [ diff --git a/test/connection_monitoring/pool-clear-interrupting-pending-connections.json b/test/connection_monitoring/pool-clear-interrupting-pending-connections.json index ceae07a1c..c1fd74632 100644 --- a/test/connection_monitoring/pool-clear-interrupting-pending-connections.json +++ b/test/connection_monitoring/pool-clear-interrupting-pending-connections.json @@ -17,7 +17,7 @@ ], "closeConnection": false, "blockConnection": true, - "blockTimeMS": 1000 + "blockTimeMS": 10000 } }, "poolOptions": { diff --git a/test/connection_monitoring/pool-clear-ready.json b/test/connection_monitoring/pool-clear-ready.json index 800c3545a..88c2988ac 100644 --- a/test/connection_monitoring/pool-clear-ready.json +++ b/test/connection_monitoring/pool-clear-ready.json @@ -40,7 +40,8 @@ { "type": "ConnectionCheckedOut", "address": 42, - "connectionId": 42 + "connectionId": 42, + "duration": 42 }, { "type": "ConnectionPoolCleared", @@ -49,6 +50,7 @@ { "type": "ConnectionCheckOutFailed", "address": 42, + "duration": 42, "reason": "connectionError" }, { @@ -57,7 +59,8 @@ }, { "type": "ConnectionCheckedOut", - "address": 42 + "address": 42, + "duration": 42 } ], "ignore": [ diff --git a/test/connection_monitoring/pool-ready.json b/test/connection_monitoring/pool-ready.json index 29ce7326c..a90aed04d 100644 --- a/test/connection_monitoring/pool-ready.json +++ b/test/connection_monitoring/pool-ready.json @@ -31,7 +31,8 @@ { "type": "ConnectionCheckOutFailed", "reason": "connectionError", - "address": 42 + "address": 42, + "duration": 42 }, { "type": "ConnectionPoolReady", @@ -47,7 +48,8 @@ }, { "type": "ConnectionCheckedOut", - "address": 42 + "address": 42, + "duration": 42 } ], "ignore": [ diff --git a/test/connection_monitoring/wait-queue-timeout.json b/test/connection_monitoring/wait-queue-timeout.json index fbcbdfb04..8bd7c4949 100644 --- a/test/connection_monitoring/wait-queue-timeout.json +++ b/test/connection_monitoring/wait-queue-timeout.json @@ -48,7 +48,8 @@ { "type": "ConnectionCheckedOut", "connectionId": 42, - "address": 42 + "address": 42, + "duration": 42 }, { "type": "ConnectionCheckOutStarted", @@ -57,7 +58,8 @@ { "type": "ConnectionCheckOutFailed", "reason": "timeout", - "address": 42 + "address": 42, + "duration": 42 }, { "type": "ConnectionCheckedIn", diff --git a/test/csot/change-streams.json b/test/csot/change-streams.json index a8b2b7e17..8cffb08e2 100644 --- a/test/csot/change-streams.json +++ b/test/csot/change-streams.json @@ -6,7 +6,7 @@ "minServerVersion": "4.4", "topologies": [ "replicaset", - "sharded-replicaset" + "sharded" ] } ], @@ -104,7 +104,7 @@ "aggregate" ], "blockConnection": true, - "blockTimeMS": 55 + "blockTimeMS": 250 } } } @@ -114,7 +114,7 @@ "object": "collection", "arguments": { "pipeline": [], - "timeoutMS": 50 + "timeoutMS": 200 }, "expectError": { "isTimeoutError": true @@ -242,7 +242,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 150 } } } @@ -252,7 +252,7 @@ "object": "collection", "arguments": { "pipeline": [], - "timeoutMS": 20, + "timeoutMS": 200, "batchSize": 2, "maxAwaitTimeMS": 1 }, @@ -310,7 +310,7 @@ "object": "collection", "arguments": { "pipeline": [], - "timeoutMS": 20 + "timeoutMS": 200 }, "saveResultAsEntity": "changeStream" }, @@ -330,7 +330,7 @@ "aggregate" ], "blockConnection": true, - "blockTimeMS": 12, + "blockTimeMS": 120, "errorCode": 7, "errorLabels": [ "ResumableChangeStreamError" @@ -412,7 +412,7 @@ "arguments": { "pipeline": [], "maxAwaitTimeMS": 1, - "timeoutMS": 100 + "timeoutMS": 200 }, "saveResultAsEntity": "changeStream" }, @@ -431,7 +431,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 150 + "blockTimeMS": 250 } } } @@ -534,7 +534,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 250 } } } @@ -544,7 +544,7 @@ "object": "collection", "arguments": { "pipeline": [], - "timeoutMS": 10 + "timeoutMS": 200 }, "saveResultAsEntity": "changeStream" }, diff --git a/test/csot/close-cursors.json b/test/csot/close-cursors.json index 1361971c4..79b0de7b6 100644 --- a/test/csot/close-cursors.json +++ b/test/csot/close-cursors.json @@ -75,7 +75,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 50 + "blockTimeMS": 250 } } } @@ -86,7 +86,7 @@ "arguments": { "filter": {}, "batchSize": 2, - "timeoutMS": 20 + "timeoutMS": 200 }, "saveResultAsEntity": "cursor" }, @@ -175,7 +175,7 @@ "killCursors" ], "blockConnection": true, - "blockTimeMS": 30 + "blockTimeMS": 250 } } } @@ -186,7 +186,7 @@ "arguments": { "filter": {}, "batchSize": 2, - "timeoutMS": 20 + "timeoutMS": 200 }, "saveResultAsEntity": "cursor" }, @@ -194,7 +194,7 @@ "name": "close", "object": "cursor", "arguments": { - "timeoutMS": 40 + "timeoutMS": 400 } } ], @@ -215,7 +215,7 @@ { "commandStartedEvent": { "command": { - "killCursors": "collection", + "killCursors": "coll", "maxTimeMS": { "$$type": [ "int", diff --git a/test/csot/command-execution.json b/test/csot/command-execution.json index f0858791e..aa9c3eb23 100644 --- a/test/csot/command-execution.json +++ b/test/csot/command-execution.json @@ -3,11 +3,10 @@ "schemaVersion": "1.9", "runOnRequirements": [ { - "minServerVersion": "4.9", + "minServerVersion": "4.4.7", "topologies": [ "single", "replicaset", - "sharded-replicaset", "sharded" ], "serverless": "forbid" @@ -52,7 +51,7 @@ ], "appName": "reduceMaxTimeMSTest", "blockConnection": true, - "blockTimeMS": 75 + "blockTimeMS": 50 } } } diff --git a/test/csot/convenient-transactions.json b/test/csot/convenient-transactions.json index 0c8cc6edd..3868b3026 100644 --- a/test/csot/convenient-transactions.json +++ b/test/csot/convenient-transactions.json @@ -6,7 +6,7 @@ "minServerVersion": "4.4", "topologies": [ "replicaset", - "sharded-replicaset" + "sharded" ] } ], @@ -21,7 +21,7 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 50 + "timeoutMS": 500 }, "useMultipleMongoses": false, "observeEvents": [ @@ -81,6 +81,9 @@ } } ] + }, + "expectError": { + "isClientError": true } } ], @@ -109,7 +112,7 @@ "insert" ], "blockConnection": true, - "blockTimeMS": 30 + "blockTimeMS": 300 } } } @@ -182,6 +185,21 @@ } } } + }, + { + "commandStartedEvent": { + "commandName": "abortTransaction", + "databaseName": "admin", + "command": { + "abortTransaction": 1, + "maxTimeMS": { + "$$type": [ + "int", + "long" + ] + } + } + } } ] } diff --git a/test/csot/deprecated-options.json b/test/csot/deprecated-options.json index 9c9b9a228..d3e4631ff 100644 --- a/test/csot/deprecated-options.json +++ b/test/csot/deprecated-options.json @@ -6,7 +6,7 @@ "minServerVersion": "4.2", "topologies": [ "replicaset", - "sharded-replicaset" + "sharded" ] } ], diff --git a/test/csot/error-transformations.json b/test/csot/error-transformations.json index 4d9e061c3..4889e3958 100644 --- a/test/csot/error-transformations.json +++ b/test/csot/error-transformations.json @@ -11,7 +11,6 @@ { "minServerVersion": "4.2", "topologies": [ - "replicaset", "sharded" ] } diff --git a/test/csot/global-timeoutMS.json b/test/csot/global-timeoutMS.json index 34854ac15..740bbad2e 100644 --- a/test/csot/global-timeoutMS.json +++ b/test/csot/global-timeoutMS.json @@ -6,7 +6,7 @@ "minServerVersion": "4.4", "topologies": [ "replicaset", - "sharded-replicaset" + "sharded" ] } ], diff --git a/test/csot/legacy-timeouts.json b/test/csot/legacy-timeouts.json index 3a2d2eaef..535425c93 100644 --- a/test/csot/legacy-timeouts.json +++ b/test/csot/legacy-timeouts.json @@ -1,6 +1,6 @@ { "description": "legacy timeouts continue to work if timeoutMS is not set", - "schemaVersion": "1.9", + "schemaVersion": "1.0", "runOnRequirements": [ { "minServerVersion": "4.4" @@ -280,7 +280,7 @@ { "topologies": [ "replicaset", - "sharded-replicaset" + "sharded" ] } ], diff --git a/test/csot/non-tailable-cursors.json b/test/csot/non-tailable-cursors.json index 0a5448a6b..291c6e72a 100644 --- a/test/csot/non-tailable-cursors.json +++ b/test/csot/non-tailable-cursors.json @@ -17,7 +17,7 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 10 + "timeoutMS": 200 }, "useMultipleMongoses": false, "observeEvents": [ @@ -84,7 +84,7 @@ "find" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 250 } } } @@ -143,7 +143,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 125 } } } @@ -153,7 +153,7 @@ "object": "collection", "arguments": { "filter": {}, - "timeoutMS": 20, + "timeoutMS": 200, "batchSize": 2 }, "expectError": { @@ -221,7 +221,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 150 } } } @@ -232,7 +232,7 @@ "arguments": { "filter": {}, "timeoutMode": "cursorLifetime", - "timeoutMS": 20, + "timeoutMS": 200, "batchSize": 2 }, "expectError": { @@ -299,7 +299,7 @@ "find" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 250 } } } @@ -355,7 +355,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 125 } } } @@ -366,7 +366,7 @@ "arguments": { "filter": {}, "timeoutMode": "iteration", - "timeoutMS": 20, + "timeoutMS": 200, "batchSize": 2 } } @@ -427,7 +427,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 250 } } } diff --git a/test/csot/override-operation-timeoutMS.json b/test/csot/override-operation-timeoutMS.json index 896b996ee..6fa0bd802 100644 --- a/test/csot/override-operation-timeoutMS.json +++ b/test/csot/override-operation-timeoutMS.json @@ -6,7 +6,7 @@ "minServerVersion": "4.4", "topologies": [ "replicaset", - "sharded-replicaset" + "sharded" ] } ], diff --git a/test/csot/retryability-legacy-timeouts.json b/test/csot/retryability-legacy-timeouts.json index 63e8efccf..aded781ae 100644 --- a/test/csot/retryability-legacy-timeouts.json +++ b/test/csot/retryability-legacy-timeouts.json @@ -6,7 +6,7 @@ "minServerVersion": "4.4", "topologies": [ "replicaset", - "sharded-replicaset" + "sharded" ] } ], diff --git a/test/csot/sessions-inherit-timeoutMS.json b/test/csot/sessions-inherit-timeoutMS.json index 8205c086b..13ea91c79 100644 --- a/test/csot/sessions-inherit-timeoutMS.json +++ b/test/csot/sessions-inherit-timeoutMS.json @@ -6,7 +6,7 @@ "minServerVersion": "4.4", "topologies": [ "replicaset", - "sharded-replicaset" + "sharded" ] } ], @@ -21,7 +21,7 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 50 + "timeoutMS": 500 }, "useMultipleMongoses": false, "observeEvents": [ @@ -78,7 +78,7 @@ "commitTransaction" ], "blockConnection": true, - "blockTimeMS": 60 + "blockTimeMS": 600 } } } @@ -165,7 +165,7 @@ "abortTransaction" ], "blockConnection": true, - "blockTimeMS": 60 + "blockTimeMS": 600 } } } @@ -249,7 +249,7 @@ "insert" ], "blockConnection": true, - "blockTimeMS": 60 + "blockTimeMS": 600 } } } @@ -302,6 +302,26 @@ "commandFailedEvent": { "commandName": "insert" } + }, + { + "commandStartedEvent": { + "commandName": "abortTransaction", + "databaseName": "admin", + "command": { + "abortTransaction": 1, + "maxTimeMS": { + "$$type": [ + "int", + "long" + ] + } + } + } + }, + { + "commandFailedEvent": { + "commandName": "abortTransaction" + } } ] } diff --git a/test/csot/sessions-override-operation-timeoutMS.json b/test/csot/sessions-override-operation-timeoutMS.json index ff26de29f..441c69832 100644 --- a/test/csot/sessions-override-operation-timeoutMS.json +++ b/test/csot/sessions-override-operation-timeoutMS.json @@ -6,7 +6,7 @@ "minServerVersion": "4.4", "topologies": [ "replicaset", - "sharded-replicaset" + "sharded" ] } ], @@ -75,7 +75,7 @@ "commitTransaction" ], "blockConnection": true, - "blockTimeMS": 60 + "blockTimeMS": 600 } } } @@ -98,7 +98,7 @@ "name": "commitTransaction", "object": "session", "arguments": { - "timeoutMS": 50 + "timeoutMS": 500 }, "expectError": { "isTimeoutError": true @@ -165,7 +165,7 @@ "abortTransaction" ], "blockConnection": true, - "blockTimeMS": 60 + "blockTimeMS": 600 } } } @@ -188,7 +188,7 @@ "name": "abortTransaction", "object": "session", "arguments": { - "timeoutMS": 50 + "timeoutMS": 500 } } ], @@ -252,7 +252,7 @@ "insert" ], "blockConnection": true, - "blockTimeMS": 60 + "blockTimeMS": 600 } } } @@ -261,7 +261,7 @@ "name": "withTransaction", "object": "session", "arguments": { - "timeoutMS": 50, + "timeoutMS": 500, "callback": [ { "name": "insertOne", @@ -306,6 +306,26 @@ "commandFailedEvent": { "commandName": "insert" } + }, + { + "commandStartedEvent": { + "commandName": "abortTransaction", + "databaseName": "admin", + "command": { + "abortTransaction": 1, + "maxTimeMS": { + "$$type": [ + "int", + "long" + ] + } + } + } + }, + { + "commandFailedEvent": { + "commandName": "abortTransaction" + } } ] } diff --git a/test/csot/sessions-override-timeoutMS.json b/test/csot/sessions-override-timeoutMS.json index 1d3b8932a..d90152e90 100644 --- a/test/csot/sessions-override-timeoutMS.json +++ b/test/csot/sessions-override-timeoutMS.json @@ -6,7 +6,7 @@ "minServerVersion": "4.4", "topologies": [ "replicaset", - "sharded-replicaset" + "sharded" ] } ], @@ -47,7 +47,7 @@ "id": "session", "client": "client", "sessionOptions": { - "defaultTimeoutMS": 50 + "defaultTimeoutMS": 500 } } } @@ -78,7 +78,7 @@ "commitTransaction" ], "blockConnection": true, - "blockTimeMS": 60 + "blockTimeMS": 600 } } } @@ -165,7 +165,7 @@ "abortTransaction" ], "blockConnection": true, - "blockTimeMS": 60 + "blockTimeMS": 600 } } } @@ -249,7 +249,7 @@ "insert" ], "blockConnection": true, - "blockTimeMS": 60 + "blockTimeMS": 600 } } } @@ -302,6 +302,26 @@ "commandFailedEvent": { "commandName": "insert" } + }, + { + "commandStartedEvent": { + "commandName": "abortTransaction", + "databaseName": "admin", + "command": { + "abortTransaction": 1, + "maxTimeMS": { + "$$type": [ + "int", + "long" + ] + } + } + } + }, + { + "commandFailedEvent": { + "commandName": "abortTransaction" + } } ] } diff --git a/test/csot/tailable-awaitData.json b/test/csot/tailable-awaitData.json index 6da85c778..535fb6924 100644 --- a/test/csot/tailable-awaitData.json +++ b/test/csot/tailable-awaitData.json @@ -17,7 +17,7 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 10 + "timeoutMS": 200 }, "useMultipleMongoses": false, "observeEvents": [ @@ -130,7 +130,7 @@ "find" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 300 } } } @@ -188,7 +188,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 150 } } } @@ -199,7 +199,7 @@ "arguments": { "filter": {}, "cursorType": "tailableAwait", - "timeoutMS": 20, + "timeoutMS": 250, "batchSize": 1 }, "saveResultAsEntity": "tailableCursor" @@ -272,7 +272,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 150 } } } @@ -283,7 +283,7 @@ "arguments": { "filter": {}, "cursorType": "tailableAwait", - "timeoutMS": 20, + "timeoutMS": 250, "batchSize": 1, "maxAwaitTimeMS": 1 }, @@ -354,7 +354,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 250 } } } diff --git a/test/csot/tailable-non-awaitData.json b/test/csot/tailable-non-awaitData.json index 34ee66096..e88230e4f 100644 --- a/test/csot/tailable-non-awaitData.json +++ b/test/csot/tailable-non-awaitData.json @@ -17,7 +17,7 @@ "client": { "id": "client", "uriOptions": { - "timeoutMS": 10 + "timeoutMS": 200 }, "useMultipleMongoses": false, "observeEvents": [ @@ -94,7 +94,7 @@ "find" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 250 } } } @@ -154,7 +154,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 150 } } } @@ -165,7 +165,7 @@ "arguments": { "filter": {}, "cursorType": "tailable", - "timeoutMS": 20, + "timeoutMS": 200, "batchSize": 1 }, "saveResultAsEntity": "tailableCursor" @@ -239,7 +239,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 15 + "blockTimeMS": 250 } } } diff --git a/test/discovery_and_monitoring/unified/hello-command-error.json b/test/discovery_and_monitoring/unified/hello-command-error.json index 9afea87e7..87958cb2c 100644 --- a/test/discovery_and_monitoring/unified/hello-command-error.json +++ b/test/discovery_and_monitoring/unified/hello-command-error.json @@ -3,7 +3,7 @@ "schemaVersion": "1.4", "runOnRequirements": [ { - "minServerVersion": "4.9", + "minServerVersion": "4.4.7", "serverless": "forbid", "topologies": [ "single", diff --git a/test/discovery_and_monitoring/unified/hello-network-error.json b/test/discovery_and_monitoring/unified/hello-network-error.json index 55373c90c..15ed2b605 100644 --- a/test/discovery_and_monitoring/unified/hello-network-error.json +++ b/test/discovery_and_monitoring/unified/hello-network-error.json @@ -3,7 +3,7 @@ "schemaVersion": "1.4", "runOnRequirements": [ { - "minServerVersion": "4.9", + "minServerVersion": "4.4.7", "serverless": "forbid", "topologies": [ "single", diff --git a/test/discovery_and_monitoring/unified/interruptInUse-pool-clear.json b/test/discovery_and_monitoring/unified/interruptInUse-pool-clear.json index a20d79030..d9329646d 100644 --- a/test/discovery_and_monitoring/unified/interruptInUse-pool-clear.json +++ b/test/discovery_and_monitoring/unified/interruptInUse-pool-clear.json @@ -3,7 +3,7 @@ "schemaVersion": "1.11", "runOnRequirements": [ { - "minServerVersion": "4.9", + "minServerVersion": "4.4", "serverless": "forbid", "topologies": [ "replicaset", diff --git a/test/discovery_and_monitoring/unified/minPoolSize-error.json b/test/discovery_and_monitoring/unified/minPoolSize-error.json index 7e294baf6..bd9e9fcde 100644 --- a/test/discovery_and_monitoring/unified/minPoolSize-error.json +++ b/test/discovery_and_monitoring/unified/minPoolSize-error.json @@ -3,7 +3,7 @@ "schemaVersion": "1.4", "runOnRequirements": [ { - "minServerVersion": "4.9", + "minServerVersion": "4.4.7", "serverless": "forbid", "topologies": [ "single" diff --git a/test/load_balancer/cursors.json b/test/load_balancer/cursors.json index e66c46c0c..27aaddd5b 100644 --- a/test/load_balancer/cursors.json +++ b/test/load_balancer/cursors.json @@ -1,6 +1,6 @@ { "description": "cursors are correctly pinned to connections for load-balanced clusters", - "schemaVersion": "1.3", + "schemaVersion": "1.4", "runOnRequirements": [ { "topologies": [ @@ -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/test/load_balancer/sdam-error-handling.json b/test/load_balancer/sdam-error-handling.json index 8760b723f..5892dcacd 100644 --- a/test/load_balancer/sdam-error-handling.json +++ b/test/load_balancer/sdam-error-handling.json @@ -1,6 +1,6 @@ { "description": "state change errors are correctly handled", - "schemaVersion": "1.3", + "schemaVersion": "1.4", "runOnRequirements": [ { "topologies": [ @@ -263,7 +263,7 @@ "description": "errors during the initial connection hello are ignored", "runOnRequirements": [ { - "minServerVersion": "4.9" + "minServerVersion": "4.4.7" } ], "operations": [ @@ -279,7 +279,6 @@ }, "data": { "failCommands": [ - "ismaster", "isMaster", "hello" ], diff --git a/test/load_balancer/transactions.json b/test/load_balancer/transactions.json index 8cf24f4ca..0dd04ee85 100644 --- a/test/load_balancer/transactions.json +++ b/test/load_balancer/transactions.json @@ -1,6 +1,6 @@ { "description": "transactions are correctly pinned to connections for load-balanced clusters", - "schemaVersion": "1.3", + "schemaVersion": "1.4", "runOnRequirements": [ { "topologies": [ diff --git a/test/test_pooling.py b/test/test_pooling.py index cd8a61735..31259d7b3 100644 --- a/test/test_pooling.py +++ b/test/test_pooling.py @@ -413,7 +413,7 @@ class TestPooling(_TestPoolingBase): # maxConnecting = unbounded: 30+ connections in ~0.140+ seconds print(len(pool.conns)) - @client_context.require_failCommand_fail_point + @client_context.require_failCommand_appName def test_csot_timeout_message(self): client = rs_or_single_client(appName="connectionTimeoutApp") self.addCleanup(client.close) @@ -438,7 +438,7 @@ class TestPooling(_TestPoolingBase): self.assertTrue("(configured timeouts: timeoutMS: 500.0ms" in str(error.exception)) - @client_context.require_failCommand_fail_point + @client_context.require_failCommand_appName def test_socket_timeout_message(self): client = rs_or_single_client(socketTimeoutMS=500, appName="connectionTimeoutApp") self.addCleanup(client.close) @@ -465,10 +465,7 @@ class TestPooling(_TestPoolingBase): in str(error.exception) ) - @client_context.require_failCommand_fail_point - @client_context.require_version_min( - 4, 9, 0 - ) # configureFailPoint does not allow failure on handshake before 4.9, fixed in SERVER-49336 + @client_context.require_failCommand_appName def test_connection_timeout_message(self): # Mock a connection creation failing due to timeout. mock_connection_timeout = { diff --git a/test/test_streaming_protocol.py b/test/test_streaming_protocol.py index 44e673822..9bca899a4 100644 --- a/test/test_streaming_protocol.py +++ b/test/test_streaming_protocol.py @@ -141,7 +141,6 @@ class TestStreamingProtocol(IntegrationTest): self.assertEqual(1, len(events)) self.assertGreater(events[0].new_description.round_trip_time, 0) - @client_context.require_version_min(4, 9, -1) @client_context.require_failCommand_appName def test_monitor_waits_after_server_check_error(self): # This test implements: