mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-02 20:59:06 +08:00
PR#1717: Fail if requested side tag is not available for any base modules.
Merges #1717 https://pagure.io/fm-orchestrator/pull-request/1717
This commit is contained in:
@@ -280,6 +280,7 @@ class DBResolver(GenericResolver):
|
||||
", ".join([name, stream, str(version), context]), strict)
|
||||
)
|
||||
|
||||
module_build = None
|
||||
module_tags = {}
|
||||
if mmd:
|
||||
queried_mmd = mmd
|
||||
@@ -290,14 +291,14 @@ class DBResolver(GenericResolver):
|
||||
mmd.get_context() or models.DEFAULT_MODULE_CONTEXT,
|
||||
])
|
||||
else:
|
||||
build = models.ModuleBuild.get_build_from_nsvc(
|
||||
module_build = models.ModuleBuild.get_build_from_nsvc(
|
||||
self.db_session, name, stream, version, context)
|
||||
if not build:
|
||||
if not module_build:
|
||||
raise UnprocessableEntity(
|
||||
"The module {} was not found".format(
|
||||
":".join([name, stream, version, context]))
|
||||
)
|
||||
queried_mmd = build.mmd()
|
||||
queried_mmd = module_build.mmd()
|
||||
nsvc = ":".join([name, stream, version, context])
|
||||
|
||||
xmd_mbs = queried_mmd.get_xmd().get("mbs", {})
|
||||
@@ -309,6 +310,7 @@ class DBResolver(GenericResolver):
|
||||
|
||||
buildrequires = xmd_mbs["buildrequires"]
|
||||
side_tag = xmd_mbs.get("side_tag")
|
||||
side_tag_brs_found = []
|
||||
for br_name, details in buildrequires.items():
|
||||
build = models.ModuleBuild.get_build_from_nsvc(
|
||||
self.db_session,
|
||||
@@ -328,6 +330,7 @@ class DBResolver(GenericResolver):
|
||||
side_tag_format = build.mmd().get_xmd().get("mbs", {}).get("koji_side_tag_format")
|
||||
if side_tag_format:
|
||||
koji_tag = side_tag_format.format(side_tag=side_tag)
|
||||
side_tag_brs_found.append(side_tag_format)
|
||||
log.info("Using side tag for base module %s: %s", br_name, koji_tag)
|
||||
else:
|
||||
log.warning("Side tag requested, but base module %s lacks koji_side_tag_format"
|
||||
@@ -340,6 +343,11 @@ class DBResolver(GenericResolver):
|
||||
module_tags.setdefault(koji_tag, [])
|
||||
module_tags[koji_tag].append(build.mmd())
|
||||
|
||||
if side_tag and not side_tag_brs_found:
|
||||
msg = "None of the buildrequired base modules are configured for side tags."
|
||||
if module_build:
|
||||
module_build.log_message(self.db_session, msg)
|
||||
raise RuntimeError(msg)
|
||||
return module_tags
|
||||
|
||||
def resolve_requires(self, requires):
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import logging
|
||||
|
||||
from datetime import datetime
|
||||
from mock import patch, PropertyMock
|
||||
@@ -19,6 +20,9 @@ from module_build_service.scheduler.db_session import db_session
|
||||
import tests
|
||||
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestDBModule:
|
||||
|
||||
def test_get_buildrequired_modulemds(self):
|
||||
@@ -101,7 +105,7 @@ class TestDBModule:
|
||||
|
||||
@pytest.mark.parametrize("missing_format", [False, True])
|
||||
def test_get_module_build_dependencies_side_tag(
|
||||
self, missing_format, reuse_component_init_data):
|
||||
self, missing_format, reuse_component_init_data, caplog):
|
||||
"""
|
||||
Test that we get the correct base module tag when a side tag is specified
|
||||
"""
|
||||
@@ -123,8 +127,19 @@ class TestDBModule:
|
||||
db_session.commit()
|
||||
expected = {"module-f28-build"}
|
||||
resolver = mbs_resolver.GenericResolver.create(db_session, conf, backend="db")
|
||||
result = resolver.get_module_build_dependencies(mmd=mmd).keys()
|
||||
assert set(result) == expected
|
||||
if missing_format:
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
result = resolver.get_module_build_dependencies(mmd=mmd).keys()
|
||||
assert set(result) == expected
|
||||
msg = "None of the buildrequired base modules are configured for side tags"
|
||||
assert msg in str(excinfo.value)
|
||||
assert (
|
||||
'Side tag requested, but base module platform lacks koji_side_tag_format value' in
|
||||
caplog.text
|
||||
)
|
||||
else:
|
||||
result = resolver.get_module_build_dependencies(mmd=mmd).keys()
|
||||
assert set(result) == expected
|
||||
|
||||
def test_get_module_build_dependencies_recursive(self, reuse_component_init_data):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user