Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Make sure all rhcos arch builds are complete (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegreyd committed Nov 30, 2022
1 parent cbb6a2f commit 30c8f14
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
16 changes: 13 additions & 3 deletions doozerlib/rhcos.py
Expand Up @@ -167,9 +167,19 @@ def _latest_rhcos_build_id(self) -> Optional[str]:

if not data["builds"]:
return None
build = data["builds"][0]
# old schema just had the id as a string; newer has it in a dict
return build if isinstance(build, str) else build["id"]

multi_url = self.runtime.group_config.urls.rhcos_release_base["multi"]
build_id = None
if multi_url:
# Make sure all rhcos arch builds are complete
arches_building = self.runtime.group_config.arches
for b in data["builds"]:
if len(b["arches"]) == len(arches_building):
build_id = b["id"]
break
else:
build_id = data["builds"][0]["id"]
return build_id

@retry(reraise=True, stop=stop_after_attempt(10), wait=wait_fixed(3))
def rhcos_build_meta(self, build_id: str, meta_type: str = "meta") -> Dict:
Expand Down
11 changes: 10 additions & 1 deletion tests/test_rhcos.py
Expand Up @@ -69,14 +69,23 @@ def test_release_url(self):

@patch('urllib.request.urlopen')
def test_build_id(self, mock_urlopen):
_urlopen_json_cm(mock_urlopen, dict(builds=['id-1', 'id-2']))
builds = [{'id': 'id-1'}, {'id': 'id-2'}]
_urlopen_json_cm(mock_urlopen, dict(builds=builds))
self.assertEqual('id-1', rhcos.RHCOSBuildFinder(self.runtime, "4.4")._latest_rhcos_build_id())
self.assertIn('/rhcos-4.4/', mock_urlopen.call_args_list[0][0][0])

_urlopen_json_cm(mock_urlopen, dict(builds=[]))
self.assertIsNone(rhcos.RHCOSBuildFinder(self.runtime, "4.2", "ppc64le")._latest_rhcos_build_id())
self.assertIn('/rhcos-4.2-ppc64le/', mock_urlopen.call_args_list[1][0][0])

@patch('urllib.request.urlopen')
def test_build_id_multi(self, mock_urlopen):
builds = [{'id': 'id-1', 'arches': ['arch1', 'arch2']}, {'id': 'id-2', 'arches': ['arch1', 'arch2', 'arch3']}]
_urlopen_json_cm(mock_urlopen, dict(builds=builds))
self.runtime.group_config.urls = Model(dict(rhcos_release_base=dict(multi='some_url')))
self.runtime.group_config.arches = ['arch1', 'arch2', 'arch3']
self.assertEqual('id-2', rhcos.RHCOSBuildFinder(self.runtime, "4.4")._latest_rhcos_build_id())

@patch('urllib.request.urlopen')
def test_build_find_failure(self, mock_urlopen):
mock_urlopen.side_effect = URLError("test")
Expand Down

0 comments on commit 30c8f14

Please sign in to comment.