Skip to content

Commit 4550db2

Browse files
committed
address review
1 parent 771bde9 commit 4550db2

File tree

9 files changed

+20
-10
lines changed

9 files changed

+20
-10
lines changed

.evergreen/generated_configs/functions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ functions:
145145
- MONGODB_API_VERSION
146146
- REQUIRE_API_VERSION
147147
- DEBUG_LOG
148+
- DISABLE_FLAKY
148149
- ORCHESTRATION_FILE
149150
- OCSP_SERVER_TYPE
150151
- VERSION

.evergreen/scripts/generate_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,7 @@ def create_run_tests_func():
10841084
"MONGODB_API_VERSION",
10851085
"REQUIRE_API_VERSION",
10861086
"DEBUG_LOG",
1087+
"DISABLE_FLAKY",
10871088
"ORCHESTRATION_FILE",
10881089
"OCSP_SERVER_TYPE",
10891090
"VERSION",

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ We have a custom `flaky` decorator in [test/asynchronous/utils.py](test/asynchro
410410
tests that are `flaky`. By default the decorator only applies when not running on CPython on Linux, since other
411411
runtimes tend to have more variation. When using the `flaky` decorator, open a corresponding ticket and
412412
a use the ticket number as the "reason" parameter to the decorator, e.g. `@flaky(reason="PYTHON-1234")`.
413+
When running tests locally (not in CI), the `flaky` decorator will be disabled unless `ENABLE_FLAKY` is set.
414+
To disable the `flaky` decorator in CI, you can use `evergreen patch --param DISABLE_FLAKY=1`.
413415

414416
## Specification Tests
415417

test/asynchronous/test_client_bulk_write.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ async def asyncSetUp(self):
629629
@async_client_context.require_failCommand_fail_point
630630
@flaky(reason="PYTHON-5290", max_runs=3, affects_cpython_linux=True)
631631
async def test_timeout_in_multi_batch_bulk_write(self):
632-
if sys.platform != "linux":
632+
if sys.platform != "linux" and "CI" in os.environ:
633633
self.skipTest("PYTHON-3522 CSOT test runs too slow on Windows and MacOS")
634634
_OVERHEAD = 500
635635

test/asynchronous/unified_format.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,17 +536,17 @@ def maybe_skip_test(self, spec):
536536
slow_pypy = [
537537
"timeoutMS applies to whole operation.*",
538538
]
539-
if sys.platform == "win32" and "gridfs" in class_name:
539+
if "CI" in os.environ and sys.platform == "win32" and "gridfs" in class_name:
540540
self.skipTest("PYTHON-3522 CSOT GridFS test runs too slow on Windows")
541-
if sys.platform == "win32":
541+
if "CI" in os.environ and sys.platform == "win32":
542542
for pat in slow_win32:
543543
if re.match(pat.lower(), description):
544544
self.skipTest("PYTHON-3522 CSOT test runs too slow on Windows")
545-
if sys.platform == "darwin":
545+
if "CI" in os.environ and sys.platform == "darwin":
546546
for pat in slow_macos:
547547
if re.match(pat.lower(), description):
548548
self.skipTest("PYTHON-3522 CSOT test runs too slow on MacOS")
549-
if sys.implementation.name.lower() == "pypy":
549+
if "CI" in os.environ and sys.implementation.name.lower() == "pypy":
550550
for pat in slow_pypy:
551551
if re.match(pat.lower(), description):
552552
self.skipTest("PYTHON-3522 CSOT test runs too slow on PyPy")

test/asynchronous/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ def flaky(
183183
raise ValueError("flaky requires a reason input")
184184
is_cpython_linux = sys.platform == "linux" and sys.implementation.name == "cpython"
185185
disable_flaky = "DISABLE_FLAKY" in os.environ
186+
if "CI" not in os.environ and "ENABLE_FLAKY" not in os.environ:
187+
disable_flaky = True
188+
186189
if disable_flaky or (is_cpython_linux and not affects_cpython_linux):
187190
max_runs = 1
188191
min_passes = 1

test/test_client_bulk_write.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ def setUp(self):
625625
@client_context.require_failCommand_fail_point
626626
@flaky(reason="PYTHON-5290", max_runs=3, affects_cpython_linux=True)
627627
def test_timeout_in_multi_batch_bulk_write(self):
628-
if sys.platform != "linux":
628+
if sys.platform != "linux" and "CI" in os.environ:
629629
self.skipTest("PYTHON-3522 CSOT test runs too slow on Windows and MacOS")
630630
_OVERHEAD = 500
631631

test/unified_format.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,17 +535,17 @@ def maybe_skip_test(self, spec):
535535
slow_pypy = [
536536
"timeoutMS applies to whole operation.*",
537537
]
538-
if sys.platform == "win32" and "gridfs" in class_name:
538+
if "CI" in os.environ and sys.platform == "win32" and "gridfs" in class_name:
539539
self.skipTest("PYTHON-3522 CSOT GridFS test runs too slow on Windows")
540-
if sys.platform == "win32":
540+
if "CI" in os.environ and sys.platform == "win32":
541541
for pat in slow_win32:
542542
if re.match(pat.lower(), description):
543543
self.skipTest("PYTHON-3522 CSOT test runs too slow on Windows")
544-
if sys.platform == "darwin":
544+
if "CI" in os.environ and sys.platform == "darwin":
545545
for pat in slow_macos:
546546
if re.match(pat.lower(), description):
547547
self.skipTest("PYTHON-3522 CSOT test runs too slow on MacOS")
548-
if sys.implementation.name.lower() == "pypy":
548+
if "CI" in os.environ and sys.implementation.name.lower() == "pypy":
549549
for pat in slow_pypy:
550550
if re.match(pat.lower(), description):
551551
self.skipTest("PYTHON-3522 CSOT test runs too slow on PyPy")

test/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ def flaky(
181181
raise ValueError("flaky requires a reason input")
182182
is_cpython_linux = sys.platform == "linux" and sys.implementation.name == "cpython"
183183
disable_flaky = "DISABLE_FLAKY" in os.environ
184+
if "CI" not in os.environ and "ENABLE_FLAKY" not in os.environ:
185+
disable_flaky = True
186+
184187
if disable_flaky or (is_cpython_linux and not affects_cpython_linux):
185188
max_runs = 1
186189
min_passes = 1

0 commit comments

Comments
 (0)