Skip to content

Commit fa92e8f

Browse files
committed
Randomize test order each run
[sc-46860]
1 parent a8c16b7 commit fa92e8f

File tree

6 files changed

+12
-3
lines changed

6 files changed

+12
-3
lines changed

compute_endpoint/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"coverage>=5.2",
5252
"pytest-mock==3.2.0",
5353
"pyfakefs<5.9.2", # 5.9.2 (Jul 30, 2025), breaks us; retry after 6.0.0 lands?
54+
"pytest-random-order",
5455
]
5556

5657

compute_endpoint/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extras = test
1010
usedevelop = true
1111
commands =
1212
coverage erase
13-
coverage run -m pytest --durations 5 --log-cli-level=ERROR {posargs}
13+
coverage run -m pytest --random-order --durations 5 --log-cli-level=ERROR {posargs}
1414
coverage report
1515

1616
[testenv:mypy]

compute_sdk/globus_compute_sdk/sdk/executor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,7 @@ def run(self):
14511451

14521452
def shutdown(self, wait=True, *, cancel_futures=False):
14531453
if not self.is_alive():
1454+
_RESULT_WATCHERS.pop(self.task_group_id, None)
14541455
return
14551456

14561457
self._closed = True # No more futures will be accepted

compute_sdk/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"flake8==3.8.0",
3737
"pytest>=7.2",
3838
"pytest-mock",
39+
"pytest-random-order",
3940
"pyfakefs",
4041
"coverage",
4142
# easy mocking of the `requests` library

compute_sdk/tests/unit/test_executor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def __init__(self, *args, **kwargs):
6969
}
7070
kwargs.setdefault("client", mock_client)
7171
super().__init__(*args, **kwargs)
72-
Executor._default_task_group_id = None # Reset for each test
7372
self._test_task_submitter_exception: t.Type[Exception] | None = None
7473
self._test_task_submitter_done = False
7574

@@ -112,6 +111,11 @@ def join(self, timeout: float | None = None) -> None:
112111
super().join(timeout=timeout)
113112

114113

114+
@pytest.fixture(autouse=True)
115+
def reset_default_executor_id():
116+
Executor._default_task_group_id = None # Reset for each test
117+
118+
115119
@pytest.fixture
116120
def mock_result_watcher(mocker: MockerFixture):
117121
rw = mocker.patch(f"{_MOCK_BASE}_ResultWatcher", autospec=True)
@@ -1581,6 +1585,7 @@ def test_resultwatcher_onmessage_verifies_result_type(mocker, unpacked):
15811585
mrw._on_message(mock_channel, mock_deliver, mock_props, b"some_bytes")
15821586
mock_channel.basic_nack.assert_called()
15831587
assert not mrw._received_results
1588+
mrw.shutdown()
15841589

15851590

15861591
def test_resultwatcher_onmessage_sets_check_results_flag():
@@ -1594,6 +1599,7 @@ def test_resultwatcher_onmessage_sets_check_results_flag():
15941599
mock_channel.basic_nack.assert_not_called()
15951600
assert mrw._received_results
15961601
assert mrw._time_to_check_results.is_set()
1602+
mrw.shutdown()
15971603

15981604

15991605
@pytest.mark.parametrize("exc", (MemoryError("some description"), "some description"))

compute_sdk/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ usedevelop = true
99
extras = test
1010
commands =
1111
coverage erase
12-
coverage run -m pytest --durations 5 {posargs}
12+
coverage run -m pytest --durations 5 --random-order {posargs}
1313
coverage report --skip-covered
1414

1515
[testenv:mypy]

0 commit comments

Comments
 (0)