Use repo id instead of latest symlink

Fixes https://pagure.io/fm-orchestrator/issue/1581
This commit is contained in:
Brendan Reilly
2020-03-05 15:05:15 -05:00
parent 25cdfbbd22
commit e68f5c4c26
2 changed files with 16 additions and 3 deletions

View File

@@ -765,7 +765,9 @@ class KojiModuleBuilder(GenericBuilder):
Returns URL of repository containing the built artifacts for
the tag with particular name and architecture.
"""
return "%s/%s/latest/%s" % (config.koji_repository_url, tag_name, arch)
koji_session = get_session(conf, login=False)
repo_info = koji_session.getRepo(tag_name)
return "%s/%s/%s/%s" % (config.koji_repository_url, tag_name, str(repo_info['id']), arch)
@validate_koji_tag("tag", post="")
def _get_tag(self, tag, strict=True):

View File

@@ -107,16 +107,19 @@ class TestKojiBuilder:
self.p_read_config.stop()
events.scheduler.reset()
def test_tag_to_repo(self):
@patch("koji.ClientSession")
def test_tag_to_repo(self, ClientSession):
""" Test that when a repo msg hits us and we have no match,
that we do nothing gracefully.
"""
session = ClientSession.return_value
session.getRepo.return_value = {"id": 1234}
repo = GenericBuilder.tag_to_repo(
"koji", self.config, "module-base-runtime-0.25-9", "x86_64"
)
assert repo == (
"https://kojipkgs.stg.fedoraproject.org/repos"
"/module-base-runtime-0.25-9/latest/x86_64"
"/module-base-runtime-0.25-9/1234/x86_64"
)
def test_recover_orphaned_artifact_when_tagged(self, mock_get_session):
@@ -909,6 +912,14 @@ class TestKojiBuilder:
builder = KojiModuleBuilder(db_session, "owner", module_build, conf, "module-tag", [])
builder.koji_session.krb_login.assert_called_once()
@patch("koji.ClientSession")
def test_repo_from_tag(self, ClientSession):
repo = "https://kojipkgs.stg.fedoraproject.org/repos/tagname/1234/arch"
session = ClientSession.return_value
session.getRepo.return_value = {"id": 1234}
ret = GenericBuilder.backends['koji'].repo_from_tag(self.config, 'tagname', 'arch')
assert ret == repo
@patch("koji.ClientSession")
def test_get_module_build_arches(self, ClientSession):
module_build = module_build_service.common.models.ModuleBuild.get_by_id(db_session, 2)