mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-02 20:59:06 +08:00
Fixed scratch build suffix bug
When building a scratch build of a module with static context the scratch suffix was added twice. Signed-off-by: Martin Curlej <mcurlej@redhat.com>
This commit is contained in:
committed by
Mike McLean
parent
5cdb2127fe
commit
71a44bdfb6
@@ -707,11 +707,13 @@ def submit_module_build(db_session, username, stream_or_packager, params, module
|
||||
module.build_context, module.runtime_context, module.context, \
|
||||
module.build_context_no_bms = module.contexts_from_mmd(module.modulemd)
|
||||
|
||||
xmd = mmd.get_xmd()
|
||||
if xmd["mbs"].get("static_context"):
|
||||
if static_context:
|
||||
# if the static_context is True we use the context from defined in the mmd
|
||||
# and discard the computed one.
|
||||
module.context = mmd.get_context()
|
||||
|
||||
module.context += context_suffix
|
||||
else:
|
||||
# if the context is defined by MSE, we need to add a context_suffix if it exists.
|
||||
module.context += context_suffix
|
||||
|
||||
if not conf.allow_dashes_in_svc:
|
||||
if '-' in module.stream:
|
||||
@@ -786,10 +788,15 @@ def process_module_context_configuration(stream_or_packager):
|
||||
return streams, static_context
|
||||
else:
|
||||
xmd = stream_or_packager.get_xmd()
|
||||
# check if we are handling rebuild of a static context module
|
||||
|
||||
# check if the static format is defined through `static_context` field
|
||||
if stream_or_packager.is_static_context():
|
||||
static_context = True
|
||||
return [stream_or_packager], static_context
|
||||
|
||||
# check if we are handling rebuild of a static context module defined in xmd
|
||||
if "mbs" in xmd:
|
||||
# check if it is a static context
|
||||
if "static_context" in xmd["mbs"] or stream_or_packager.is_static_context():
|
||||
if "static_context" in xmd["mbs"]:
|
||||
static_context = True
|
||||
return [stream_or_packager], static_context
|
||||
|
||||
|
||||
@@ -25,10 +25,15 @@ from tests import (
|
||||
make_module,
|
||||
read_staged_data,
|
||||
init_data,
|
||||
clean_database,
|
||||
)
|
||||
|
||||
|
||||
class TestSubmit:
|
||||
|
||||
def teardown_method(self, tested_method):
|
||||
clean_database()
|
||||
|
||||
def test_get_prefixed_version_f28(self):
|
||||
scheduler_init_data(1)
|
||||
build_one = models.ModuleBuild.get_by_id(db_session, 2)
|
||||
@@ -144,6 +149,77 @@ class TestSubmit:
|
||||
assert "mbs_options" not in xmd
|
||||
assert xmd["mbs"]["static_context"]
|
||||
|
||||
def test_submit_build_module_scratch_v3_static_context(self):
|
||||
"""
|
||||
Test if the static context in the v3 metadata format will contain the correct suffix
|
||||
during a scratch build
|
||||
"""
|
||||
init_data(multiple_stream_versions=True)
|
||||
yaml_str = read_staged_data("v3/mmd_packager")
|
||||
mmd = load_mmd(yaml_str)
|
||||
ux_timestamp = "1613048427"
|
||||
version = provide_module_stream_version_from_timestamp(ux_timestamp)
|
||||
params = {"scratch": True}
|
||||
|
||||
builds = submit_module_build(db_session, "foo", mmd, params, version)
|
||||
|
||||
assert len(builds) == 2
|
||||
|
||||
expected_contexts = {"CTX1_1": {}, "CTX2_1": {}}
|
||||
|
||||
for build in builds:
|
||||
mmd = build.mmd()
|
||||
context = mmd.get_context()
|
||||
assert context in expected_contexts
|
||||
|
||||
def test_submit_build_module_scratch_v2_static_context(self):
|
||||
"""
|
||||
Test if the static context in the v2 metadata format will contain
|
||||
the correct suffix during a scratch build
|
||||
"""
|
||||
scheduler_init_data(1)
|
||||
yaml_str = read_staged_data("static_context_v2")
|
||||
mmd = load_mmd(yaml_str)
|
||||
ux_timestamp = "1613048427"
|
||||
version = provide_module_stream_version_from_timestamp(ux_timestamp)
|
||||
params = {"scratch": True}
|
||||
|
||||
builds = submit_module_build(db_session, "app", mmd, params, version)
|
||||
|
||||
assert len(builds) == 2
|
||||
|
||||
expected_contexts = {"context1_1": {}, "context2_1": {}}
|
||||
|
||||
for build in builds:
|
||||
mmd = build.mmd()
|
||||
context = mmd.get_context()
|
||||
assert context in expected_contexts
|
||||
|
||||
def test_submit_build_module_scratch_increment(self):
|
||||
"""
|
||||
Test if the context suffix is incremented correctly during a repeated scratch build.
|
||||
"""
|
||||
init_data(multiple_stream_versions=True)
|
||||
yaml_str = read_staged_data("v3/mmd_packager")
|
||||
mmd = load_mmd(yaml_str)
|
||||
ux_timestamp = "1613048427"
|
||||
version = provide_module_stream_version_from_timestamp(ux_timestamp)
|
||||
params = {"scratch": True}
|
||||
|
||||
builds = submit_module_build(db_session, "foo", mmd, params, version)
|
||||
|
||||
assert len(builds) == 2
|
||||
|
||||
builds = submit_module_build(db_session, "foo", mmd, params, version)
|
||||
|
||||
assert len(builds) == 2
|
||||
|
||||
expected_contexts = {"CTX1_2": {}, "CTX2_2": {}}
|
||||
for build in builds:
|
||||
mmd = build.mmd()
|
||||
context = mmd.get_context()
|
||||
assert context in expected_contexts
|
||||
|
||||
|
||||
class TestProcessModuleContextConfiguration:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user