From 72c559921376400839eb66a6dbbdb1bbfaa1ef5f Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Tue, 8 Oct 2024 12:37:42 -0700 Subject: [PATCH 1/4] PYTHON-4729 Drop support for MongoDB 3.6 --- .evergreen/config.yml | 52 ++++++---------------------- README.md | 2 +- doc/changelog.rst | 15 ++++++++ doc/common-issues.rst | 6 ++-- doc/examples/authentication.rst | 5 ++- pymongo/asynchronous/collection.py | 5 --- pymongo/asynchronous/mongo_client.py | 5 ++- pymongo/synchronous/collection.py | 5 --- pymongo/synchronous/mongo_client.py | 5 ++- 9 files changed, 36 insertions(+), 64 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 7fb48c8054..a345e4f5b7 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1014,33 +1014,6 @@ tasks: TOPOLOGY: "server" - func: "run doctests" - - name: "test-3.6-standalone" - tags: ["3.6", "standalone"] - commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.6" - TOPOLOGY: "server" - - func: "run tests" - - - name: "test-3.6-replica_set" - tags: ["3.6", "replica_set"] - commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.6" - TOPOLOGY: "replica_set" - - func: "run tests" - - - name: "test-3.6-sharded_cluster" - tags: ["3.6", "sharded_cluster"] - commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.6" - TOPOLOGY: "sharded_cluster" - - func: "run tests" - - name: "test-4.0-standalone" tags: ["4.0", "standalone"] commands: @@ -2186,10 +2159,6 @@ axes: - id: mongodb-version display_name: "MongoDB" values: - - id: "3.6" - display_name: "MongoDB 3.6" - variables: - VERSION: "3.6" - id: "4.0" display_name: "MongoDB 4.0" variables: @@ -2490,7 +2459,6 @@ buildvariants: - ".4.4" - ".4.2" - ".4.0" - - ".3.6" - matrix_name: "test-macos-arm64" matrix_spec: @@ -2562,7 +2530,6 @@ buildvariants: - ".4.4" - ".4.2" - ".4.0" - - ".3.6" - matrix_name: "tests-pyopenssl" matrix_spec: @@ -2657,19 +2624,22 @@ buildvariants: display_name: "${compression} ${c-extensions} ${python-version} ${platform}" tasks: - "test-latest-standalone" + - "test-8.0-standalone" + - "test-7.0-standalone" + - "test-6.0-standalone" - "test-5.0-standalone" - "test-4.4-standalone" - "test-4.2-standalone" + - "test-4.0-standalone" rules: - # Server versions 3.6 and 4.0 support snappy and zlib. + # Server version 4.0 supports snappy and zlib but not zstd. - if: python-version: "*" c-extensions: "*" - compression: ["snappy", "zlib"] + compression: ["zstd"] then: - add_tasks: + remove_tasks: - "test-4.0-standalone" - - "test-3.6-standalone" - matrix_name: "tests-python-version-green-framework-rhel8" matrix_spec: @@ -2734,7 +2704,7 @@ buildvariants: matrix_spec: platform: rhel8 storage-engine: "*" - python-version: 3.9 + python-version: "3.9" display_name: "Storage ${storage-engine} ${python-version} ${platform}" rules: - if: @@ -2751,7 +2721,6 @@ buildvariants: - "test-4.4-standalone" - "test-4.2-standalone" - "test-4.0-standalone" - - "test-3.6-standalone" - if: # MongoDB 4.2 drops support for MMAPv1 platform: rhel8 @@ -2761,8 +2730,6 @@ buildvariants: add_tasks: - "test-4.0-standalone" - "test-4.0-replica_set" - - "test-3.6-standalone" - - "test-3.6-replica_set" # enableTestCommands=0 tests on RHEL 8.4 (x86_64) with Python 3.9. - matrix_name: "test-disableTestCommands" @@ -2881,6 +2848,9 @@ buildvariants: tasks: # Versioned API was introduced in MongoDB 4.7 - "test-latest-standalone" + - "test-8.0-standalone" + - "test-7.0-standalone" + - "test-6.0-standalone" - "test-5.0-standalone" - matrix_name: "ocsp-test" diff --git a/README.md b/README.md index 9b5aa33f78..f5e2cdf46d 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ a native Python driver for MongoDB. The `gridfs` package is a [gridfs](https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.rst/) implementation on top of `pymongo`. -PyMongo supports MongoDB 3.6, 4.0, 4.2, 4.4, 5.0, 6.0, 7.0, and 8.0. +PyMongo supports MongoDB 4.0, 4.2, 4.4, 5.0, 6.0, 7.0, and 8.0. ## Support / Feedback diff --git a/doc/changelog.rst b/doc/changelog.rst index a73a89a0ef..6a118f56ca 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -5,6 +5,21 @@ Changes in Version 4.11.0 ------------------------- .. warning:: PyMongo 4.11 drops support for Python 3.8: Python 3.9+ or PyPy 3.9+ is now required. +.. warning:: PyMongo 4.11 drops support for MongoDB 3.6. PyMongo now supports MongoDB 4.0+. + Driver support for MongoDB 3.6 reached end of life in April 2024. + +PyMongo 4.11 brings a number of changes including: + +- Dropped support for Python 3.8. +- Dropped support for MongoDB 3.6. + +Issues Resolved +............... + +See the `PyMongo 4.11 release notes in JIRA`_ for the list of resolved issues +in this release. + +.. _PyMongo 4.11 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=40784 Changes in Version 4.10.1 ------------------------- diff --git a/doc/common-issues.rst b/doc/common-issues.rst index 3d2d06a5a7..b300bac784 100644 --- a/doc/common-issues.rst +++ b/doc/common-issues.rst @@ -6,14 +6,14 @@ Also see the :ref:`TLSErrors` section. Server reports wire version X, PyMongo requires Y ------------------------------------------------- -When one attempts to connect to a <=3.4 version server, PyMongo will throw the following error:: +When one attempts to connect to a <=3.6 version server, PyMongo will throw the following error:: >>> client.admin.command('ping') ... - pymongo.errors.ConfigurationError: Server at localhost:27017 reports wire version 5, but this version of PyMongo requires at least 6 (MongoDB 3.6). + pymongo.errors.ConfigurationError: Server at localhost:27017 reports wire version 6, but this version of PyMongo requires at least 7 (MongoDB 4.0). This is caused by the driver being too new for the server it is being run against. -To resolve this issue either upgrade your database to version >= 3.6 or downgrade to PyMongo 3.x which supports MongoDB >= 2.6. +To resolve this issue either upgrade your database to version >= 4.0 or downgrade to an early version of PyMongo which supports MongoDB < 4.0. 'Cursor' object has no attribute '_Cursor__killed' diff --git a/doc/examples/authentication.rst b/doc/examples/authentication.rst index 24b3cff8df..6c89910f3c 100644 --- a/doc/examples/authentication.rst +++ b/doc/examples/authentication.rst @@ -97,9 +97,8 @@ the "MongoDB Challenge-Response" protocol:: Default Authentication Mechanism -------------------------------- -If no mechanism is specified, PyMongo automatically SCRAM-SHA-1 when connected -to MongoDB 3.6 and negotiates the mechanism to use (SCRAM-SHA-1 -or SCRAM-SHA-256) when connected to MongoDB 4.0+. +If no mechanism is specified, PyMongo automatically negotiates the mechanism to use (SCRAM-SHA-1 +or SCRAM-SHA-256) with the MongoDB server. Default Database and "authSource" --------------------------------- diff --git a/pymongo/asynchronous/collection.py b/pymongo/asynchronous/collection.py index 5abc41a7e0..4ddcbab4d2 100644 --- a/pymongo/asynchronous/collection.py +++ b/pymongo/asynchronous/collection.py @@ -1960,20 +1960,15 @@ async def _count_cmd( collation: Optional[Collation], ) -> int: """Internal count command helper.""" - # XXX: "ns missing" checks can be removed when we drop support for - # MongoDB 3.0, see SERVER-17051. res = await self._command( conn, cmd, read_preference=read_preference, - allowable_errors=["ns missing"], codec_options=self._write_response_codec_options, read_concern=self.read_concern, collation=collation, session=session, ) - if res.get("errmsg", "") == "ns missing": - return 0 return int(res["n"]) async def _aggregate_one_result( diff --git a/pymongo/asynchronous/mongo_client.py b/pymongo/asynchronous/mongo_client.py index 814c604562..bfae302dac 100644 --- a/pymongo/asynchronous/mongo_client.py +++ b/pymongo/asynchronous/mongo_client.py @@ -498,9 +498,8 @@ def __init__( - `authSource`: The database to authenticate on. Defaults to the database specified in the URI, if provided, or to "admin". - `authMechanism`: See :data:`~pymongo.auth.MECHANISMS` for options. - If no mechanism is specified, PyMongo automatically SCRAM-SHA-1 - when connected to MongoDB 3.6 and negotiates the mechanism to use - (SCRAM-SHA-1 or SCRAM-SHA-256) when connected to MongoDB 4.0+. + If no mechanism is specified, PyMongo automatically negotiates the + mechanism to use (SCRAM-SHA-1 or SCRAM-SHA-256) with the MongoDB server. - `authMechanismProperties`: Used to specify authentication mechanism specific options. To specify the service name for GSSAPI authentication pass authMechanismProperties='SERVICE_NAME: int: """Internal count command helper.""" - # XXX: "ns missing" checks can be removed when we drop support for - # MongoDB 3.0, see SERVER-17051. res = self._command( conn, cmd, read_preference=read_preference, - allowable_errors=["ns missing"], codec_options=self._write_response_codec_options, read_concern=self.read_concern, collation=collation, session=session, ) - if res.get("errmsg", "") == "ns missing": - return 0 return int(res["n"]) def _aggregate_one_result( diff --git a/pymongo/synchronous/mongo_client.py b/pymongo/synchronous/mongo_client.py index b2dff5b4ab..1351cb200f 100644 --- a/pymongo/synchronous/mongo_client.py +++ b/pymongo/synchronous/mongo_client.py @@ -496,9 +496,8 @@ def __init__( - `authSource`: The database to authenticate on. Defaults to the database specified in the URI, if provided, or to "admin". - `authMechanism`: See :data:`~pymongo.auth.MECHANISMS` for options. - If no mechanism is specified, PyMongo automatically SCRAM-SHA-1 - when connected to MongoDB 3.6 and negotiates the mechanism to use - (SCRAM-SHA-1 or SCRAM-SHA-256) when connected to MongoDB 4.0+. + If no mechanism is specified, PyMongo automatically negotiates the + mechanism to use (SCRAM-SHA-1 or SCRAM-SHA-256) with the MongoDB server. - `authMechanismProperties`: Used to specify authentication mechanism specific options. To specify the service name for GSSAPI authentication pass authMechanismProperties='SERVICE_NAME: Date: Tue, 8 Oct 2024 12:48:58 -0700 Subject: [PATCH 2/4] PYTHON-4729 Actually drop support --- pymongo/common.py | 4 ++-- test/test_topology.py | 28 ++++++++++++++-------------- test/utils_selection_tests.py | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pymongo/common.py b/pymongo/common.py index 126d0ee46e..87aa936f5d 100644 --- a/pymongo/common.py +++ b/pymongo/common.py @@ -66,8 +66,8 @@ MAX_WRITE_BATCH_SIZE = 1000 # What this version of PyMongo supports. -MIN_SUPPORTED_SERVER_VERSION = "3.6" -MIN_SUPPORTED_WIRE_VERSION = 6 +MIN_SUPPORTED_SERVER_VERSION = "4.0" +MIN_SUPPORTED_WIRE_VERSION = 7 # MongoDB 8.0 MAX_SUPPORTED_WIRE_VERSION = 25 diff --git a/test/test_topology.py b/test/test_topology.py index 3725bab936..01a3c57bcf 100644 --- a/test/test_topology.py +++ b/test/test_topology.py @@ -133,7 +133,7 @@ def test_direct_connection(self): HelloCompat.LEGACY_CMD: True, "hosts": ["a"], "setName": "rs", - "maxWireVersion": 6, + "maxWireVersion": 7, }, ), ( @@ -144,12 +144,12 @@ def test_direct_connection(self): "secondary": True, "hosts": ["a"], "setName": "rs", - "maxWireVersion": 6, + "maxWireVersion": 7, }, ), ( SERVER_TYPE.Mongos, - {"ok": 1, HelloCompat.LEGACY_CMD: True, "msg": "isdbgrid", "maxWireVersion": 6}, + {"ok": 1, HelloCompat.LEGACY_CMD: True, "msg": "isdbgrid", "maxWireVersion": 7}, ), ( SERVER_TYPE.RSArbiter, @@ -159,14 +159,14 @@ def test_direct_connection(self): "arbiterOnly": True, "hosts": ["a"], "setName": "rs", - "maxWireVersion": 6, + "maxWireVersion": 7, }, ), - (SERVER_TYPE.Standalone, {"ok": 1, HelloCompat.LEGACY_CMD: True, "maxWireVersion": 6}), + (SERVER_TYPE.Standalone, {"ok": 1, HelloCompat.LEGACY_CMD: True, "maxWireVersion": 7}), # A "slave" in a master-slave deployment. # This replication type was removed in MongoDB # 4.0. - (SERVER_TYPE.Standalone, {"ok": 1, HelloCompat.LEGACY_CMD: False, "maxWireVersion": 6}), + (SERVER_TYPE.Standalone, {"ok": 1, HelloCompat.LEGACY_CMD: False, "maxWireVersion": 7}), ]: t = create_mock_topology(direct_connection=True) @@ -213,7 +213,7 @@ def test_round_trip_time(self): class TestMonitor(Monitor): def _check_with_socket(self, *args, **kwargs): if available: - return (Hello({"ok": 1, "maxWireVersion": 6}), round_trip_time) + return (Hello({"ok": 1, "maxWireVersion": 7}), round_trip_time) else: raise AutoReconnect("mock monitor error") @@ -531,12 +531,12 @@ def test_wire_version(self): "setName": "rs", "hosts": ["a"], "minWireVersion": 1, - "maxWireVersion": 6, + "maxWireVersion": 7, }, ) self.assertEqual(server.description.min_wire_version, 1) - self.assertEqual(server.description.max_wire_version, 6) + self.assertEqual(server.description.max_wire_version, 7) t.select_servers(any_server_selector, _Op.TEST) # Incompatible. @@ -607,7 +607,7 @@ def write_batch_size(): HelloCompat.LEGACY_CMD: True, "setName": "rs", "hosts": ["a", "b"], - "maxWireVersion": 6, + "maxWireVersion": 7, "maxWriteBatchSize": 1, }, ) @@ -621,7 +621,7 @@ def write_batch_size(): "secondary": True, "setName": "rs", "hosts": ["a", "b"], - "maxWireVersion": 6, + "maxWireVersion": 7, "maxWriteBatchSize": 2, }, ) @@ -638,7 +638,7 @@ def write_batch_size(): HelloCompat.LEGACY_CMD: True, "setName": "rs", "hosts": ["a", "b"], - "maxWireVersion": 6, + "maxWireVersion": 7, "maxWriteBatchSize": 2, }, ) @@ -735,7 +735,7 @@ class TestMonitor(Monitor): def _check_with_socket(self, *args, **kwargs): hello_count[0] += 1 if hello_count[0] == 1: - return Hello({"ok": 1, "maxWireVersion": 6}), 0 + return Hello({"ok": 1, "maxWireVersion": 7}), 0 else: raise AutoReconnect("mock monitor error") @@ -757,7 +757,7 @@ class TestMonitor(Monitor): def _check_with_socket(self, *args, **kwargs): hello_count[0] += 1 if hello_count[0] in (1, 3): - return Hello({"ok": 1, "maxWireVersion": 6}), 0 + return Hello({"ok": 1, "maxWireVersion": 7}), 0 else: raise AutoReconnect(f"mock monitor error #{hello_count[0]}") diff --git a/test/utils_selection_tests.py b/test/utils_selection_tests.py index cef5780d21..f0eeac7314 100644 --- a/test/utils_selection_tests.py +++ b/test/utils_selection_tests.py @@ -85,7 +85,7 @@ def make_server_description(server, hosts): if field in server: hello_response[field] = server[field] - hello_response.setdefault("maxWireVersion", 6) + hello_response.setdefault("maxWireVersion", 7) # Sets _last_update_time to now. sd = ServerDescription( From 15c6482bbe0a50e87801d47c22ac26332ab60cff Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Tue, 8 Oct 2024 14:12:31 -0700 Subject: [PATCH 3/4] PYTHON-4729 Fix tests --- .../rs/null_election_id-pre-6.0.json | 2 +- test/mockupdb/test_auth_recovering_member.py | 4 +- test/mockupdb/test_cluster_time.py | 7 ++- test/mockupdb/test_cursor.py | 3 +- test/mockupdb/test_cursor_namespace.py | 5 +- test/mockupdb/test_getmore_sharded.py | 8 +++- test/mockupdb/test_handshake.py | 23 +++++++-- test/mockupdb/test_initial_ismaster.py | 10 ++-- test/mockupdb/test_list_indexes.py | 3 +- test/mockupdb/test_max_staleness.py | 6 ++- test/mockupdb/test_mixed_version_sharded.py | 2 - .../mockupdb/test_mongos_command_read_mode.py | 13 ++++- .../test_network_disconnect_primary.py | 9 +++- test/mockupdb/test_op_msg_read_preference.py | 9 ++-- test/mockupdb/test_query_read_pref_sharded.py | 8 +++- test/mockupdb/test_reset_and_request_check.py | 6 ++- test/mockupdb/test_slave_okay_rs.py | 10 +++- test/mockupdb/test_slave_okay_sharded.py | 7 ++- test/mockupdb/test_slave_okay_single.py | 3 +- test/test_discovery_and_monitoring.py | 7 ++- test/test_server_description.py | 4 +- test/test_topology.py | 48 ++++++++++++++----- test/utils_selection_tests.py | 4 +- 23 files changed, 144 insertions(+), 57 deletions(-) diff --git a/test/discovery_and_monitoring/rs/null_election_id-pre-6.0.json b/test/discovery_and_monitoring/rs/null_election_id-pre-6.0.json index 9e7ccc6e7f..7261fbfc2a 100644 --- a/test/discovery_and_monitoring/rs/null_election_id-pre-6.0.json +++ b/test/discovery_and_monitoring/rs/null_election_id-pre-6.0.json @@ -66,7 +66,7 @@ "$oid": "000000000000000000000002" }, "minWireVersion": 0, - "maxWireVersion": 21 + "maxWireVersion": 7 } ] ], diff --git a/test/mockupdb/test_auth_recovering_member.py b/test/mockupdb/test_auth_recovering_member.py index 6eadafaf38..046d8d4b0f 100644 --- a/test/mockupdb/test_auth_recovering_member.py +++ b/test/mockupdb/test_auth_recovering_member.py @@ -25,7 +25,7 @@ except ImportError: _HAVE_MOCKUPDB = False -from pymongo import MongoClient +from pymongo import common from pymongo.errors import ServerSelectionTimeoutError pytestmark = pytest.mark.mockupdb @@ -39,7 +39,7 @@ def test_auth_recovering_member(self): "ismaster", { "minWireVersion": 2, - "maxWireVersion": 6, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, "ismaster": False, "secondary": False, "setName": "rs", diff --git a/test/mockupdb/test_cluster_time.py b/test/mockupdb/test_cluster_time.py index 761415951b..ea879b7ea3 100644 --- a/test/mockupdb/test_cluster_time.py +++ b/test/mockupdb/test_cluster_time.py @@ -30,13 +30,16 @@ from bson import Timestamp from pymongo import DeleteMany, InsertOne, MongoClient, UpdateOne +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION from pymongo.errors import OperationFailure pytestmark = pytest.mark.mockupdb class TestClusterTime(PyMongoTestCase): - def cluster_time_conversation(self, callback, replies, max_wire_version=6): + def cluster_time_conversation( + self, callback, replies, max_wire_version=MIN_SUPPORTED_WIRE_VERSION + ): cluster_time = Timestamp(0, 0) server = MockupDB() @@ -110,7 +113,7 @@ def test_monitor(self): cluster_time = Timestamp(0, 0) reply = { "minWireVersion": 0, - "maxWireVersion": 6, + "maxWireVersion": MIN_SUPPORTED_WIRE_VERSION, "$clusterTime": {"clusterTime": cluster_time}, } diff --git a/test/mockupdb/test_cursor.py b/test/mockupdb/test_cursor.py index 2300297218..e61f220d5b 100644 --- a/test/mockupdb/test_cursor.py +++ b/test/mockupdb/test_cursor.py @@ -29,6 +29,7 @@ from bson.objectid import ObjectId +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION from pymongo.errors import OperationFailure pytestmark = pytest.mark.mockupdb @@ -74,7 +75,7 @@ def _test_fail_on_operation_failure_with_code(self, code): server = MockupDB() server.run() self.addCleanup(server.stop) - server.autoresponds("ismaster", maxWireVersion=6) + server.autoresponds("ismaster", maxWireVersion=MIN_SUPPORTED_WIRE_VERSION) client = self.simple_client(server.uri) diff --git a/test/mockupdb/test_cursor_namespace.py b/test/mockupdb/test_cursor_namespace.py index 455a3a923b..89b897f479 100644 --- a/test/mockupdb/test_cursor_namespace.py +++ b/test/mockupdb/test_cursor_namespace.py @@ -29,6 +29,7 @@ from pymongo import MongoClient +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION pytestmark = pytest.mark.mockupdb @@ -39,7 +40,7 @@ class TestCursorNamespace(PyMongoTestCase): @classmethod def setUpClass(cls): - cls.server = MockupDB(auto_ismaster={"maxWireVersion": 6}) + cls.server = MockupDB(auto_ismaster={"maxWireVersion": 7}) cls.server.run() cls.client = cls.unmanaged_simple_client(cls.server.uri) @@ -95,7 +96,7 @@ class TestKillCursorsNamespace(PyMongoTestCase): @classmethod def setUpClass(cls): - cls.server = MockupDB(auto_ismaster={"maxWireVersion": 6}) + cls.server = MockupDB(auto_ismaster={"maxWireVersion": MIN_SUPPORTED_WIRE_VERSION}) cls.server.run() cls.client = cls.unmanaged_simple_client(cls.server.uri) diff --git a/test/mockupdb/test_getmore_sharded.py b/test/mockupdb/test_getmore_sharded.py index 8ba291e4a7..d24c8aa10a 100644 --- a/test/mockupdb/test_getmore_sharded.py +++ b/test/mockupdb/test_getmore_sharded.py @@ -29,7 +29,7 @@ _HAVE_MOCKUPDB = False -from pymongo import MongoClient +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION pytestmark = pytest.mark.mockupdb @@ -43,7 +43,11 @@ def test_getmore_sharded(self): for server in servers: server.subscribe(q.put) server.autoresponds( - "ismaster", ismaster=True, msg="isdbgrid", minWireVersion=2, maxWireVersion=6 + "ismaster", + ismaster=True, + msg="isdbgrid", + minWireVersion=2, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) server.run() self.addCleanup(server.stop) diff --git a/test/mockupdb/test_handshake.py b/test/mockupdb/test_handshake.py index 8193714a86..7cc3017c8f 100644 --- a/test/mockupdb/test_handshake.py +++ b/test/mockupdb/test_handshake.py @@ -28,6 +28,7 @@ from bson.objectid import ObjectId from pymongo import MongoClient, has_c from pymongo import version as pymongo_version +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION from pymongo.errors import OperationFailure from pymongo.server_api import ServerApi, ServerApiVersion @@ -101,7 +102,12 @@ def test_client_handshake_data(self): hosts = [server.address_string for server in (primary, secondary)] primary_response = OpReply( - "ismaster", True, setName="rs", hosts=hosts, minWireVersion=2, maxWireVersion=6 + "ismaster", + True, + setName="rs", + hosts=hosts, + minWireVersion=2, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) error_response = OpReply(0, errmsg="Cache Reader No keys found for HMAC ...", code=211) @@ -112,7 +118,7 @@ def test_client_handshake_data(self): hosts=hosts, secondary=True, minWireVersion=2, - maxWireVersion=6, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) client = MongoClient( @@ -179,7 +185,9 @@ def test_client_handshake_saslSupportedMechs(self): server.run() self.addCleanup(server.stop) - primary_response = OpReply("ismaster", True, minWireVersion=2, maxWireVersion=6) + primary_response = OpReply( + "ismaster", True, minWireVersion=2, maxWireVersion=MIN_SUPPORTED_WIRE_VERSION + ) client = MongoClient(server.uri, username="username", password="password") self.addCleanup(client.close) @@ -213,7 +221,7 @@ def test_client_handshake_saslSupportedMechs(self): saslSupportedMechs=["SCRAM-SHA-256"], speculativeAuthenticate=auth, minWireVersion=2, - maxWireVersion=6, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) # Authentication should immediately fail with: # OperationFailure: Server returned an invalid nonce. @@ -240,7 +248,12 @@ def test_handshake_not_either(self): def test_handshake_max_wire(self): server = MockupDB() - primary_response = {"hello": 1, "ok": 1, "minWireVersion": 0, "maxWireVersion": 6} + primary_response = { + "hello": 1, + "ok": 1, + "minWireVersion": 0, + "maxWireVersion": MIN_SUPPORTED_WIRE_VERSION, + } self.found_auth_msg = False def responder(request): diff --git a/test/mockupdb/test_initial_ismaster.py b/test/mockupdb/test_initial_ismaster.py index 3eae98716b..a52930c742 100644 --- a/test/mockupdb/test_initial_ismaster.py +++ b/test/mockupdb/test_initial_ismaster.py @@ -27,7 +27,7 @@ _HAVE_MOCKUPDB = False -from pymongo import MongoClient +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION pytestmark = pytest.mark.mockupdb @@ -43,11 +43,15 @@ def test_initial_ismaster(self): # A single ismaster is enough for the client to be connected. self.assertFalse(client.nodes) - server.receives("ismaster").ok(ismaster=True, minWireVersion=2, maxWireVersion=6) + server.receives("ismaster").ok( + ismaster=True, minWireVersion=2, maxWireVersion=MIN_SUPPORTED_WIRE_VERSION + ) wait_until(lambda: client.nodes, "update nodes", timeout=1) # At least 10 seconds before next heartbeat. - server.receives("ismaster").ok(ismaster=True, minWireVersion=2, maxWireVersion=6) + server.receives("ismaster").ok( + ismaster=True, minWireVersion=2, maxWireVersion=MIN_SUPPORTED_WIRE_VERSION + ) self.assertGreaterEqual(time.time() - start, 10) diff --git a/test/mockupdb/test_list_indexes.py b/test/mockupdb/test_list_indexes.py index ff3363664b..71cad43aa2 100644 --- a/test/mockupdb/test_list_indexes.py +++ b/test/mockupdb/test_list_indexes.py @@ -29,13 +29,14 @@ from bson import SON +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION pytestmark = pytest.mark.mockupdb class TestListIndexes(PyMongoTestCase): def test_list_indexes_command(self): - server = MockupDB(auto_ismaster={"maxWireVersion": 6}) + server = MockupDB(auto_ismaster={"maxWireVersion": MIN_SUPPORTED_WIRE_VERSION}) server.run() self.addCleanup(server.stop) client = self.simple_client(server.uri) diff --git a/test/mockupdb/test_max_staleness.py b/test/mockupdb/test_max_staleness.py index 7275aaf44b..7168bd2954 100644 --- a/test/mockupdb/test_max_staleness.py +++ b/test/mockupdb/test_max_staleness.py @@ -26,7 +26,7 @@ _HAVE_MOCKUPDB = False -from pymongo import MongoClient +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION pytestmark = pytest.mark.mockupdb @@ -34,7 +34,9 @@ class TestMaxStalenessMongos(PyMongoTestCase): def test_mongos(self): mongos = MockupDB() - mongos.autoresponds("ismaster", maxWireVersion=6, ismaster=True, msg="isdbgrid") + mongos.autoresponds( + "ismaster", maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ismaster=True, msg="isdbgrid" + ) mongos.run() self.addCleanup(mongos.stop) diff --git a/test/mockupdb/test_mixed_version_sharded.py b/test/mockupdb/test_mixed_version_sharded.py index 99d428b5d9..adbe61204b 100644 --- a/test/mockupdb/test_mixed_version_sharded.py +++ b/test/mockupdb/test_mixed_version_sharded.py @@ -31,8 +31,6 @@ from operations import upgrades # type: ignore[import] -from pymongo import MongoClient - pytestmark = pytest.mark.mockupdb diff --git a/test/mockupdb/test_mongos_command_read_mode.py b/test/mockupdb/test_mongos_command_read_mode.py index 7265c97020..61744e184d 100644 --- a/test/mockupdb/test_mongos_command_read_mode.py +++ b/test/mockupdb/test_mongos_command_read_mode.py @@ -28,6 +28,7 @@ from operations import operations # type: ignore[import] from pymongo import MongoClient, ReadPreference +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION from pymongo.read_preferences import ( _MONGOS_MODES, make_read_preference, @@ -41,7 +42,11 @@ class TestMongosCommandReadMode(unittest.TestCase): def test_aggregate(self): server = MockupDB() server.autoresponds( - "ismaster", ismaster=True, msg="isdbgrid", minWireVersion=2, maxWireVersion=6 + "ismaster", + ismaster=True, + msg="isdbgrid", + minWireVersion=2, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) self.addCleanup(server.stop) server.run() @@ -76,7 +81,11 @@ def test(self): self.addCleanup(server.stop) server.run() server.autoresponds( - "ismaster", ismaster=True, msg="isdbgrid", minWireVersion=2, maxWireVersion=6 + "ismaster", + ismaster=True, + msg="isdbgrid", + minWireVersion=2, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) pref = make_read_preference(read_pref_mode_from_name(mode), tag_sets=None) diff --git a/test/mockupdb/test_network_disconnect_primary.py b/test/mockupdb/test_network_disconnect_primary.py index 32e0471e26..b5ccd5276f 100644 --- a/test/mockupdb/test_network_disconnect_primary.py +++ b/test/mockupdb/test_network_disconnect_primary.py @@ -26,6 +26,7 @@ from pymongo import MongoClient +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION from pymongo.errors import ConnectionFailure from pymongo.topology_description import TOPOLOGY_TYPE @@ -44,7 +45,11 @@ def test_network_disconnect_primary(self): hosts = [server.address_string for server in (primary, secondary)] primary_response = OpReply( - ismaster=True, setName="rs", hosts=hosts, minWireVersion=2, maxWireVersion=6 + ismaster=True, + setName="rs", + hosts=hosts, + minWireVersion=2, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) primary.autoresponds("ismaster", primary_response) secondary.autoresponds( @@ -54,7 +59,7 @@ def test_network_disconnect_primary(self): setName="rs", hosts=hosts, minWireVersion=2, - maxWireVersion=6, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) client = MongoClient(primary.uri, replicaSet="rs") diff --git a/test/mockupdb/test_op_msg_read_preference.py b/test/mockupdb/test_op_msg_read_preference.py index 86293d0c09..4cf82c760e 100644 --- a/test/mockupdb/test_op_msg_read_preference.py +++ b/test/mockupdb/test_op_msg_read_preference.py @@ -30,7 +30,8 @@ from operations import operations # type: ignore[import] -from pymongo import MongoClient, ReadPreference +from pymongo import ReadPreference +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION from pymongo.read_preferences import ( _MONGOS_MODES, make_read_preference, @@ -66,7 +67,7 @@ def setUpClass(cls): "ismaster": True, "msg": "isdbgrid", # Mongos. "minWireVersion": 2, - "maxWireVersion": 6, + "maxWireVersion": MIN_SUPPORTED_WIRE_VERSION, } cls.primary = MockupDB(auto_ismaster=auto_ismaster) cls.primary.run() @@ -93,7 +94,7 @@ def setUpClass(cls): "setName": "rs", "hosts": hosts, "minWireVersion": 2, - "maxWireVersion": 6, + "maxWireVersion": MIN_SUPPORTED_WIRE_VERSION, } cls.primary.autoresponds(CommandBase("ismaster"), primary_ismaster) secondary_ismaster = copy.copy(primary_ismaster) @@ -134,7 +135,7 @@ def setUpClass(cls): auto_ismaster = { "ismaster": True, "minWireVersion": 2, - "maxWireVersion": 6, + "maxWireVersion": MIN_SUPPORTED_WIRE_VERSION, } cls.primary = MockupDB(auto_ismaster=auto_ismaster) cls.primary.run() diff --git a/test/mockupdb/test_query_read_pref_sharded.py b/test/mockupdb/test_query_read_pref_sharded.py index 676e71b711..2fae46be76 100644 --- a/test/mockupdb/test_query_read_pref_sharded.py +++ b/test/mockupdb/test_query_read_pref_sharded.py @@ -29,7 +29,7 @@ from bson import SON -from pymongo import MongoClient +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION from pymongo.read_preferences import ( Nearest, Primary, @@ -46,7 +46,11 @@ def test_query_and_read_mode_sharded_op_msg(self): """Test OP_MSG sends non-primary $readPreference and never $query.""" server = MockupDB() server.autoresponds( - "ismaster", ismaster=True, msg="isdbgrid", minWireVersion=2, maxWireVersion=6 + "ismaster", + ismaster=True, + msg="isdbgrid", + minWireVersion=2, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) server.run() self.addCleanup(server.stop) diff --git a/test/mockupdb/test_reset_and_request_check.py b/test/mockupdb/test_reset_and_request_check.py index dd6ad46b1e..b438afe894 100644 --- a/test/mockupdb/test_reset_and_request_check.py +++ b/test/mockupdb/test_reset_and_request_check.py @@ -30,7 +30,7 @@ from operations import operations # type: ignore[import] -from pymongo import MongoClient +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION from pymongo.errors import ConnectionFailure from pymongo.operations import _Op from pymongo.server_type import SERVER_TYPE @@ -50,7 +50,9 @@ def setup_server(self): def responder(request): self.ismaster_time = time.time() - return request.ok(ismaster=True, minWireVersion=2, maxWireVersion=6) + return request.ok( + ismaster=True, minWireVersion=2, maxWireVersion=MIN_SUPPORTED_WIRE_VERSION + ) self.server.autoresponds("ismaster", responder) self.server.run() diff --git a/test/mockupdb/test_slave_okay_rs.py b/test/mockupdb/test_slave_okay_rs.py index a60531a716..728e4e2ce0 100644 --- a/test/mockupdb/test_slave_okay_rs.py +++ b/test/mockupdb/test_slave_okay_rs.py @@ -32,6 +32,7 @@ from operations import operations # type: ignore[import] from pymongo import MongoClient +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION pytestmark = pytest.mark.mockupdb @@ -45,7 +46,12 @@ def setup_server(self): hosts = [server.address_string for server in (self.primary, self.secondary)] self.primary.autoresponds( - "ismaster", ismaster=True, setName="rs", hosts=hosts, minWireVersion=2, maxWireVersion=6 + "ismaster", + ismaster=True, + setName="rs", + hosts=hosts, + minWireVersion=2, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) self.secondary.autoresponds( "ismaster", @@ -54,7 +60,7 @@ def setup_server(self): setName="rs", hosts=hosts, minWireVersion=2, - maxWireVersion=6, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, ) diff --git a/test/mockupdb/test_slave_okay_sharded.py b/test/mockupdb/test_slave_okay_sharded.py index 252fe772b9..6efbff6583 100644 --- a/test/mockupdb/test_slave_okay_sharded.py +++ b/test/mockupdb/test_slave_okay_sharded.py @@ -36,6 +36,7 @@ from operations import operations # type: ignore[import] from pymongo import MongoClient +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION from pymongo.read_preferences import make_read_preference, read_pref_mode_from_name pytestmark = pytest.mark.mockupdb @@ -52,7 +53,11 @@ def setup_server(self): server.run() self.addCleanup(server.stop) server.autoresponds( - "ismaster", minWireVersion=2, maxWireVersion=6, ismaster=True, msg="isdbgrid" + "ismaster", + minWireVersion=2, + maxWireVersion=MIN_SUPPORTED_WIRE_VERSION, + ismaster=True, + msg="isdbgrid", ) self.mongoses_uri = f"mongodb://{self.mongos1.address_string},{self.mongos2.address_string}" diff --git a/test/mockupdb/test_slave_okay_single.py b/test/mockupdb/test_slave_okay_single.py index 0f562e569a..88cb1a48a5 100644 --- a/test/mockupdb/test_slave_okay_single.py +++ b/test/mockupdb/test_slave_okay_single.py @@ -35,6 +35,7 @@ from operations import operations # type: ignore[import] from pymongo import MongoClient +from pymongo.common import MIN_SUPPORTED_WIRE_VERSION from pymongo.read_preferences import make_read_preference, read_pref_mode_from_name from pymongo.topology_description import TOPOLOGY_TYPE @@ -57,7 +58,7 @@ def create_slave_ok_single_test(mode, server_type, ismaster, operation): def test(self): ismaster_with_version = ismaster.copy() ismaster_with_version["minWireVersion"] = 2 - ismaster_with_version["maxWireVersion"] = 6 + ismaster_with_version["maxWireVersion"] = MIN_SUPPORTED_WIRE_VERSION self.server.autoresponds("ismaster", **ismaster_with_version) self.assertIn( operation.op_type, ("always-use-secondary", "may-use-secondary", "must-use-primary") diff --git a/test/test_discovery_and_monitoring.py b/test/test_discovery_and_monitoring.py index 3554619f12..ce7a52f1a0 100644 --- a/test/test_discovery_and_monitoring.py +++ b/test/test_discovery_and_monitoring.py @@ -250,7 +250,12 @@ def send_cluster_time(time, inc, should_update): got_hello( t, ("host", 27017), - {"ok": 1, "minWireVersion": 0, "maxWireVersion": 6, "$clusterTime": new}, + { + "ok": 1, + "minWireVersion": 0, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, + "$clusterTime": new, + }, ) actual = t.max_cluster_time() diff --git a/test/test_server_description.py b/test/test_server_description.py index ee05e95cf8..fe7a5f7119 100644 --- a/test/test_server_description.py +++ b/test/test_server_description.py @@ -118,7 +118,7 @@ def test_fields(self): "maxBsonObjectSize": 2, "maxWriteBatchSize": 3, "minWireVersion": 4, - "maxWireVersion": 5, + "maxWireVersion": 25, "setName": "rs", } ) @@ -130,7 +130,7 @@ def test_fields(self): self.assertEqual(2, s.max_bson_size) self.assertEqual(3, s.max_write_batch_size) self.assertEqual(4, s.min_wire_version) - self.assertEqual(5, s.max_wire_version) + self.assertEqual(25, s.max_wire_version) def test_default_max_message_size(self): s = parse_hello_response({"ok": 1, HelloCompat.LEGACY_CMD: True, "maxBsonObjectSize": 2}) diff --git a/test/test_topology.py b/test/test_topology.py index 01a3c57bcf..86aa87c2cc 100644 --- a/test/test_topology.py +++ b/test/test_topology.py @@ -133,7 +133,7 @@ def test_direct_connection(self): HelloCompat.LEGACY_CMD: True, "hosts": ["a"], "setName": "rs", - "maxWireVersion": 7, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, }, ), ( @@ -144,12 +144,17 @@ def test_direct_connection(self): "secondary": True, "hosts": ["a"], "setName": "rs", - "maxWireVersion": 7, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, }, ), ( SERVER_TYPE.Mongos, - {"ok": 1, HelloCompat.LEGACY_CMD: True, "msg": "isdbgrid", "maxWireVersion": 7}, + { + "ok": 1, + HelloCompat.LEGACY_CMD: True, + "msg": "isdbgrid", + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, + }, ), ( SERVER_TYPE.RSArbiter, @@ -159,14 +164,28 @@ def test_direct_connection(self): "arbiterOnly": True, "hosts": ["a"], "setName": "rs", - "maxWireVersion": 7, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, + }, + ), + ( + SERVER_TYPE.Standalone, + { + "ok": 1, + HelloCompat.LEGACY_CMD: True, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, }, ), - (SERVER_TYPE.Standalone, {"ok": 1, HelloCompat.LEGACY_CMD: True, "maxWireVersion": 7}), # A "slave" in a master-slave deployment. # This replication type was removed in MongoDB # 4.0. - (SERVER_TYPE.Standalone, {"ok": 1, HelloCompat.LEGACY_CMD: False, "maxWireVersion": 7}), + ( + SERVER_TYPE.Standalone, + { + "ok": 1, + HelloCompat.LEGACY_CMD: False, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, + }, + ), ]: t = create_mock_topology(direct_connection=True) @@ -213,7 +232,10 @@ def test_round_trip_time(self): class TestMonitor(Monitor): def _check_with_socket(self, *args, **kwargs): if available: - return (Hello({"ok": 1, "maxWireVersion": 7}), round_trip_time) + return ( + Hello({"ok": 1, "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION}), + round_trip_time, + ) else: raise AutoReconnect("mock monitor error") @@ -531,7 +553,7 @@ def test_wire_version(self): "setName": "rs", "hosts": ["a"], "minWireVersion": 1, - "maxWireVersion": 7, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, }, ) @@ -607,7 +629,7 @@ def write_batch_size(): HelloCompat.LEGACY_CMD: True, "setName": "rs", "hosts": ["a", "b"], - "maxWireVersion": 7, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, "maxWriteBatchSize": 1, }, ) @@ -621,7 +643,7 @@ def write_batch_size(): "secondary": True, "setName": "rs", "hosts": ["a", "b"], - "maxWireVersion": 7, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, "maxWriteBatchSize": 2, }, ) @@ -638,7 +660,7 @@ def write_batch_size(): HelloCompat.LEGACY_CMD: True, "setName": "rs", "hosts": ["a", "b"], - "maxWireVersion": 7, + "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION, "maxWriteBatchSize": 2, }, ) @@ -735,7 +757,7 @@ class TestMonitor(Monitor): def _check_with_socket(self, *args, **kwargs): hello_count[0] += 1 if hello_count[0] == 1: - return Hello({"ok": 1, "maxWireVersion": 7}), 0 + return Hello({"ok": 1, "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION}), 0 else: raise AutoReconnect("mock monitor error") @@ -757,7 +779,7 @@ class TestMonitor(Monitor): def _check_with_socket(self, *args, **kwargs): hello_count[0] += 1 if hello_count[0] in (1, 3): - return Hello({"ok": 1, "maxWireVersion": 7}), 0 + return Hello({"ok": 1, "maxWireVersion": common.MIN_SUPPORTED_WIRE_VERSION}), 0 else: raise AutoReconnect(f"mock monitor error #{hello_count[0]}") diff --git a/test/utils_selection_tests.py b/test/utils_selection_tests.py index f0eeac7314..2d21888e27 100644 --- a/test/utils_selection_tests.py +++ b/test/utils_selection_tests.py @@ -26,7 +26,7 @@ from test.utils import MockPool, parse_read_preference from bson import json_util -from pymongo.common import HEARTBEAT_FREQUENCY, clean_node +from pymongo.common import HEARTBEAT_FREQUENCY, MIN_SUPPORTED_WIRE_VERSION, clean_node from pymongo.errors import AutoReconnect, ConfigurationError from pymongo.hello import Hello, HelloCompat from pymongo.operations import _Op @@ -85,7 +85,7 @@ def make_server_description(server, hosts): if field in server: hello_response[field] = server[field] - hello_response.setdefault("maxWireVersion", 7) + hello_response.setdefault("maxWireVersion", MIN_SUPPORTED_WIRE_VERSION) # Sets _last_update_time to now. sd = ServerDescription( From b303f93ebbb1048b9098b3902e2e2e618a8244d3 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Tue, 8 Oct 2024 14:23:49 -0700 Subject: [PATCH 4/4] PYTHON-4729 Fix one more test --- test/asynchronous/test_client.py | 8 ++++---- test/test_client.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/asynchronous/test_client.py b/test/asynchronous/test_client.py index 2052d1cd7f..faa23348c9 100644 --- a/test/asynchronous/test_client.py +++ b/test/asynchronous/test_client.py @@ -99,7 +99,7 @@ from pymongo.asynchronous.settings import TOPOLOGY_TYPE from pymongo.asynchronous.topology import _ErrorContext from pymongo.client_options import ClientOptions -from pymongo.common import _UUID_REPRESENTATIONS, CONNECT_TIMEOUT, has_c +from pymongo.common import _UUID_REPRESENTATIONS, CONNECT_TIMEOUT, MIN_SUPPORTED_WIRE_VERSION, has_c from pymongo.compression_support import _have_snappy, _have_zstd from pymongo.driver_info import DriverInfo from pymongo.errors import ( @@ -2455,8 +2455,8 @@ async def _test_network_error(self, operation_callback): self.addAsyncCleanup(c.close) # Set host-specific information so we can test whether it is reset. - c.set_wire_version_range("a:1", 2, 6) - c.set_wire_version_range("b:2", 2, 7) + c.set_wire_version_range("a:1", 2, MIN_SUPPORTED_WIRE_VERSION) + c.set_wire_version_range("b:2", 2, MIN_SUPPORTED_WIRE_VERSION + 1) await (await c._get_topology()).select_servers(writable_server_selector, _Op.TEST) wait_until(lambda: len(c.nodes) == 2, "connect") @@ -2480,7 +2480,7 @@ async def _test_network_error(self, operation_callback): sd_b = server_b.description self.assertEqual(SERVER_TYPE.RSSecondary, sd_b.server_type) self.assertEqual(2, sd_b.min_wire_version) - self.assertEqual(7, sd_b.max_wire_version) + self.assertEqual(MIN_SUPPORTED_WIRE_VERSION + 1, sd_b.max_wire_version) async def test_network_error_on_query(self): async def callback(client): diff --git a/test/test_client.py b/test/test_client.py index 936c38b8c6..be1994dd93 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -87,7 +87,7 @@ from bson.tz_util import utc from pymongo import event_loggers, message, monitoring from pymongo.client_options import ClientOptions -from pymongo.common import _UUID_REPRESENTATIONS, CONNECT_TIMEOUT, has_c +from pymongo.common import _UUID_REPRESENTATIONS, CONNECT_TIMEOUT, MIN_SUPPORTED_WIRE_VERSION, has_c from pymongo.compression_support import _have_snappy, _have_zstd from pymongo.driver_info import DriverInfo from pymongo.errors import ( @@ -2411,8 +2411,8 @@ def _test_network_error(self, operation_callback): self.addCleanup(c.close) # Set host-specific information so we can test whether it is reset. - c.set_wire_version_range("a:1", 2, 6) - c.set_wire_version_range("b:2", 2, 7) + c.set_wire_version_range("a:1", 2, MIN_SUPPORTED_WIRE_VERSION) + c.set_wire_version_range("b:2", 2, MIN_SUPPORTED_WIRE_VERSION + 1) (c._get_topology()).select_servers(writable_server_selector, _Op.TEST) wait_until(lambda: len(c.nodes) == 2, "connect") @@ -2436,7 +2436,7 @@ def _test_network_error(self, operation_callback): sd_b = server_b.description self.assertEqual(SERVER_TYPE.RSSecondary, sd_b.server_type) self.assertEqual(2, sd_b.min_wire_version) - self.assertEqual(7, sd_b.max_wire_version) + self.assertEqual(MIN_SUPPORTED_WIRE_VERSION + 1, sd_b.max_wire_version) def test_network_error_on_query(self): def callback(client):