Compare commits

..

1 Commits

Author SHA1 Message Date
Cloud User
bc48f0db82 resyncing specs 05-11-2026 2026-05-11 16:02:08 +00:00
12 changed files with 22 additions and 39 deletions

View File

@ -17,7 +17,6 @@ from __future__ import annotations
import json
from typing import Any, Optional
from urllib.parse import quote
def _get_azure_response(
@ -30,7 +29,7 @@ def _get_azure_response(
url += "?api-version=2018-02-01"
url += f"&resource={resource}"
if client_id:
url += f"&client_id={quote(client_id)}"
url += f"&client_id={client_id}"
headers = {"Metadata": "true", "Accept": "application/json"}
request = Request(url, headers=headers) # noqa: S310
try:

View File

@ -2711,11 +2711,11 @@ class TestClientPool(AsyncMockClientTest):
await async_wait_until(lambda: len(c.nodes) == 1, "connect")
self.assertEqual(await c.address, ("c", 3))
# Wait for the pooled connection to be registered
# Assert that we create 1 pooled connection.
await listener.async_wait_for_event(monitoring.ConnectionReadyEvent, 1)
self.assertEqual(listener.event_count(monitoring.ConnectionCreatedEvent), 1)
arbiter = c._topology.get_server_by_address(("c", 3))
await async_wait_until(lambda: len(arbiter.pool.conns) == 1, "create 1 pooled connection")
self.assertEqual(len(arbiter.pool.conns), 1)
# Arbiter pool is marked ready.
self.assertEqual(listener.event_count(monitoring.PoolReadyEvent), 1)

View File

@ -5,7 +5,8 @@
{
"topologies": [
"single",
"sharded"
"sharded",
"sharded-replicaset"
],
"serverless": "forbid"
}

View File

@ -385,7 +385,7 @@
]
},
{
"description": "pinned connections are returned after an network error during getMore",
"description": "pinned connections are not returned after an network error during getMore",
"operations": [
{
"name": "failPoint",
@ -449,7 +449,7 @@
"object": "testRunner",
"arguments": {
"client": "client0",
"connections": 0
"connections": 1
}
},
{
@ -677,7 +677,7 @@
]
},
{
"description": "pinned connections are returned to the pool after a non-network error on getMore",
"description": "pinned connections are not returned to the pool after a non-network error on getMore",
"operations": [
{
"name": "failPoint",
@ -733,7 +733,7 @@
"object": "testRunner",
"arguments": {
"client": "client0",
"connections": 0
"connections": 1
}
},
{

View File

@ -372,6 +372,9 @@
{
"connectionCreatedEvent": {}
},
{
"poolClearedEvent": {}
},
{
"connectionClosedEvent": {
"reason": "error"
@ -381,9 +384,6 @@
"connectionCheckOutFailedEvent": {
"reason": "connectionError"
}
},
{
"poolClearedEvent": {}
}
]
}

View File

@ -197,7 +197,7 @@
}
},
{
"level": "debug",
"level": "info",
"component": "serverSelection",
"data": {
"message": "Waiting for suitable server to become available",
@ -383,7 +383,7 @@
}
},
{
"level": "debug",
"level": "info",
"component": "serverSelection",
"data": {
"message": "Waiting for suitable server to become available",

View File

@ -184,7 +184,7 @@
}
},
{
"level": "debug",
"level": "info",
"component": "serverSelection",
"data": {
"message": "Waiting for suitable server to become available",

View File

@ -193,7 +193,7 @@
}
},
{
"level": "debug",
"level": "info",
"component": "serverSelection",
"data": {
"message": "Waiting for suitable server to become available",

View File

@ -191,7 +191,7 @@
}
},
{
"level": "debug",
"level": "info",
"component": "serverSelection",
"data": {
"message": "Waiting for suitable server to become available",

View File

@ -150,20 +150,6 @@ class TestGetAzureResponse(unittest.TestCase):
_, kwargs = mock_open.call_args
self.assertEqual(kwargs["timeout"], 42)
def test_client_id_is_url_encoded(self):
"""Ensure special characters in client_id are percent-encoded."""
body = json.dumps({"access_token": "tok", "expires_in": "3600"})
with _mock_urlopen(200, body) as mock_open:
self._call(client_id="id with spaces&special=chars")
url = mock_open.call_args[0][0].full_url
# '&' and '=' must be percent-encoded so they don't inject extra query params
self.assertIn("client_id=id%20with%20spaces%26special%3Dchars", url)
# The encoded client_id should not introduce a raw '&'
# Count params: api-version, resource, client_id — exactly 3
query_string = url.split("?", 1)[1]
self.assertEqual(query_string.count("&"), 2)
if __name__ == "__main__":
unittest.main()

View File

@ -2666,11 +2666,11 @@ class TestClientPool(MockClientTest):
wait_until(lambda: len(c.nodes) == 1, "connect")
self.assertEqual(c.address, ("c", 3))
# Wait for the pooled connection to be registered
# Assert that we create 1 pooled connection.
listener.wait_for_event(monitoring.ConnectionReadyEvent, 1)
self.assertEqual(listener.event_count(monitoring.ConnectionCreatedEvent), 1)
arbiter = c._topology.get_server_by_address(("c", 3))
wait_until(lambda: len(arbiter.pool.conns) == 1, "create 1 pooled connection")
self.assertEqual(len(arbiter.pool.conns), 1)
# Arbiter pool is marked ready.
self.assertEqual(listener.event_count(monitoring.PoolReadyEvent), 1)

View File

@ -23,7 +23,7 @@ sys.path[0:0] = [""]
from test import client_knobs, unittest
from test.pymongo_mocks import DummyMonitor
from test.utils import MockPool
from test.utils import MockPool, flaky
from test.utils_shared import wait_until
from bson.objectid import ObjectId
@ -755,6 +755,7 @@ def wait_for_primary(topology):
class TestTopologyErrors(TopologyTest):
# Errors when calling hello.
@flaky(reason="PYTHON-5366")
def test_pool_reset(self):
# hello succeeds at first, then always raises socket error.
hello_count = [0]
@ -775,11 +776,7 @@ class TestTopologyErrors(TopologyTest):
# Pool is reset by hello failure.
t.request_check_all()
# Wait for the monitor's hello failure to trigger Pool.reset() and bump the generation.
wait_until(
lambda: server.pool.gen.get_overall() != generation,
"pool reset after failed monitor check",
)
self.assertNotEqual(generation, server.pool.gen.get_overall())
def test_hello_retry(self):
# hello succeeds at first, then raises socket error, then succeeds.