Skip to content

Commit b40dc2c

Browse files
committed
skip more tests
1 parent 9065639 commit b40dc2c

File tree

5 files changed

+61
-18
lines changed

5 files changed

+61
-18
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,13 @@ If you are running one of the `no-responder` tests, omit the `run-server` step.
404404
- Regenerate the test variants and tasks using `pre-commit run --all-files generate-config`.
405405
- Make sure to add instructions for running the test suite to `CONTRIBUTING.md`.
406406

407+
## Handling flaky tests
408+
409+
We have a custom ``flaky`` decorator in [test/asynchronous/utils.py](test/asynchronous/utils.py) that can be used for
410+
tests that are ``flaky``. By default the decorator only applies when not running on CPython on Linux, since other
411+
runtimes tend to have more variation. When using the ``flaky`` decorator, open a corresponding ticket and
412+
a comment with the ticket number.
413+
407414
## Specification Tests
408415

409416
The MongoDB [specifications repository](https://github.com/mongodb/specifications)

test/asynchronous/unified_format.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -534,17 +534,25 @@ def maybe_skip_test(self, spec):
534534
description = spec["description"].lower()
535535
if "csot" in class_name:
536536
# Skip tests that are too slow to run on a given platform.
537-
slow_win32 = [
538-
"maxtimems value in the command is less than timeoutms",
539-
"non-tailable cursor lifetime remaining timeoutms applied to getmore if timeoutmode is unset",
540-
]
541537
slow_macos = [
542-
"non-tailable cursor lifetime remaining timeoutms applied to getmore if timeoutmode is unset"
538+
"operation fails after two consecutive socket timeouts.*",
539+
"operation succeeds after one socket timeout.*",
540+
"Non-tailable cursor lifetime remaining timeoutMS applied to getMore if timeoutMode is unset",
541+
]
542+
slow_win32 = [
543+
*slow_macos,
544+
"maxTimeMS value in the command is less than timeoutMS",
543545
]
544-
if sys.platform == "win32" and description in slow_win32 or "gridfs" in class_name:
545-
self.skipTest("PYTHON-3522 CSOT test runs too slow on Windows")
546-
if sys.platform == "darwin" and description in slow_macos:
547-
self.skipTest("PYTHON-3522 CSOT test runs too slow on MacOS")
546+
if sys.platform == "win32" and "gridfs" in class_name:
547+
self.skipTest("PYTHON-3522 CSOT GridFS test runs too slow on Windows")
548+
if sys.platform == "win32":
549+
for pat in slow_win32:
550+
if re.match(pat, description.lower()):
551+
self.skipTest("PYTHON-3522 CSOT test runs too slow on Windows")
552+
if sys.platform == "darwin":
553+
for pat in slow_macos:
554+
if re.match(pat, description.lower()):
555+
self.skipTest("PYTHON-3522 CSOT test runs too slow on MacOS")
548556
if async_client_context.storage_engine == "mmapv1":
549557
self.skipTest(
550558
"MMAPv1 does not support retryable writes which is required for CSOT tests"

test/asynchronous/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ def flaky(
168168
func_name=None,
169169
reset_func=None,
170170
):
171+
"""Decorate a test as flaky.
172+
173+
:param max_runs: the maximum number of runs before raising an error
174+
:param min_passes: the minimum number of passing runs
175+
:param delay: the delay in seconds between retries
176+
:param affects_cpython_links: whether the test is flaky on CPython on Linux
177+
:param func_name: the name of the function, used for the rety message
178+
:param reset_func: a function to call before retrying
179+
180+
"""
171181
is_cpython_linux = sys.platform == "linux" and sys.implementation.name == "cpython"
172182
disable_flaky = "DISABLE_FLAKY" in os.environ
173183
if disable_flaky or (is_cpython_linux and not affects_cpython_linux):

test/unified_format.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -533,17 +533,25 @@ def maybe_skip_test(self, spec):
533533
description = spec["description"].lower()
534534
if "csot" in class_name:
535535
# Skip tests that are too slow to run on a given platform.
536-
slow_win32 = [
537-
"maxtimems value in the command is less than timeoutms",
538-
"non-tailable cursor lifetime remaining timeoutms applied to getmore if timeoutmode is unset",
539-
]
540536
slow_macos = [
541-
"non-tailable cursor lifetime remaining timeoutms applied to getmore if timeoutmode is unset"
537+
"operation fails after two consecutive socket timeouts.*",
538+
"operation succeeds after one socket timeout.*",
539+
"Non-tailable cursor lifetime remaining timeoutMS applied to getMore if timeoutMode is unset",
540+
]
541+
slow_win32 = [
542+
*slow_macos,
543+
"maxTimeMS value in the command is less than timeoutMS",
542544
]
543-
if sys.platform == "win32" and description in slow_win32 or "gridfs" in class_name:
544-
self.skipTest("PYTHON-3522 CSOT test runs too slow on Windows")
545-
if sys.platform == "darwin" and description in slow_macos:
546-
self.skipTest("PYTHON-3522 CSOT test runs too slow on MacOS")
545+
if sys.platform == "win32" and "gridfs" in class_name:
546+
self.skipTest("PYTHON-3522 CSOT GridFS test runs too slow on Windows")
547+
if sys.platform == "win32":
548+
for pat in slow_win32:
549+
if re.match(pat, description.lower()):
550+
self.skipTest("PYTHON-3522 CSOT test runs too slow on Windows")
551+
if sys.platform == "darwin":
552+
for pat in slow_macos:
553+
if re.match(pat, description.lower()):
554+
self.skipTest("PYTHON-3522 CSOT test runs too slow on MacOS")
547555
if client_context.storage_engine == "mmapv1":
548556
self.skipTest(
549557
"MMAPv1 does not support retryable writes which is required for CSOT tests"

test/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ def flaky(
166166
func_name=None,
167167
reset_func=None,
168168
):
169+
"""Decorate a test as flaky.
170+
171+
:param max_runs: the maximum number of runs before raising an error
172+
:param min_passes: the minimum number of passing runs
173+
:param delay: the delay in seconds between retries
174+
:param affects_cpython_links: whether the test is flaky on CPython on Linux
175+
:param func_name: the name of the function, used for the rety message
176+
:param reset_func: a function to call before retrying
177+
178+
"""
169179
is_cpython_linux = sys.platform == "linux" and sys.implementation.name == "cpython"
170180
disable_flaky = "DISABLE_FLAKY" in os.environ
171181
if disable_flaky or (is_cpython_linux and not affects_cpython_linux):

0 commit comments

Comments
 (0)