mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-06-14 22:17:34 +08:00
Take the list of arches for -build Koji tag from buildrequired modules.
Currently, we are using just `conf.arches` and `conf.base_module_arches` to define the list of arches for which the RPMs in a submitted module are built. This is not enough, because RCM needs to generate modules based on the base modules which should use different arches. This commit changes the MBS to take the list of arches from the buildrequired module build. It checks the buildrequires for "privileged" module or base module and if it finds such module, it queries the Koji to find out the list of arches to set for the module. The "privileged" module is a module which can override base module arches or disttag. Previously, these modules have been defined by `allowed_disttag_marking_module_names` config option. In this commit, this has been renamed to `allowed_privileged_module_names`. The list of arches are stored per module build in new table represented by ModuleArch class and are m:n mapped to ModuleBuild.
This commit is contained in:
@@ -311,6 +311,40 @@ class TestUtils:
|
||||
def teardown_method(self, test_method):
|
||||
clean_database()
|
||||
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.KojiClientSession")
|
||||
def test_get_build_arches(self, ClientSession):
|
||||
session = ClientSession.return_value
|
||||
session.getTag.return_value = {"arches": "ppc64le"}
|
||||
mmd = load_mmd_file(path.join(BASE_DIR, "..", "staged_data", "formatted_testmodule.yaml"))
|
||||
r = module_build_service.utils.get_build_arches(mmd, conf)
|
||||
assert r == ["ppc64le"]
|
||||
|
||||
@patch(
|
||||
"module_build_service.config.Config.allowed_privileged_module_names",
|
||||
new_callable=mock.PropertyMock,
|
||||
return_value=["testmodule"],
|
||||
)
|
||||
def test_get_build_arches_koji_tag_arches(self, cfg):
|
||||
mmd = load_mmd_file(path.join(BASE_DIR, "..", "staged_data", "formatted_testmodule.yaml"))
|
||||
xmd = mmd.get_xmd()
|
||||
xmd["mbs"]["koji_tag_arches"] = ["ppc64", "ppc64le"]
|
||||
mmd.set_xmd(xmd)
|
||||
|
||||
r = module_build_service.utils.get_build_arches(mmd, conf)
|
||||
assert r == ["ppc64", "ppc64le"]
|
||||
|
||||
@patch.object(conf, "base_module_arches", new={"platform:xx": ["x86_64", "i686"]})
|
||||
def test_get_build_arches_base_module_override(self):
|
||||
mmd = load_mmd_file(path.join(BASE_DIR, "..", "staged_data", "formatted_testmodule.yaml"))
|
||||
xmd = mmd.get_xmd()
|
||||
mbs_options = xmd["mbs"] if "mbs" in xmd.keys() else {}
|
||||
mbs_options["buildrequires"] = {"platform": {"stream": "xx"}}
|
||||
xmd["mbs"] = mbs_options
|
||||
mmd.set_xmd(xmd)
|
||||
|
||||
r = module_build_service.utils.get_build_arches(mmd, conf)
|
||||
assert r == ["x86_64", "i686"]
|
||||
|
||||
@pytest.mark.parametrize("context", ["c1", None])
|
||||
def test_import_mmd_contexts(self, context):
|
||||
mmd = load_mmd_file(path.join(BASE_DIR, "..", "staged_data", "formatted_testmodule.yaml"))
|
||||
@@ -425,13 +459,13 @@ class TestUtils:
|
||||
assert release == "module+fedora28+2+814cfa39"
|
||||
|
||||
@patch(
|
||||
"module_build_service.config.Config.allowed_disttag_marking_module_names",
|
||||
"module_build_service.config.Config.allowed_privileged_module_names",
|
||||
new_callable=mock.PropertyMock,
|
||||
return_value=["build"],
|
||||
)
|
||||
def test_get_rpm_release_metadata_br_stream_override(self, mock_admmn):
|
||||
"""
|
||||
Test that when a module buildrequires a module in conf.allowed_disttag_marking_module_names,
|
||||
Test that when a module buildrequires a module in conf.allowed_privileged_module_names,
|
||||
and that module has the xmd.mbs.disttag_marking field set, it should influence the disttag.
|
||||
"""
|
||||
scheduler_init_data(1)
|
||||
@@ -477,6 +511,17 @@ class TestUtils:
|
||||
release = module_build_service.utils.get_rpm_release(build_one)
|
||||
assert release == "scrmod+f28+2+814cfa39"
|
||||
|
||||
@patch("module_build_service.utils.submit.get_build_arches")
|
||||
def test_record_module_build_arches(self, get_build_arches):
|
||||
get_build_arches.return_value = ["x86_64", "i686"]
|
||||
scheduler_init_data(1)
|
||||
build = models.ModuleBuild.query.get(2)
|
||||
build.arches = []
|
||||
module_build_service.utils.record_module_build_arches(build.mmd(), build, db.session)
|
||||
|
||||
arches = set([arch.name for arch in build.arches])
|
||||
assert arches == set(get_build_arches.return_value)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"scmurl",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user