Skip to content

Commit

Permalink
Fix TestTestingFarmUtil.test_fetch_failed_test_cases_from_file
Browse files Browse the repository at this point in the history
`TestingFarmRequest` now can be put into test-mode which allows to fetch
failed test cases from file rather than URL.

Fixes #632
  • Loading branch information
kwk committed Aug 7, 2024
1 parent 5bd544b commit f495da9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
47 changes: 38 additions & 9 deletions snapshot_manager/snapshot_manager/testing_farm_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"<!--TESTING_FARM:([^/]+)/([^/]+)(/([^/]+))?-->", string)
if not matches:
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions snapshot_manager/tests/testing_farm_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit f495da9

Please sign in to comment.