Skip to content

Commit a3465e9

Browse files
committed
retrying the tests because they're flakey
1 parent c454ade commit a3465e9

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

test/asynchronous/unified_format.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
NotPrimaryError,
8888
OperationFailure,
8989
PyMongoError,
90+
_OperationCancelled,
9091
)
9192
from pymongo.monitoring import (
9293
CommandStartedEvent,
@@ -1388,17 +1389,20 @@ async def run_scenario(self, spec, uri=None):
13881389
# operations during test set up and tear down.
13891390
await self.kill_all_sessions()
13901391

1391-
if "csot" in self.id().lower():
1392+
if "csot" in self.id().lower() or "discovery_and_monitoring" in self.id().lower():
13921393
# Retry CSOT tests up to 2 times to deal with flakey tests.
1394+
# discovery_and_monitoring tests on windows are also flakey
13931395
attempts = 3
13941396
for i in range(attempts):
13951397
try:
13961398
return await self._run_scenario(spec, uri)
1397-
except (AssertionError, OperationFailure) as exc:
1399+
except (AssertionError, OperationFailure, _OperationCancelled) as exc:
13981400
if isinstance(exc, OperationFailure) and (
13991401
_IS_SYNC or "failpoint" not in exc._message
14001402
):
14011403
raise
1404+
if isinstance(exc, _OperationCancelled) and _IS_SYNC:
1405+
raise
14021406
if i < attempts - 1:
14031407
print(
14041408
f"Retrying after attempt {i+1} of {self.id()} failed with:\n"

test/unified_format.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
NotPrimaryError,
8080
OperationFailure,
8181
PyMongoError,
82+
_OperationCancelled,
8283
)
8384
from pymongo.monitoring import (
8485
CommandStartedEvent,
@@ -1375,17 +1376,20 @@ def run_scenario(self, spec, uri=None):
13751376
# operations during test set up and tear down.
13761377
self.kill_all_sessions()
13771378

1378-
if "csot" in self.id().lower():
1379+
if "csot" in self.id().lower() or "discovery_and_monitoring" in self.id().lower():
13791380
# Retry CSOT tests up to 2 times to deal with flakey tests.
1381+
# discovery_and_monitoring tests on windows are also flakey
13801382
attempts = 3
13811383
for i in range(attempts):
13821384
try:
13831385
return self._run_scenario(spec, uri)
1384-
except (AssertionError, OperationFailure) as exc:
1386+
except (AssertionError, OperationFailure, _OperationCancelled) as exc:
13851387
if isinstance(exc, OperationFailure) and (
13861388
_IS_SYNC or "failpoint" not in exc._message
13871389
):
13881390
raise
1391+
if isinstance(exc, _OperationCancelled) and _IS_SYNC:
1392+
raise
13891393
if i < attempts - 1:
13901394
print(
13911395
f"Retrying after attempt {i+1} of {self.id()} failed with:\n"

0 commit comments

Comments
 (0)