diff --git a/release/ray_release/scripts/ray_bisect.py b/release/ray_release/scripts/ray_bisect.py index 65ef1ac75bff..9f17f2cb076a 100644 --- a/release/ray_release/scripts/ray_bisect.py +++ b/release/ray_release/scripts/ray_bisect.py @@ -32,8 +32,7 @@ def main(test_name: str, passing_commit: str, failing_commit: str) -> None: logger.info(f"Blamed commit found for test {test_name}: {blamed_commit}") -def _bisect(test_name: str, commit_list: List[str]) -> str: - test = _get_test(test_name) +def _bisect(test: Test, commit_list: List[str]) -> str: while len(commit_list) > 2: logger.info( f"Bisecting between {len(commit_list)} commits: " diff --git a/release/ray_release/tests/test_bisect.py b/release/ray_release/tests/test_bisect.py index 397179792ad6..1a7fe46ec8bc 100644 --- a/release/ray_release/tests/test_bisect.py +++ b/release/ray_release/tests/test_bisect.py @@ -1,19 +1,20 @@ from unittest import mock from typing import List, Dict from ray_release.scripts.ray_bisect import _bisect +from ray_release.config import Test def test_bisect(): test_cases = { "c3": { - "c0": True, - "c1": True, - "c3": False, - "c4": False, + "c0": "passed", + "c1": "passed", + "c3": "hard_failed", + "c4": "soft_failed", }, "c1": { - "c0": True, - "c1": False, + "c0": "passed", + "c1": "hard_failed", }, } @@ -43,66 +44,8 @@ def test_bisect(): def _mock_run_test(test_name: str, commit: str) -> bool: return commit_to_test_result[commit] - with mock.patch( - "ray_release.scripts.ray_bisect._run_test", - side_effect=_mock_run_test, - ): - blamed_commit = _bisect("test", list(commit_to_test_result.keys())) - assert blamed_commit == "c3" - -def test_bisect(): - commit_to_test_result = { - "c0": True, - "c1": True, - "c2": True, - "c3": False, - "c4": False, - } - - def _mock_run_test(test_name: str, commit: str) -> bool: - return commit_to_test_result[commit] - - with mock.patch( - "ray_release.scripts.ray_bisect._run_test", - side_effect=_mock_run_test, - ): - blamed_commit = _bisect("test", list(commit_to_test_result.keys())) - assert blamed_commit == "c3" - -def test_bisect(): - commit_to_test_result = { - "c0": True, - "c1": True, - "c2": True, - "c3": False, - "c4": False, - } - - def _mock_run_test(test_name: str, commit: str) -> bool: - return commit_to_test_result[commit] - - with mock.patch( - "ray_release.scripts.ray_bisect._run_test", - side_effect=_mock_run_test, - ): - blamed_commit = _bisect("test", list(commit_to_test_result.keys())) - assert blamed_commit == "c3" - -def test_bisect(): - commit_to_test_result = { - "c0": "passed", - "c1": "passed", - "c2": "passed", - "c3": "hard_failed", - "c4": "soft_failed", - } - - def _mock_run_test(test_name: str, commit: List[str]) -> Dict[str, str]: - return commit_to_test_result - - with mock.patch( - "ray_release.scripts.ray_bisect._run_test", - side_effect=_mock_run_test, - ): - blamed_commit = _bisect({}, list(commit_to_test_result.keys())) - assert blamed_commit == "c3" + with mock.patch( + "ray_release.scripts.ray_bisect._run_test", + side_effect=_mock_run_test, + ): + assert _bisect({}, list(input.keys())) == output