Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/asynchronous/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,7 @@ def test_gevent_timeout_when_creating_connection(self):
client = self.async_rs_or_single_client()
self.addCleanup(client.close)
coll = client.pymongo_test.test
pool = async_get_pool(client)
pool = async_get_pool(client) # type:ignore

# Patch the pool to delay the connect method.
def delayed_connect(*args, **kwargs):
Expand Down
14 changes: 12 additions & 2 deletions test/asynchronous/unified_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,17 @@ async def _create_entity(self, entity_spec, uri=None):
kwargs["h"] = uri
client = await self.test.async_rs_or_single_client(**kwargs)
await client.aconnect()
# Wait for pool to be populated.
if "awaitMinPoolSizeMS" in spec:
pool = await async_get_pool(client)
t0 = time.monotonic()
while True:
if (time.monotonic() - t0) > spec["awaitMinPoolSizeMS"] * 1000:
raise ValueError("Test timed out during awaitMinPoolSize")
async with pool.lock:
if len(pool.conns) + pool.active_sockets >= pool.opts.min_pool_size:
break
await asyncio.sleep(0.1)
self[spec["id"]] = client
return
elif entity_type == "database":
Expand Down Expand Up @@ -463,7 +474,7 @@ class UnifiedSpecTestMixinV1(AsyncIntegrationTest):
a class attribute ``TEST_SPEC``.
"""

SCHEMA_VERSION = Version.from_string("1.25")
SCHEMA_VERSION = Version.from_string("1.26")
RUN_ON_LOAD_BALANCER = True
TEST_SPEC: Any
TEST_PATH = "" # This gets filled in by generate_test_classes
Expand Down Expand Up @@ -1551,7 +1562,6 @@ async def test_case(self):
if re.search(fail_pattern, description):
test_method = unittest.expectedFailure(test_method)
break

setattr(cls, test_name, test_method)


Expand Down
6 changes: 3 additions & 3 deletions test/asynchronous/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@

from bson.son import SON
from pymongo import AsyncMongoClient
from pymongo.asynchronous.pool import Pool, _CancellationContext, _PoolGeneration
from pymongo.errors import ConfigurationError
from pymongo.hello import HelloCompat
from pymongo.lock import _async_create_lock
from pymongo.operations import _Op
from pymongo.read_preferences import ReadPreference
from pymongo.server_selectors import any_server_selector, writable_server_selector
from pymongo.synchronous.pool import _CancellationContext, _PoolGeneration

_IS_SYNC = False


async def async_get_pool(client):
async def async_get_pool(client: AsyncMongoClient) -> Pool:
"""Get the standalone, primary, or mongos pool."""
topology = await client._get_topology()
server = await topology._select_server(writable_server_selector, _Op.TEST)
return server.pool


async def async_get_pools(client):
async def async_get_pools(client: AsyncMongoClient) -> list[Pool]:
"""Get all pools."""
return [
server.pool
Expand Down
14 changes: 10 additions & 4 deletions test/csot/command-execution.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "timeoutMS behaves correctly during command execution",
"schemaVersion": "1.9",
"schemaVersion": "1.26",
"runOnRequirements": [
{
"minServerVersion": "4.4.7",
Expand Down Expand Up @@ -69,8 +69,10 @@
"appName": "reduceMaxTimeMSTest",
"w": 1,
"timeoutMS": 500,
"heartbeatFrequencyMS": 500
"heartbeatFrequencyMS": 500,
"minPoolSize": 1
},
"awaitMinPoolSizeMS": 10000,
"observeEvents": [
"commandStartedEvent"
]
Expand Down Expand Up @@ -185,8 +187,10 @@
"appName": "rttTooHighTest",
"w": 1,
"timeoutMS": 10,
"heartbeatFrequencyMS": 500
"heartbeatFrequencyMS": 500,
"minPoolSize": 1
},
"awaitMinPoolSizeMS": 10000,
"observeEvents": [
"commandStartedEvent"
]
Expand Down Expand Up @@ -316,8 +320,10 @@
"appName": "reduceMaxTimeMSTest",
"w": 1,
"timeoutMS": 90,
"heartbeatFrequencyMS": 100000
"heartbeatFrequencyMS": 100000,
"minPoolSize": 1
},
"awaitMinPoolSizeMS": 10000,
"observeEvents": [
"commandStartedEvent"
]
Expand Down
6 changes: 4 additions & 2 deletions test/csot/convenient-transactions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "timeoutMS behaves correctly for the withTransaction API",
"schemaVersion": "1.9",
"schemaVersion": "1.26",
"runOnRequirements": [
{
"minServerVersion": "4.4",
Expand All @@ -21,8 +21,10 @@
"client": {
"id": "client",
"uriOptions": {
"timeoutMS": 500
"timeoutMS": 500,
"minPoolSize": 1
},
"awaitMinPoolSizeMS": 10000,
"useMultipleMongoses": false,
"observeEvents": [
"commandStartedEvent"
Expand Down
6 changes: 4 additions & 2 deletions test/csot/error-transformations.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "MaxTimeMSExpired server errors are transformed into a custom timeout error",
"schemaVersion": "1.9",
"schemaVersion": "1.26",
"runOnRequirements": [
{
"minServerVersion": "4.0",
Expand All @@ -26,8 +26,10 @@
"client": {
"id": "client",
"uriOptions": {
"timeoutMS": 250
"timeoutMS": 250,
"minPoolSize": 1
},
"awaitMinPoolSizeMS": 10000,
"useMultipleMongoses": false,
"observeEvents": [
"commandStartedEvent"
Expand Down
Loading
Loading