Skip to content
Draft
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
4 changes: 2 additions & 2 deletions test/asynchronous/test_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import asyncio
import time
from test.asynchronous import AsyncIntegrationTest, async_client_context
from test.utils_shared import delay

_IS_SYNC = False


class TestAsyncConcurrency(AsyncIntegrationTest):
async def _task(self, client):
await client.db.test.find_one({"$where": delay(0.20)})
await client.db.test.find_one({})
await asyncio.sleep(0.20)

async def test_concurrency(self):
tasks = []
Expand Down
5 changes: 5 additions & 0 deletions test/asynchronous/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import gc
import itertools
import os
import platform
import random
import re
import sys
Expand Down Expand Up @@ -832,6 +833,10 @@ async def test_sort(self):
break
self.assertRaises(InvalidOperation, a.sort, "x", ASCENDING)

@unittest.skipIf(
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
"PYTHON-5861: $where is too slow on macOS ARM64 CI",
)
async def test_where(self):
db = self.db
await db.test.drop()
Expand Down
9 changes: 9 additions & 0 deletions test/asynchronous/test_discovery_and_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import asyncio
import os
import platform
import socketserver
import sys
import threading
Expand Down Expand Up @@ -303,6 +304,10 @@ async def send_cluster_time(time, inc):


class TestIgnoreStaleErrors(AsyncIntegrationTest):
@unittest.skipIf(
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
"PYTHON-5861: asyncio.Barrier hangs on macOS ARM64 CI",
)
async def test_ignore_stale_connection_errors(self):
if not _IS_SYNC and sys.version_info < (3, 11):
self.skipTest("Test requires asyncio.Barrier (added in Python 3.11)")
Expand Down Expand Up @@ -451,6 +456,10 @@ async def mock_close(self, reason):

class TestPoolBackpressure(AsyncIntegrationTest):
@async_client_context.require_version_min(7, 0, 0)
@unittest.skipIf(
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
"PYTHON-5861: $where is too slow on macOS ARM64 CI",
)
async def test_connection_pool_is_not_cleared(self):
listener = CMAPListener()

Expand Down
5 changes: 2 additions & 3 deletions test/asynchronous/test_pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,7 @@ async def test_max_pool_size(self):

async def f():
for _ in range(5):
await collection.find_one({"$where": delay(0.1)})
assert len(cx_pool.conns) <= max_pool_size
await collection.find_one({})

async with lock:
self.n_passed += 1
Expand Down Expand Up @@ -600,7 +599,7 @@ async def test_max_pool_size_none(self):

async def f():
for _ in range(5):
await collection.find_one({"$where": delay(0.1)})
await collection.find_one({})

async with lock:
self.n_passed += 1
Expand Down
6 changes: 6 additions & 0 deletions test/asynchronous/test_server_selection_in_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import asyncio
import os
import platform
import sys
import threading
from pathlib import Path
from test.asynchronous import AsyncIntegrationTest, async_client_context, unittest
Expand Down Expand Up @@ -137,6 +139,10 @@ async def frequencies(self, client, listener, n_finds=10):

@async_client_context.require_failCommand_appName
@async_client_context.require_multiple_mongoses
@unittest.skipIf(
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
"PYTHON-5861: Load balancing frequency assertion is timing-sensitive on macOS ARM64 CI",
)
async def test_load_balancing(self):
listener = OvertCommandListener()
cmap_listener = CMAPListener()
Expand Down
6 changes: 6 additions & 0 deletions test/asynchronous/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from __future__ import annotations

import asyncio
import os
import platform
import random
import sys
import time
Expand Down Expand Up @@ -582,6 +584,10 @@ async def callback(session):
self.assertTrue(context.exception.has_error_label("UnknownTransactionCommitResult"))

@async_client_context.require_transactions
@unittest.skipIf(
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
"PYTHON-5861: Transaction operations too slow on macOS ARM64 CI",
)
async def test_callback_not_retried_after_csot_timeout(self):
listener = OvertCommandListener()
client = await self.async_rs_client(event_listeners=[listener])
Expand Down
11 changes: 11 additions & 0 deletions test/asynchronous/unified_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import copy
import functools
import os
import platform
import re
import sys
import time
Expand Down Expand Up @@ -1464,6 +1465,16 @@ async def verify_outcome(self, spec):
self.assertListEqual(sorted_expected_documents, actual_documents)

async def run_scenario(self, spec, uri=None):
# Skip tests that rely on $where performance on macOS ARM64 CI.
if sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ:
arm64_skip_tests = [
("PYTHON-5861", ".*InterruptInUsePoolClear.*is_retryable"),
("PYTHON-5861", ".*timeoutms_can_be_overridden_for_upload"),
]
for reason, skip_pattern in arm64_skip_tests:
if re.match(skip_pattern.lower(), self.id().lower()) is not None:
self.skipTest(f"{reason}: $where is too slow on macOS ARM64 CI")

# Handle flaky tests.
flaky_tests = [
("PYTHON-5170", ".*test_discovery_and_monitoring.*"),
Expand Down
5 changes: 5 additions & 0 deletions test/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import gc
import itertools
import os
import platform
import random
import re
import sys
Expand Down Expand Up @@ -823,6 +824,10 @@ def test_sort(self):
break
self.assertRaises(InvalidOperation, a.sort, "x", ASCENDING)

@unittest.skipIf(
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
"PYTHON-5861: $where is too slow on macOS ARM64 CI",
)
def test_where(self):
db = self.db
db.test.drop()
Expand Down
9 changes: 9 additions & 0 deletions test/test_discovery_and_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import asyncio
import os
import platform
import socketserver
import sys
import threading
Expand Down Expand Up @@ -303,6 +304,10 @@ def send_cluster_time(time, inc):


class TestIgnoreStaleErrors(IntegrationTest):
@unittest.skipIf(
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
"PYTHON-5861: asyncio.Barrier hangs on macOS ARM64 CI",
)
def test_ignore_stale_connection_errors(self):
if not _IS_SYNC and sys.version_info < (3, 11):
self.skipTest("Test requires asyncio.Barrier (added in Python 3.11)")
Expand Down Expand Up @@ -449,6 +454,10 @@ def mock_close(self, reason):

class TestPoolBackpressure(IntegrationTest):
@client_context.require_version_min(7, 0, 0)
@unittest.skipIf(
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
"PYTHON-5861: $where is too slow on macOS ARM64 CI",
)
def test_connection_pool_is_not_cleared(self):
listener = CMAPListener()

Expand Down
5 changes: 2 additions & 3 deletions test/test_pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,7 @@ def test_max_pool_size(self):

def f():
for _ in range(5):
collection.find_one({"$where": delay(0.1)})
assert len(cx_pool.conns) <= max_pool_size
collection.find_one({})

with lock:
self.n_passed += 1
Expand Down Expand Up @@ -598,7 +597,7 @@ def test_max_pool_size_none(self):

def f():
for _ in range(5):
collection.find_one({"$where": delay(0.1)})
collection.find_one({})

with lock:
self.n_passed += 1
Expand Down
6 changes: 6 additions & 0 deletions test/test_server_selection_in_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import asyncio
import os
import platform
import sys
import threading
from pathlib import Path
from test import IntegrationTest, client_context, unittest
Expand Down Expand Up @@ -137,6 +139,10 @@ def frequencies(self, client, listener, n_finds=10):

@client_context.require_failCommand_appName
@client_context.require_multiple_mongoses
@unittest.skipIf(
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
"PYTHON-5861: Load balancing frequency assertion is timing-sensitive on macOS ARM64 CI",
)
def test_load_balancing(self):
listener = OvertCommandListener()
cmap_listener = CMAPListener()
Expand Down
6 changes: 6 additions & 0 deletions test/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from __future__ import annotations

import asyncio
import os
import platform
import random
import sys
import time
Expand Down Expand Up @@ -570,6 +572,10 @@ def callback(session):
self.assertTrue(context.exception.has_error_label("UnknownTransactionCommitResult"))

@client_context.require_transactions
@unittest.skipIf(
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
"PYTHON-5861: Transaction operations too slow on macOS ARM64 CI",
)
def test_callback_not_retried_after_csot_timeout(self):
listener = OvertCommandListener()
client = self.rs_client(event_listeners=[listener])
Expand Down
11 changes: 11 additions & 0 deletions test/unified_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import copy
import functools
import os
import platform
import re
import sys
import time
Expand Down Expand Up @@ -1451,6 +1452,16 @@ def verify_outcome(self, spec):
self.assertListEqual(sorted_expected_documents, actual_documents)

def run_scenario(self, spec, uri=None):
# Skip tests that rely on $where performance on macOS ARM64 CI.
if sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ:
arm64_skip_tests = [
("PYTHON-5861", ".*InterruptInUsePoolClear.*is_retryable"),
("PYTHON-5861", ".*timeoutms_can_be_overridden_for_upload"),
]
for reason, skip_pattern in arm64_skip_tests:
if re.match(skip_pattern.lower(), self.id().lower()) is not None:
self.skipTest(f"{reason}: $where is too slow on macOS ARM64 CI")

# Handle flaky tests.
flaky_tests = [
("PYTHON-5170", ".*test_discovery_and_monitoring.*"),
Expand Down
Loading