mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-01 09:50:33 +08:00
There are following changes introduced in this commit: - The `koji_tag` of module builds imported from the local repositories is now in `repofile:///etc/yum.repos.d/some.repo` format to store the repository from which the module was imported to local MBS DB. - The `koji_tag` of fake base module is set to empty `repofile://` and in `MockModuleBuilder` the `conf.base_module_repofiles` list is used as source for the repositories defining platform. We can't simply use single repository, because there might be fedora.repo and fedora-update.repo and so on. - The list of default .repo files for platform are passed using the `-r` switch in `build_module_locally` `mbs-manager` command. - The LocalResolver (subclass of DBResolver) is added which is used to resolve the build dependencies when building modules offline locally. - The `MockModuleBuilder` enables the buildrequired modules and repositories from which they come in the mock config. With this commit, it is possible to build testmodule locally without any external infra.
77 lines
3.2 KiB
Python
77 lines
3.2 KiB
Python
# Copyright (c) 2019 Red Hat, Inc.
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
# in the Software without restriction, including without limitation the rights
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
# copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
# SOFTWARE.
|
|
#
|
|
# Written by Jan Kaluza <jkaluza@redhat.com>
|
|
|
|
import os
|
|
from datetime import datetime
|
|
|
|
from module_build_service.utils import to_text_type
|
|
import module_build_service.resolver as mbs_resolver
|
|
from module_build_service import db
|
|
from module_build_service.utils import import_mmd, load_mmd
|
|
from module_build_service.models import ModuleBuild
|
|
import tests
|
|
|
|
|
|
base_dir = os.path.join(os.path.dirname(__file__), "..")
|
|
|
|
|
|
class TestLocalResolverModule:
|
|
|
|
def setup_method(self):
|
|
tests.reuse_component_init_data()
|
|
|
|
def test_get_buildrequired_modulemds(self):
|
|
mmd = load_mmd(os.path.join(base_dir, 'staged_data', 'platform.yaml'), True)
|
|
mmd.set_stream('f8')
|
|
import_mmd(db.session, mmd)
|
|
platform_f8 = ModuleBuild.query.filter_by(stream='f8').one()
|
|
mmd.set_name("testmodule")
|
|
mmd.set_stream("master")
|
|
mmd.set_version(20170109091357)
|
|
mmd.set_context("123")
|
|
build = ModuleBuild(
|
|
name='testmodule',
|
|
stream='master',
|
|
version=20170109091357,
|
|
state=5,
|
|
build_context='dd4de1c346dcf09ce77d38cd4e75094ec1c08ec3',
|
|
runtime_context='ec4de1c346dcf09ce77d38cd4e75094ec1c08ef7',
|
|
context='7c29193d',
|
|
koji_tag='module-testmodule-master-20170109091357-7c29193d',
|
|
scmurl='https://src.stg.fedoraproject.org/modules/testmodule.git?#ff1ea79',
|
|
batch=3,
|
|
owner='Dr. Pepper',
|
|
time_submitted=datetime(2018, 11, 15, 16, 8, 18),
|
|
time_modified=datetime(2018, 11, 15, 16, 19, 35),
|
|
rebuild_strategy='changed-and-after',
|
|
modulemd=to_text_type(mmd.dumps())
|
|
)
|
|
db.session.add(build)
|
|
db.session.commit()
|
|
|
|
resolver = mbs_resolver.GenericResolver.create(tests.conf, backend='local')
|
|
result = resolver.get_buildrequired_modulemds(
|
|
"testmodule", "master", platform_f8.mmd().dup_nsvc())
|
|
nsvcs = set([m.dup_nsvc() for m in result])
|
|
assert nsvcs == set(['testmodule:master:20170109091357:9c690d0e',
|
|
'testmodule:master:20170109091357:123'])
|