-
Type:
Build Failure
-
Resolution: Fixed
-
Priority:
Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Python Drivers
-
Not Needed
-
-
None
-
None
-
None
-
None
-
None
-
None
Name of Failure:
test.test_client.TestClient.test_init_disconnected_with_srv
Link to task:
Context of when and why the failure occurred:
Intended behavior of MongoClient.address.
Stack trace:
[2025/04/23 10:10:12.482] FAILURE: pymongo.errors.InvalidOperation: Cannot use "address" property when load balancing among mongoses, use "nodes" instead. () [2025/04/23 10:10:12.482] self = <test.test_client.TestClient testMethod=test_init_disconnected_with_srv> [2025/04/23 10:10:12.482] @client_context.require_no_standalone [2025/04/23 10:10:12.482] @client_context.require_no_load_balancer [2025/04/23 10:10:12.482] @client_context.require_tls [2025/04/23 10:10:12.482] def test_init_disconnected_with_srv(self): [2025/04/23 10:10:12.482] c = self.rs_or_single_client( [2025/04/23 10:10:12.482] "mongodb+srv://test1.test.build.10gen.cc", connect=False, tlsInsecure=True [2025/04/23 10:10:12.482] ) [2025/04/23 10:10:12.482] # nodes returns an empty set if not connected [2025/04/23 10:10:12.482] self.assertEqual(c.nodes, frozenset()) [2025/04/23 10:10:12.482] # topology_description returns the initial seed description if not connected [2025/04/23 10:10:12.482] topology_description = c.topology_description [2025/04/23 10:10:12.482] self.assertEqual(topology_description.topology_type, TOPOLOGY_TYPE.Unknown) [2025/04/23 10:10:12.482] self.assertEqual( [2025/04/23 10:10:12.482] { [2025/04/23 10:10:12.482] ("test1.test.build.10gen.cc", None): ServerDescription( [2025/04/23 10:10:12.482] ("test1.test.build.10gen.cc", None) [2025/04/23 10:10:12.482] ) [2025/04/23 10:10:12.482] }, [2025/04/23 10:10:12.482] topology_description.server_descriptions(), [2025/04/23 10:10:12.482] ) [2025/04/23 10:10:12.482] [2025/04/23 10:10:12.482] # address causes client to block until connected [2025/04/23 10:10:12.482] > self.assertIsNotNone(c.address) [2025/04/23 10:10:12.482] test/test_client.py:850: [2025/04/23 10:10:12.482] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ [2025/04/23 10:10:12.482] self = MongoClient(host=['localhost.test.build.10gen.cc:27017', 'localhost.test.build.10gen.cc:27018'], document_class=dict, ...', tlsinsecure=True, tlsallowinvalidhostnames=True, tlsdisableocspendpointcheck=True, tlsallowinvalidcertificates=True) [2025/04/23 10:10:12.482] @property [2025/04/23 10:10:12.482] def address(self) -> Optional[tuple[str, int]]: [2025/04/23 10:10:12.482] """(host, port) of the current standalone, primary, or mongos, or None. [2025/04/23 10:10:12.482] [2025/04/23 10:10:12.482] Accessing :attr:`address` raises :exc:`~.errors.InvalidOperation` if [2025/04/23 10:10:12.482] the client is load-balancing among mongoses, since there is no single [2025/04/23 10:10:12.482] address. Use :attr:`nodes` instead. [2025/04/23 10:10:12.482] [2025/04/23 10:10:12.482] If the client is not connected, this will block until a connection is [2025/04/23 10:10:12.482] established or raise ServerSelectionTimeoutError if no server is [2025/04/23 10:10:12.482] available. [2025/04/23 10:10:12.482] [2025/04/23 10:10:12.482] .. versionadded:: 3.0 [2025/04/23 10:10:12.482] """ [2025/04/23 10:10:12.482] if self._topology is None: [2025/04/23 10:10:12.482] self._get_topology() [2025/04/23 10:10:12.482] topology_type = self._topology._description.topology_type [2025/04/23 10:10:12.482] if ( [2025/04/23 10:10:12.482] topology_type == TOPOLOGY_TYPE.Sharded [2025/04/23 10:10:12.482] and len(self.topology_description.server_descriptions()) > 1 [2025/04/23 10:10:12.482] ): [2025/04/23 10:10:12.482] > raise InvalidOperation( [2025/04/23 10:10:12.482] 'Cannot use "address" property when load balancing among' [2025/04/23 10:10:12.482] ' mongoses, use "nodes" instead.' [2025/04/23 10:10:12.482] ) [2025/04/23 10:10:12.482] E pymongo.errors.InvalidOperation: Cannot use "address" property when load balancing among mongoses, use "nodes" instead. [2025/04/23 10:10:12.482] pymongo/synchronous/mongo_client.py:1593: InvalidOperation