Skip to content

Commit a24fc91

Browse files
authored
PYTHON-5861 Fix macOS ARM64 test regressions (#2853)
1 parent 99fd309 commit a24fc91

13 files changed

Lines changed: 102 additions & 1 deletion

test/asynchronous/test_concurrency.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
from __future__ import annotations
1717

1818
import asyncio
19+
import os
20+
import platform
21+
import sys
1922
import time
20-
from test.asynchronous import AsyncIntegrationTest, async_client_context
23+
from test.asynchronous import AsyncIntegrationTest, async_client_context, unittest
2124
from test.utils_shared import delay
2225

2326
_IS_SYNC = False
@@ -27,6 +30,10 @@ class TestAsyncConcurrency(AsyncIntegrationTest):
2730
async def _task(self, client):
2831
await client.db.test.find_one({"$where": delay(0.20)})
2932

33+
@unittest.skipIf(
34+
sys.platform == "darwin" and "CI" in os.environ,
35+
"PYTHON-5861: $where is too slow on macOS CI",
36+
)
3037
async def test_concurrency(self):
3138
tasks = []
3239
iterations = 5

test/asynchronous/test_cursor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import gc
2020
import itertools
2121
import os
22+
import platform
2223
import random
2324
import re
2425
import sys
@@ -832,6 +833,10 @@ async def test_sort(self):
832833
break
833834
self.assertRaises(InvalidOperation, a.sort, "x", ASCENDING)
834835

836+
@unittest.skipIf(
837+
sys.platform == "darwin" and "CI" in os.environ,
838+
"PYTHON-5861: $where is too slow on macOS CI",
839+
)
835840
async def test_where(self):
836841
db = self.db
837842
await db.test.drop()

test/asynchronous/test_discovery_and_monitoring.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import asyncio
1919
import os
20+
import platform
2021
import socketserver
2122
import sys
2223
import threading
@@ -303,6 +304,10 @@ async def send_cluster_time(time, inc):
303304

304305

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

452457
class TestPoolBackpressure(AsyncIntegrationTest):
453458
@async_client_context.require_version_min(7, 0, 0)
459+
@unittest.skipIf(
460+
sys.platform == "darwin" and "CI" in os.environ,
461+
"PYTHON-5861: $where is too slow on macOS CI",
462+
)
454463
async def test_connection_pool_is_not_cleared(self):
455464
listener = CMAPListener()
456465

test/asynchronous/test_pooling.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import asyncio
1919
import gc
20+
import os
21+
import platform
2022
import random
2123
import socket
2224
import sys
@@ -548,6 +550,10 @@ async def test_pool_backpressure_preserves_existing_connections(self):
548550

549551

550552
class TestPoolMaxSize(_TestPoolingBase):
553+
@unittest.skipIf(
554+
sys.platform == "darwin" and "CI" in os.environ,
555+
"PYTHON-5861: $where is too slow on macOS CI",
556+
)
551557
async def test_max_pool_size(self):
552558
max_pool_size = 4
553559
c = await self.async_rs_or_single_client(maxPoolSize=max_pool_size)
@@ -584,6 +590,10 @@ async def f():
584590
self.assertGreater(len(cx_pool.conns), 1)
585591
self.assertEqual(0, cx_pool.requests)
586592

593+
@unittest.skipIf(
594+
sys.platform == "darwin" and "CI" in os.environ,
595+
"PYTHON-5861: $where is too slow on macOS CI",
596+
)
587597
async def test_max_pool_size_none(self):
588598
c = await self.async_rs_or_single_client(maxPoolSize=None)
589599
collection = c[DB].test

test/asynchronous/test_server_selection_in_window.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import asyncio
1919
import os
20+
import platform
21+
import sys
2022
import threading
2123
from pathlib import Path
2224
from test.asynchronous import AsyncIntegrationTest, async_client_context, unittest
@@ -137,6 +139,10 @@ async def frequencies(self, client, listener, n_finds=10):
137139

138140
@async_client_context.require_failCommand_appName
139141
@async_client_context.require_multiple_mongoses
142+
@unittest.skipIf(
143+
sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
144+
"PYTHON-5861: Load balancing frequency assertion is timing-sensitive on macOS ARM64 CI",
145+
)
140146
async def test_load_balancing(self):
141147
listener = OvertCommandListener()
142148
cmap_listener = CMAPListener()

test/asynchronous/test_transactions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from __future__ import annotations
1717

1818
import asyncio
19+
import os
20+
import platform
1921
import random
2022
import sys
2123
import time
@@ -582,6 +584,10 @@ async def callback(session):
582584
self.assertTrue(context.exception.has_error_label("UnknownTransactionCommitResult"))
583585

584586
@async_client_context.require_transactions
587+
@unittest.skipIf(
588+
sys.platform == "darwin" and "CI" in os.environ,
589+
"PYTHON-5861: $where is too slow on macOS CI",
590+
)
585591
async def test_callback_not_retried_after_csot_timeout(self):
586592
listener = OvertCommandListener()
587593
client = await self.async_rs_client(event_listeners=[listener])

test/asynchronous/unified_format.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import copy
2424
import functools
2525
import os
26+
import platform
2627
import re
2728
import sys
2829
import time
@@ -1470,6 +1471,16 @@ async def verify_outcome(self, spec):
14701471
self.assertListEqual(sorted_expected_documents, actual_documents)
14711472

14721473
async def run_scenario(self, spec, uri=None):
1474+
# Skip tests that rely on $where performance on macOS CI.
1475+
if sys.platform == "darwin" and "CI" in os.environ:
1476+
macos_skip_tests = [
1477+
("PYTHON-5861", ".*InterruptInUsePoolClear.*is_retryable"),
1478+
("PYTHON-5861", ".*timeoutms_can_be_overridden_for_upload"),
1479+
]
1480+
for reason, skip_pattern in macos_skip_tests:
1481+
if re.match(skip_pattern.lower(), self.id().lower()) is not None:
1482+
self.skipTest(f"{reason}: $where is too slow on macOS CI")
1483+
14731484
# Handle flaky tests.
14741485
flaky_tests = [
14751486
("PYTHON-5170", ".*test_discovery_and_monitoring.*"),

test/test_cursor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import gc
2020
import itertools
2121
import os
22+
import platform
2223
import random
2324
import re
2425
import sys
@@ -823,6 +824,10 @@ def test_sort(self):
823824
break
824825
self.assertRaises(InvalidOperation, a.sort, "x", ASCENDING)
825826

827+
@unittest.skipIf(
828+
sys.platform == "darwin" and "CI" in os.environ,
829+
"PYTHON-5861: $where is too slow on macOS CI",
830+
)
826831
def test_where(self):
827832
db = self.db
828833
db.test.drop()

test/test_discovery_and_monitoring.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import asyncio
1919
import os
20+
import platform
2021
import socketserver
2122
import sys
2223
import threading
@@ -303,6 +304,10 @@ def send_cluster_time(time, inc):
303304

304305

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

450455
class TestPoolBackpressure(IntegrationTest):
451456
@client_context.require_version_min(7, 0, 0)
457+
@unittest.skipIf(
458+
sys.platform == "darwin" and "CI" in os.environ,
459+
"PYTHON-5861: $where is too slow on macOS CI",
460+
)
452461
def test_connection_pool_is_not_cleared(self):
453462
listener = CMAPListener()
454463

test/test_pooling.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import asyncio
1919
import gc
20+
import os
21+
import platform
2022
import random
2123
import socket
2224
import sys
@@ -546,6 +548,10 @@ def test_pool_backpressure_preserves_existing_connections(self):
546548

547549

548550
class TestPoolMaxSize(_TestPoolingBase):
551+
@unittest.skipIf(
552+
sys.platform == "darwin" and "CI" in os.environ,
553+
"PYTHON-5861: $where is too slow on macOS CI",
554+
)
549555
def test_max_pool_size(self):
550556
max_pool_size = 4
551557
c = self.rs_or_single_client(maxPoolSize=max_pool_size)
@@ -582,6 +588,10 @@ def f():
582588
self.assertGreater(len(cx_pool.conns), 1)
583589
self.assertEqual(0, cx_pool.requests)
584590

591+
@unittest.skipIf(
592+
sys.platform == "darwin" and "CI" in os.environ,
593+
"PYTHON-5861: $where is too slow on macOS CI",
594+
)
585595
def test_max_pool_size_none(self):
586596
c = self.rs_or_single_client(maxPoolSize=None)
587597
collection = c[DB].test

0 commit comments

Comments
 (0)