mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-12-01 00:37:08 +08:00
Allow whitelisted buildrequires with xmd.mbs.disttag_marking set to influnece the disttag
This commit is contained in:
@@ -26,3 +26,4 @@ data:
|
||||
commit: virtual
|
||||
requires: {}
|
||||
mse: true
|
||||
disttag_marking: product12
|
||||
|
||||
17
tests/staged_data/build_metadata_module_not_processed.yaml
Normal file
17
tests/staged_data/build_metadata_module_not_processed.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
document: modulemd
|
||||
version: 1
|
||||
data:
|
||||
description: A metadata-only module build for product X
|
||||
name: build
|
||||
license:
|
||||
module: [MIT]
|
||||
stream: product1.2
|
||||
summary: A metadata-only module build for a product X
|
||||
dependencies:
|
||||
buildrequires:
|
||||
platform: f28
|
||||
requires:
|
||||
platform: f28
|
||||
xmd:
|
||||
mbs:
|
||||
disttag_marking: 'product12'
|
||||
@@ -211,7 +211,7 @@ class TestModuleWait:
|
||||
@patch('module_build_service.resolver.DBResolver')
|
||||
@patch('module_build_service.resolver.GenericResolver')
|
||||
@patch("module_build_service.config.Config.base_module_names",
|
||||
new_callable=mock.PropertyMock, return_value=set(["base-runtime", "platform"]))
|
||||
new_callable=mock.PropertyMock, return_value=["base-runtime", "platform"])
|
||||
def test_set_cg_build_koji_tag(
|
||||
self, cfg, generic_resolver, resolver, create_builder, dbg,
|
||||
koji_cg_tag_build, expected_cg_koji_build_tag):
|
||||
|
||||
@@ -405,6 +405,40 @@ class TestUtils:
|
||||
release = module_build_service.utils.get_rpm_release(build_one)
|
||||
assert release == 'module+fedora28+2+814cfa39'
|
||||
|
||||
@patch('module_build_service.config.Config.allowed_disttag_marking_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,
|
||||
and that module has the xmd.mbs.disttag_marking field set, it should influence the disttag.
|
||||
"""
|
||||
scheduler_init_data(1)
|
||||
mmd_path = path.abspath(path.join(
|
||||
__file__, path.pardir, path.pardir, 'staged_data', 'build_metadata_module.yaml'))
|
||||
metadata_mmd = module_build_service.utils.load_mmd(mmd_path, True)
|
||||
module_build_service.utils.import_mmd(db.session, metadata_mmd)
|
||||
|
||||
build_one = models.ModuleBuild.query.get(2)
|
||||
mmd = build_one.mmd()
|
||||
dep = mmd.get_dependencies()[0]
|
||||
dep.add_buildrequires('build', ['product1.2'])
|
||||
mmd.set_dependencies((dep, ))
|
||||
xmd = glib.from_variant_dict(mmd.get_xmd())
|
||||
xmd['mbs']['buildrequires']['build'] = {
|
||||
'filtered_rpms': [],
|
||||
'ref': 'virtual',
|
||||
'stream': 'product1.2',
|
||||
'version': '1',
|
||||
'context': '00000000',
|
||||
}
|
||||
mmd.set_xmd(glib.dict_values(xmd))
|
||||
build_one.modulemd = to_text_type(mmd.dumps())
|
||||
db.session.add(build_one)
|
||||
db.session.commit()
|
||||
|
||||
release = module_build_service.utils.get_rpm_release(build_one)
|
||||
assert release == 'module+product12+2+814cfa39'
|
||||
|
||||
def test_get_rpm_release_mse_scratch(self):
|
||||
init_data(contexts=True, scratch=True)
|
||||
build_one = models.ModuleBuild.query.get(2)
|
||||
|
||||
@@ -56,7 +56,7 @@ base_dir = dirname(dirname(__file__))
|
||||
|
||||
class FakeSCM(object):
|
||||
def __init__(self, mocked_scm, name, mmd_filenames, commit=None, checkout_raise=False,
|
||||
get_latest_raise=False):
|
||||
get_latest_raise=False, branch='master'):
|
||||
"""
|
||||
Adds default testing checkout, get_latest and name methods
|
||||
to mocked_scm SCM class.
|
||||
@@ -91,7 +91,7 @@ class FakeSCM(object):
|
||||
else:
|
||||
self.mocked_scm.return_value.get_latest = self.get_latest
|
||||
self.mocked_scm.return_value.repository_root = "https://src.stg.fedoraproject.org/modules/"
|
||||
self.mocked_scm.return_value.branch = 'master'
|
||||
self.mocked_scm.return_value.branch = branch
|
||||
self.mocked_scm.return_value.sourcedir = self.sourcedir
|
||||
self.mocked_scm.return_value.get_module_yaml = self.get_module_yaml
|
||||
|
||||
@@ -2025,3 +2025,26 @@ class TestViews:
|
||||
|
||||
rv = self.client.post(post_url, data=json.dumps({'branch': 'master', 'scmurl': scm_url}))
|
||||
assert rv.status_code == 201
|
||||
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
@patch('module_build_service.config.Config.allowed_disttag_marking_module_names',
|
||||
new_callable=PropertyMock, return_value=['build'])
|
||||
def test_submit_build_with_disttag_marking_in_xmd(
|
||||
self, mocked_admmn, mocked_scm, mocked_get_user):
|
||||
"""
|
||||
Test that white-listed modules may set the disttag_marking in xmd.mbs.
|
||||
"""
|
||||
FakeSCM(mocked_scm, 'build', 'build_metadata_module_not_processed.yaml',
|
||||
'620ec77321b2ea7b0d67d82992dda3e1d67055b4', branch='product1.2')
|
||||
|
||||
post_url = '/module-build-service/2/module-builds/'
|
||||
scm_url = ('https://src.stg.fedoraproject.org/modules/testmodule.git?#68931c90de214d9d13fe'
|
||||
'efbd35246a81b6cb8d49')
|
||||
|
||||
rv = self.client.post(
|
||||
post_url, data=json.dumps({'branch': 'product1.2', 'scmurl': scm_url}))
|
||||
assert rv.status_code == 201
|
||||
data = json.loads(rv.data)[0]
|
||||
mmd = Modulemd.Module().new_from_string(data['modulemd'])
|
||||
assert mmd.get_xmd()['mbs']['disttag_marking'] == 'product12'
|
||||
|
||||
Reference in New Issue
Block a user