From 5d8b9af3b0f7e861678ef7825390c44eb2afde23 Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Wed, 7 Aug 2024 16:36:37 +0200 Subject: [PATCH] Fix TestTestingFarmUtil.test_fetch_failed_test_cases_from_file (#634) `TestingFarmRequest` now can be put into test-mode which allows to fetch failed test cases from file rather than URL. Fixes #632 --- .../snapshot_manager/testing_farm_util.py | 47 +++++++++++++++---- ...t_1f25b0df-71f1-4a13-a4b8-c066f6f5f116.txt | 4 ++ .../tests/testing_farm_util_test.py | 1 + 3 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 snapshot_manager/tests/testing-farm-logs/output_1f25b0df-71f1-4a13-a4b8-c066f6f5f116.txt diff --git a/snapshot_manager/snapshot_manager/testing_farm_util.py b/snapshot_manager/snapshot_manager/testing_farm_util.py index 0108f31d..a4c2ecc6 100644 --- a/snapshot_manager/snapshot_manager/testing_farm_util.py +++ b/snapshot_manager/snapshot_manager/testing_farm_util.py @@ -42,6 +42,12 @@ class TestingFarmRequest: ) copr_build_ids_pattern: ClassVar[str] = r"(\d,)*\d" + _in_test_mode: bool = False + """When this mode is on, we can workaround certain restrictions for fetching + outdated URLs for example.""" + + _dirname: str = pathlib.Path(os.path.dirname(__file__)) + @property def are_build_ids_still_valid(self, copr_build_ids: list[int]) -> bool: """Returns True if the given copr builds are the same as the ones @@ -110,14 +116,30 @@ def parse(cls, string: str) -> dict[str, "TestingFarmRequest"]: >>> keys = requests.keys() >>> keys dict_keys(['fedora-rawhide-x86_64', 'fedora-39-x86_64', 'fedora-40-x86_64', 'fedora-38-x86_64']) - >>> requests['fedora-rawhide-x86_64'] - TestingFarmRequest(request_id=UUID('271a79e8-fc9a-4e1d-95fe-567cc9d62ad4'), chroot='fedora-rawhide-x86_64', copr_build_ids=[1, 2, 3]) - >>> requests['fedora-39-x86_64'] - TestingFarmRequest(request_id=UUID('22222222-fc9a-4e1d-95fe-567cc9d62ad4'), chroot='fedora-39-x86_64', copr_build_ids=[5, 6, 7]) - >>> requests['fedora-40-x86_64'] - TestingFarmRequest(request_id=UUID('33333333-fc9a-4e1d-95fe-567cc9d62ad4'), chroot='fedora-40-x86_64', copr_build_ids=[12, 13, 14]) - >>> requests['fedora-38-x86_64'] - TestingFarmRequest(request_id=UUID('44444444-fc9a-4e1d-95fe-567cc9d62ad4'), chroot='fedora-38-x86_64', copr_build_ids=[]) + >>> requests['fedora-rawhide-x86_64'].request_id + UUID('271a79e8-fc9a-4e1d-95fe-567cc9d62ad4') + >>> requests['fedora-rawhide-x86_64'].chroot + 'fedora-rawhide-x86_64' + >>> requests['fedora-rawhide-x86_64'].copr_build_ids + [1, 2, 3] + >>> requests['fedora-39-x86_64'].request_id + UUID('22222222-fc9a-4e1d-95fe-567cc9d62ad4') + >>> requests['fedora-39-x86_64'].chroot + 'fedora-39-x86_64' + >>> requests['fedora-39-x86_64'].copr_build_ids + [5, 6, 7] + >>> requests['fedora-40-x86_64'].request_id + UUID('33333333-fc9a-4e1d-95fe-567cc9d62ad4') + >>> requests['fedora-40-x86_64'].chroot + 'fedora-40-x86_64' + >>> requests['fedora-40-x86_64'].copr_build_ids + [12, 13, 14] + >>> requests['fedora-38-x86_64'].request_id + UUID('44444444-fc9a-4e1d-95fe-567cc9d62ad4') + >>> requests['fedora-38-x86_64'].chroot + 'fedora-38-x86_64' + >>> requests['fedora-38-x86_64'].copr_build_ids + [] """ matches = re.findall(r"", string) if not matches: @@ -453,7 +475,14 @@ def get_failed_test_cases_from_xunit_file( './logs/log[@name="testout.log"]' ).get("href") - log_file = util.read_url_response_into_file(log_output_url) + log_file: pathlib.Path + if not self._in_test_mode: + log_file = util.read_url_response_into_file(log_output_url) + else: + p = self._dirname.joinpath( + f"../tests/testing-farm-logs/output_{self.request_id}.txt" + ) + log_file = pathlib.Path(p) tc = FailedTestCase( test_name=failed_testcase.get("name"), log_output_url=log_output_url, diff --git a/snapshot_manager/tests/testing-farm-logs/output_1f25b0df-71f1-4a13-a4b8-c066f6f5f116.txt b/snapshot_manager/tests/testing-farm-logs/output_1f25b0df-71f1-4a13-a4b8-c066f6f5f116.txt new file mode 100644 index 00000000..ff4960f6 --- /dev/null +++ b/snapshot_manager/tests/testing-farm-logs/output_1f25b0df-71f1-4a13-a4b8-c066f6f5f116.txt @@ -0,0 +1,4 @@ ++ clang -m32 -fsanitize=address test.c +/usr/bin/ld: cannot find -lgcc_s: No such file or directory +clang: error: linker command failed with exit code 1 (use -v to see invocation) +Shared connection to 3.12.104.11 closed. diff --git a/snapshot_manager/tests/testing_farm_util_test.py b/snapshot_manager/tests/testing_farm_util_test.py index f0f23bcf..7e8f7c85 100644 --- a/snapshot_manager/tests/testing_farm_util_test.py +++ b/snapshot_manager/tests/testing_farm_util_test.py @@ -13,6 +13,7 @@ def test_fetch_failed_test_cases_from_file(self): request_id=request_id, chroot=chroot, copr_build_ids=[11, 22, 33], + _in_test_mode=True, ) actual = req.get_failed_test_cases_from_xunit_file( xunit_file=self.abspath(f"testing-farm-logs/results_{request_id}.xml"),