mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 11:48:33 +08:00
Merge #1458 Only use default modules that were built with the same base module
This commit is contained in:
@@ -84,22 +84,23 @@ def add_default_modules(db_session, mmd, arches):
|
||||
)
|
||||
continue
|
||||
|
||||
try:
|
||||
# We are reusing resolve_requires instead of directly querying the database since it
|
||||
# provides the exact format that is needed for mbs.xmd.buildrequires.
|
||||
#
|
||||
# Only one default module is processed at a time in resolve_requires so that we
|
||||
# are aware of which modules are not in the database, and can add those that are as
|
||||
# buildrequires.
|
||||
resolver = GenericResolver.create(db_session, conf)
|
||||
resolved = resolver.resolve_requires([ns])
|
||||
except UnprocessableEntity:
|
||||
# Query for the latest default module that was built against this base module
|
||||
resolver = GenericResolver.create(db_session, conf)
|
||||
default_module_mmds = resolver.get_buildrequired_modulemds(name, stream, bm_mmd)
|
||||
if not default_module_mmds:
|
||||
log.warning(
|
||||
"The default module %s from %s is not in the database and couldn't be added as "
|
||||
"a buildrequire",
|
||||
ns, bm_nsvc,
|
||||
)
|
||||
continue
|
||||
# Since a default module entry only has the name and stream, there's no way to know
|
||||
# which context to pick from if multiple are present. In this case, just pick the first
|
||||
# one, which is the latest version but potentially a random context.
|
||||
default_module_mmd = default_module_mmds[0]
|
||||
# Use resolve_requires since it provides the exact format that is needed for
|
||||
# mbs.xmd.buildrequires
|
||||
resolved = resolver.resolve_requires([default_module_mmd.get_nsvc()])
|
||||
|
||||
nsvc = ":".join([name, stream, resolved[name]["version"], resolved[name]["context"]])
|
||||
log.info("Adding the default module %s as a buildrequire", nsvc)
|
||||
|
||||
@@ -21,8 +21,6 @@ def test_add_default_modules(mock_get_dm, mock_hc, db_session):
|
||||
Test that default modules present in the database are added, and the others are ignored.
|
||||
"""
|
||||
clean_database()
|
||||
make_module_in_db("python:3:12345:1", db_session=db_session)
|
||||
make_module_in_db("nodejs:11:2345:2", db_session=db_session)
|
||||
mmd = load_mmd(read_staged_data("formatted_testmodule.yaml"))
|
||||
xmd_brs = mmd.get_xmd()["mbs"]["buildrequires"]
|
||||
assert set(xmd_brs.keys()) == {"platform"}
|
||||
@@ -40,6 +38,9 @@ def test_add_default_modules(mock_get_dm, mock_hc, db_session):
|
||||
platform_xmd["mbs"]["use_default_modules"] = True
|
||||
platform_mmd.set_xmd(platform_xmd)
|
||||
platform.modulemd = mmd_to_str(platform_mmd)
|
||||
|
||||
make_module_in_db("python:3:12345:1", base_module=platform, db_session=db_session)
|
||||
make_module_in_db("nodejs:11:2345:2", base_module=platform, db_session=db_session)
|
||||
db_session.commit()
|
||||
|
||||
mock_get_dm.return_value = {
|
||||
|
||||
Reference in New Issue
Block a user