From 44454a2a1fcf364ddff327a8da2fdd899bf041af Mon Sep 17 00:00:00 2001 From: julius Date: Mon, 2 May 2022 16:58:52 -0700 Subject: [PATCH 1/9] initial commit --- doc/changelog.rst | 13 ++++++++----- doc/migrate-to-pymongo4.rst | 24 ++++++++++++++++++++++++ pymongo/mongo_client.py | 4 ++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index 0fe2300120..abe2640989 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -89,6 +89,14 @@ Changes in Version 4.0 .. warning:: PyMongo 4.0 drops support for MongoDB 2.6, 3.0, 3.2, and 3.4. +.. warning:: PyMongo 4.0 changes the default value of the ``directConnection`` URI option and + keyword argument to :class:`~pymongo.mongo_client.MongoClient` + to ``False`` instead of ``None``, allowing for the automatic + discovery of replica sets. This means that if you + want a direct connection to a single server you must pass + ``directConnection=True`` as a URI option or keyword argument. + See the :doc:`migrate-to-pymongo4` for more details. + PyMongo 4.0 brings a number of improvements as well as some backward breaking changes. For example, all APIs deprecated in PyMongo 3.X have been removed. Be sure to read the changes listed below and the :doc:`migrate-to-pymongo4` @@ -217,11 +225,6 @@ Breaking Changes in 4.0 - ``tz_aware``, an argument for :class:`~bson.json_util.JSONOptions`, now defaults to ``False`` instead of ``True``. ``json_util.loads`` now decodes datetime as naive by default. -- ``directConnection`` URI option and keyword argument to :class:`~pymongo.mongo_client.MongoClient` - defaults to ``False`` instead of ``None``, allowing for the automatic - discovery of replica sets. This means that if you - want a direct connection to a single server you must pass - ``directConnection=True`` as a URI option or keyword argument. - The ``hint`` option is now required when using ``min`` or ``max`` queries with :meth:`~pymongo.collection.Collection.find`. - ``name`` is now a required argument for the :class:`pymongo.driver_info.DriverInfo` class. diff --git a/doc/migrate-to-pymongo4.rst b/doc/migrate-to-pymongo4.rst index 5f75ed1760..7ee844ed88 100644 --- a/doc/migrate-to-pymongo4.rst +++ b/doc/migrate-to-pymongo4.rst @@ -74,6 +74,30 @@ allowing for the automatic discovery of replica sets. This means that if you want a direct connection to a single server you must pass ``directConnection=True`` as a URI option or keyword argument. +Here are some example errors that you might see + +.. code-block:: + + _select_servers_loop + raise ServerSelectionTimeoutError( + pymongo.errors.ServerSelectionTimeoutError: mongo_node2: [Errno 8] nodename nor servname + provided, or not known,mongo_node1:27017 + +.. code-block:: + + ServerSelectionTimeoutError: No servers match selector "Primary()", Timeout: 30s, + Topology Description: ... + + +Additionally, the "isWritablePrimary" attribute of a hello command sent back by the server will +always be True if ``directConnection=False``:: + + doc = client.admin.command('hello') + result = doc['isWritablePrimary'] + print(result) + >> True + + The waitQueueMultiple parameter is removed .......................................... diff --git a/pymongo/mongo_client.py b/pymongo/mongo_client.py index 5c7e7cb176..b8d780b48a 100644 --- a/pymongo/mongo_client.py +++ b/pymongo/mongo_client.py @@ -137,6 +137,10 @@ def __init__( ) -> None: """Client for a MongoDB instance, a replica set, or a set of mongoses. + .. warning:: Starting in PyMongo 4.0, ``directConnection`` now has a default value of + False instead of None (which is the same as specifying ``directionConnection=True``). + Please see the :ref:`pymongo4-migration-guide` for more details. + The client object is thread-safe and has connection-pooling built in. If an operation fails because of a network error, :class:`~pymongo.errors.ConnectionFailure` is raised and the client From 55e4a7dcc4cd1013d6cd0b55598c29d026ed96c1 Mon Sep 17 00:00:00 2001 From: julius Date: Mon, 2 May 2022 17:42:26 -0700 Subject: [PATCH 2/9] link to direct connection subsection, fix wording, fix error examples --- doc/changelog.rst | 8 +++++++- doc/migrate-to-pymongo4.rst | 12 +++++++----- pymongo/mongo_client.py | 5 +++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index abe2640989..1fd5ea8dd3 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -95,7 +95,8 @@ Changes in Version 4.0 discovery of replica sets. This means that if you want a direct connection to a single server you must pass ``directConnection=True`` as a URI option or keyword argument. - See the :doc:`migrate-to-pymongo4` for more details. + For more details, see the relevant section of the PyMongo 4.x migration + guide: :ref:`pymongo4-migration-direct-connection`. PyMongo 4.0 brings a number of improvements as well as some backward breaking changes. For example, all APIs deprecated in PyMongo 3.X have been removed. @@ -225,6 +226,11 @@ Breaking Changes in 4.0 - ``tz_aware``, an argument for :class:`~bson.json_util.JSONOptions`, now defaults to ``False`` instead of ``True``. ``json_util.loads`` now decodes datetime as naive by default. +- ``directConnection`` URI option and keyword argument to :class:`~pymongo.mongo_client.MongoClient` + defaults to ``False`` instead of ``None``, allowing for the automatic + discovery of replica sets. This means that if you + want a direct connection to a single server you must pass + ``directConnection=True`` as a URI option or keyword argument. - The ``hint`` option is now required when using ``min`` or ``max`` queries with :meth:`~pymongo.collection.Collection.find`. - ``name`` is now a required argument for the :class:`pymongo.driver_info.DriverInfo` class. diff --git a/doc/migrate-to-pymongo4.rst b/doc/migrate-to-pymongo4.rst index 7ee844ed88..60d633e6c5 100644 --- a/doc/migrate-to-pymongo4.rst +++ b/doc/migrate-to-pymongo4.rst @@ -65,6 +65,8 @@ get the same behavior. MongoClient ----------- +.. _pymongo4-migration-direct-connection: + ``directConnection`` defaults to False ...................................... @@ -74,7 +76,9 @@ allowing for the automatic discovery of replica sets. This means that if you want a direct connection to a single server you must pass ``directConnection=True`` as a URI option or keyword argument. -Here are some example errors that you might see +If you see any :exc:`~pymongo.errors.ServerSelectionTimeoutError`'s after upgrading from PyMongo 3 to 4.x, you likely +need to add ``directConnection=True`` when creating the client. +Here are some example errors: .. code-block:: @@ -92,10 +96,8 @@ Here are some example errors that you might see Additionally, the "isWritablePrimary" attribute of a hello command sent back by the server will always be True if ``directConnection=False``:: - doc = client.admin.command('hello') - result = doc['isWritablePrimary'] - print(result) - >> True + >>> client.admin.command('hello')['isWritablePrimary'] + True The waitQueueMultiple parameter is removed diff --git a/pymongo/mongo_client.py b/pymongo/mongo_client.py index b8d780b48a..e4d457b864 100644 --- a/pymongo/mongo_client.py +++ b/pymongo/mongo_client.py @@ -138,8 +138,9 @@ def __init__( """Client for a MongoDB instance, a replica set, or a set of mongoses. .. warning:: Starting in PyMongo 4.0, ``directConnection`` now has a default value of - False instead of None (which is the same as specifying ``directionConnection=True``). - Please see the :ref:`pymongo4-migration-guide` for more details. + False instead of None. + For more details, see the relevant section of the PyMongo 4.x migration guide: + :ref:`pymongo4-migration-direct-connection`. The client object is thread-safe and has connection-pooling built in. If an operation fails because of a network error, From 3e15310438b833c6cf771d82574cf2b5e2be120d Mon Sep 17 00:00:00 2001 From: julius Date: Mon, 2 May 2022 18:05:48 -0700 Subject: [PATCH 3/9] fixed indentation --- pymongo/mongo_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymongo/mongo_client.py b/pymongo/mongo_client.py index e4d457b864..6601c18aca 100644 --- a/pymongo/mongo_client.py +++ b/pymongo/mongo_client.py @@ -139,8 +139,8 @@ def __init__( .. warning:: Starting in PyMongo 4.0, ``directConnection`` now has a default value of False instead of None. - For more details, see the relevant section of the PyMongo 4.x migration guide: - :ref:`pymongo4-migration-direct-connection`. + For more details, see the relevant section of the PyMongo 4.x migration guide: + :ref:`pymongo4-migration-direct-connection`. The client object is thread-safe and has connection-pooling built in. If an operation fails because of a network error, From 0f41812a81e38a2006d1804c40514070830176de Mon Sep 17 00:00:00 2001 From: julius Date: Mon, 2 May 2022 19:01:13 -0700 Subject: [PATCH 4/9] remove two lines --- doc/migrate-to-pymongo4.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/migrate-to-pymongo4.rst b/doc/migrate-to-pymongo4.rst index 60d633e6c5..d70d7b8a2c 100644 --- a/doc/migrate-to-pymongo4.rst +++ b/doc/migrate-to-pymongo4.rst @@ -82,8 +82,6 @@ Here are some example errors: .. code-block:: - _select_servers_loop - raise ServerSelectionTimeoutError( pymongo.errors.ServerSelectionTimeoutError: mongo_node2: [Errno 8] nodename nor servname provided, or not known,mongo_node1:27017 From f3939560830f49ba589cb618ba3a4fabf291e111 Mon Sep 17 00:00:00 2001 From: julius Date: Thu, 5 May 2022 15:11:11 -0700 Subject: [PATCH 5/9] initial commit --- .evergreen/config.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index a6d9375f26..7ca8fbe3ac 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1930,6 +1930,10 @@ axes: display_name: "MongoDB 5.0" variables: VERSION: "5.0" + - id: "6.0" + display_name: "MongoDB 6.0" + variables: + VERSION: "6.0" - id: "latest" display_name: "MongoDB latest" variables: @@ -2174,6 +2178,7 @@ buildvariants: tasks: &all-server-versions - ".rapid" - ".latest" + - ".6.0" - ".5.0" - ".4.4" - ".4.2" @@ -2190,6 +2195,7 @@ buildvariants: display_name: "Encryption ${platform} ${auth-ssl}" tasks: &encryption-server-versions - ".latest" + - ".6.0" - ".5.0" - ".4.4" - ".4.2" @@ -2234,6 +2240,7 @@ buildvariants: display_name: "${platform} ${auth} ${ssl}" tasks: - ".latest" + - ".6.0" - ".5.0" - ".4.4" - ".4.2" @@ -2581,7 +2588,7 @@ buildvariants: # See https://jira.mongodb.org/browse/SERVER-51364. platform: ubuntu-20.04 python-version: ["3.6", "3.10", "pypy3.6", "pypy3.8"] - mongodb-version: ["4.4", "5.0", "latest"] + mongodb-version: ["4.4", "5.0", "6.0", "latest"] auth: "noauth" ssl: "ssl" display_name: "OCSP test ${platform} ${python-version} ${mongodb-version}" @@ -2593,7 +2600,7 @@ buildvariants: matrix_spec: platform: windows-64-vsMulti-small python-version-windows: ["3.6", "3.10"] - mongodb-version: ["4.4", "5.0", "latest"] + mongodb-version: ["4.4", "5.0", "6.0", "latest"] auth: "noauth" ssl: "ssl" display_name: "OCSP test ${platform} ${python-version-windows} ${mongodb-version}" @@ -2605,7 +2612,7 @@ buildvariants: - matrix_name: "ocsp-test-macos" matrix_spec: platform: macos-1014 - mongodb-version: ["4.4", "5.0", "latest"] + mongodb-version: ["4.4", "5.0", "6.0", "latest"] auth: "noauth" ssl: "ssl" display_name: "OCSP test ${platform} ${mongodb-version}" @@ -2637,7 +2644,7 @@ buildvariants: - matrix_name: "load-balancer" matrix_spec: platform: ubuntu-18.04 - mongodb-version: ["rapid", "latest"] + mongodb-version: ["rapid", "latest", "6.0"] auth-ssl: "*" python-version: "*" loadbalancer: "*" From e2794f8212b88b8629e39c618818731b62816d00 Mon Sep 17 00:00:00 2001 From: julius Date: Thu, 5 May 2022 16:06:40 -0700 Subject: [PATCH 6/9] fix up branch --- .evergreen/config.yml | 27 +++++++++++++++++++++++++++ doc/changelog.rst | 9 --------- doc/migrate-to-pymongo4.rst | 24 ------------------------ pymongo/mongo_client.py | 5 ----- 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 7ca8fbe3ac..f36c7bbbec 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1233,6 +1233,33 @@ tasks: TOPOLOGY: "sharded_cluster" - func: "run tests" + - name: "test-6.0-standalone" + tags: ["6.0", "standalone"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "6.0" + TOPOLOGY: "server" + - func: "run tests" + + - name: "test-6.0-replica_set" + tags: ["6.0", "replica_set"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "6.0" + TOPOLOGY: "replica_set" + - func: "run tests" + + - name: "test-6.0-sharded_cluster" + tags: ["6.0", "sharded_cluster"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "6.0" + TOPOLOGY: "sharded_cluster" + - func: "run tests" + - name: "test-latest-standalone" tags: ["latest", "standalone"] commands: diff --git a/doc/changelog.rst b/doc/changelog.rst index 1fd5ea8dd3..0fe2300120 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -89,15 +89,6 @@ Changes in Version 4.0 .. warning:: PyMongo 4.0 drops support for MongoDB 2.6, 3.0, 3.2, and 3.4. -.. warning:: PyMongo 4.0 changes the default value of the ``directConnection`` URI option and - keyword argument to :class:`~pymongo.mongo_client.MongoClient` - to ``False`` instead of ``None``, allowing for the automatic - discovery of replica sets. This means that if you - want a direct connection to a single server you must pass - ``directConnection=True`` as a URI option or keyword argument. - For more details, see the relevant section of the PyMongo 4.x migration - guide: :ref:`pymongo4-migration-direct-connection`. - PyMongo 4.0 brings a number of improvements as well as some backward breaking changes. For example, all APIs deprecated in PyMongo 3.X have been removed. Be sure to read the changes listed below and the :doc:`migrate-to-pymongo4` diff --git a/doc/migrate-to-pymongo4.rst b/doc/migrate-to-pymongo4.rst index d70d7b8a2c..5f75ed1760 100644 --- a/doc/migrate-to-pymongo4.rst +++ b/doc/migrate-to-pymongo4.rst @@ -65,8 +65,6 @@ get the same behavior. MongoClient ----------- -.. _pymongo4-migration-direct-connection: - ``directConnection`` defaults to False ...................................... @@ -76,28 +74,6 @@ allowing for the automatic discovery of replica sets. This means that if you want a direct connection to a single server you must pass ``directConnection=True`` as a URI option or keyword argument. -If you see any :exc:`~pymongo.errors.ServerSelectionTimeoutError`'s after upgrading from PyMongo 3 to 4.x, you likely -need to add ``directConnection=True`` when creating the client. -Here are some example errors: - -.. code-block:: - - pymongo.errors.ServerSelectionTimeoutError: mongo_node2: [Errno 8] nodename nor servname - provided, or not known,mongo_node1:27017 - -.. code-block:: - - ServerSelectionTimeoutError: No servers match selector "Primary()", Timeout: 30s, - Topology Description: ... - - -Additionally, the "isWritablePrimary" attribute of a hello command sent back by the server will -always be True if ``directConnection=False``:: - - >>> client.admin.command('hello')['isWritablePrimary'] - True - - The waitQueueMultiple parameter is removed .......................................... diff --git a/pymongo/mongo_client.py b/pymongo/mongo_client.py index 6601c18aca..5c7e7cb176 100644 --- a/pymongo/mongo_client.py +++ b/pymongo/mongo_client.py @@ -137,11 +137,6 @@ def __init__( ) -> None: """Client for a MongoDB instance, a replica set, or a set of mongoses. - .. warning:: Starting in PyMongo 4.0, ``directConnection`` now has a default value of - False instead of None. - For more details, see the relevant section of the PyMongo 4.x migration guide: - :ref:`pymongo4-migration-direct-connection`. - The client object is thread-safe and has connection-pooling built in. If an operation fails because of a network error, :class:`~pymongo.errors.ConnectionFailure` is raised and the client From 53b77da0a2ae2cc642c85156c92763e7810531fc Mon Sep 17 00:00:00 2001 From: julius Date: Thu, 5 May 2022 17:08:45 -0700 Subject: [PATCH 7/9] add tasks and remove latest and rapid from awslinux --- .evergreen/config.yml | 58 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 54ffa3176d..d50ee07ea9 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1721,6 +1721,22 @@ tasks: - func: "run aws auth test with aws EC2 credentials" - func: "run aws ECS auth test" + - name: "aws-auth-test-6.0" + commands: + - func: "bootstrap mongo-orchestration" + vars: + AUTH: "auth" + ORCHESTRATION_FILE: "auth-aws.json" + TOPOLOGY: "server" + VERSION: "6.0" + - func: "add aws auth variables to file" + - func: "run aws auth test with regular aws credentials" + - func: "run aws auth test with assume role credentials" + - func: "run aws auth test with aws credentials as environment variables" + - func: "run aws auth test with aws credentials and session token as environment variables" + - func: "run aws auth test with aws EC2 credentials" + - func: "run aws ECS auth test" + - name: "aws-auth-test-latest" commands: - func: "bootstrap mongo-orchestration" @@ -1736,6 +1752,21 @@ tasks: - func: "run aws auth test with aws credentials and session token as environment variables" - func: "run aws auth test with aws EC2 credentials" - func: "run aws ECS auth test" + - name: "aws-auth-test-rapid" + commands: + - func: "bootstrap mongo-orchestration" + vars: + AUTH: "auth" + ORCHESTRATION_FILE: "auth-aws.json" + TOPOLOGY: "server" + VERSION: "rapid" + - func: "add aws auth variables to file" + - func: "run aws auth test with regular aws credentials" + - func: "run aws auth test with assume role credentials" + - func: "run aws auth test with aws credentials as environment variables" + - func: "run aws auth test with aws credentials and session token as environment variables" + - func: "run aws auth test with aws EC2 credentials" + - func: "run aws ECS auth test" - name: load-balancer-test commands: @@ -2190,9 +2221,7 @@ buildvariants: - awslinux auth-ssl: "*" display_name: "${platform} ${auth-ssl}" - tasks: &all-server-versions - - ".rapid" - - ".latest" + tasks: - ".6.0" - ".5.0" - ".4.4" @@ -2208,8 +2237,7 @@ buildvariants: auth-ssl: "*" encryption: "*" display_name: "Encryption ${platform} ${auth-ssl}" - tasks: &encryption-server-versions - - ".latest" + tasks: - ".6.0" - ".5.0" - ".4.4" @@ -2270,7 +2298,13 @@ buildvariants: ssl: "nossl" encryption: "*" display_name: "Encryption ${platform} ${auth} ${ssl}" - tasks: *encryption-server-versions + tasks: &encryption-server-versions + - ".latest" + - ".6.0" + - ".5.0" + - ".4.4" + - ".4.2" + - ".4.0" # Test one server version (4.2) with zSeries, POWER8, and ARM. - matrix_name: "test-different-cpu-architectures" @@ -2291,7 +2325,15 @@ buildvariants: auth-ssl: "*" coverage: "*" display_name: "${python-version} ${platform} ${auth-ssl} ${coverage}" - tasks: *all-server-versions + tasks: &all-server-versions + - ".rapid" + - ".latest" + - ".6.0" + - ".5.0" + - ".4.4" + - ".4.2" + - ".4.0" + - ".3.6" - matrix_name: "tests-pyopenssl" matrix_spec: @@ -2431,7 +2473,7 @@ buildvariants: auth-ssl: "*" display_name: "OpenSSL 1.0.2 ${python-version} ${platform} ${auth-ssl}" tasks: - - ".latest" + - ".6.0" - matrix_name: "tests-windows-encryption" matrix_spec: From a0c76d521da2b1799ce352738194308418074b11 Mon Sep 17 00:00:00 2001 From: julius Date: Thu, 5 May 2022 17:22:47 -0700 Subject: [PATCH 8/9] switch to 5.0 for openssl testing --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index d50ee07ea9..d744fd7cd4 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -2473,7 +2473,7 @@ buildvariants: auth-ssl: "*" display_name: "OpenSSL 1.0.2 ${python-version} ${platform} ${auth-ssl}" tasks: - - ".6.0" + - ".5.0" - matrix_name: "tests-windows-encryption" matrix_spec: From 76ca6b8833d11c06fd0cedbf5285d875024f9275 Mon Sep 17 00:00:00 2001 From: julius Date: Thu, 5 May 2022 17:25:17 -0700 Subject: [PATCH 9/9] add to matrices --- .evergreen/config.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index d744fd7cd4..97d13654c0 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -2682,6 +2682,8 @@ buildvariants: - name: "aws-auth-test-4.4" - name: "aws-auth-test-5.0" - name: "aws-auth-test-latest" + - name: "aws-auth-test-6.0" + - name: "aws-auth-test-rapid" - matrix_name: "aws-auth-test-mac" matrix_spec: @@ -2692,7 +2694,8 @@ buildvariants: - name: "aws-auth-test-4.4" - name: "aws-auth-test-5.0" - name: "aws-auth-test-latest" - + - name: "aws-auth-test-6.0" + - name: "aws-auth-test-rapid" - matrix_name: "aws-auth-test-windows" matrix_spec: platform: [windows-64-vsMulti-small] @@ -2702,6 +2705,8 @@ buildvariants: - name: "aws-auth-test-4.4" - name: "aws-auth-test-5.0" - name: "aws-auth-test-latest" + - name: "aws-auth-test-6.0" + - name: "aws-auth-test-rapid" - matrix_name: "load-balancer" matrix_spec: