mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-24 02:32:26 +08:00
Fix local builds.
I discovered that local builds have been broken by recent (good) changes in dnf. At the end of every batch, we regenerate the local repo with createrepo and we also call modifyrepo to include the modulemd file as we progress. This was added in #467. What we really want, is for the modulemd file to be present at the *end* of the build. Recently, dnf started respecting the modulemd file natively, such that builds we built in batch0 would not show up in batch1. They would be present in the repo, but they would be marked as belonging to a module which was not enabled, and so could not be pulled in. Every module build would fail because module-srpm-macros was in a disabled module (the module being built at the time). This change makes it so that the module metadata is only added to the repo at the very end of the build. I moved it into a `finalize` method on the builder which the copr builder was using, and for symmetry's sake I moved the koji content generator code to the same method on that builder. There was a circular import issue to solve between the koji module builder and the koji content generator modules that generated a larger diff, but is mostly cosmetic and mock changes.
This commit is contained in:
@@ -277,6 +277,9 @@ class FakeModuleBuilder(GenericBuilder):
|
||||
component_build.module_build.koji_tag + '-build', component_build.package))
|
||||
return msgs
|
||||
|
||||
def finalize(self):
|
||||
pass
|
||||
|
||||
|
||||
def cleanup_moksha():
|
||||
# Necessary to restart the twisted reactor for the next test.
|
||||
|
||||
@@ -72,7 +72,7 @@ class TestBuild:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.KojiModuleBuilder.get_session")
|
||||
@patch("module_build_service.builder.KojiContentGenerator.get_session")
|
||||
@patch("subprocess.Popen")
|
||||
@patch("subprocess.check_output", return_value='1.4')
|
||||
@patch("pkg_resources.get_distribution")
|
||||
@@ -118,7 +118,7 @@ class TestBuild:
|
||||
rpms_in_tag.assert_called_once()
|
||||
assert expected_output == ret
|
||||
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.KojiModuleBuilder.get_session")
|
||||
@patch("module_build_service.builder.KojiContentGenerator.get_session")
|
||||
@patch("subprocess.Popen")
|
||||
@patch("subprocess.check_output", return_value='1.4')
|
||||
@patch("pkg_resources.get_distribution")
|
||||
@@ -165,7 +165,7 @@ class TestBuild:
|
||||
with open(path.join(dir_path, "modulemd.txt")) as mmd:
|
||||
assert len(mmd.read()) == 1134
|
||||
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.KojiModuleBuilder.get_session")
|
||||
@patch("module_build_service.builder.KojiContentGenerator.get_session")
|
||||
def test_tag_cg_build(self, get_session):
|
||||
""" Test that the CG build is tagged. """
|
||||
koji_session = MagicMock()
|
||||
@@ -178,7 +178,7 @@ class TestBuild:
|
||||
koji_session.getTag.assert_called_once_with(self.cg.module.cg_build_koji_tag)
|
||||
koji_session.tagBuild.assert_called_once_with(123, "nginx-0-2.10e50d06")
|
||||
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.KojiModuleBuilder.get_session")
|
||||
@patch("module_build_service.builder.KojiContentGenerator.get_session")
|
||||
def test_tag_cg_build_fallback_to_default_tag(self, get_session):
|
||||
""" Test that the CG build is tagged to default tag. """
|
||||
koji_session = MagicMock()
|
||||
@@ -193,7 +193,7 @@ class TestBuild:
|
||||
call(conf.koji_cg_default_build_tag)]
|
||||
koji_session.tagBuild.assert_called_once_with(123, "nginx-0-2.10e50d06")
|
||||
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.KojiModuleBuilder.get_session")
|
||||
@patch("module_build_service.builder.KojiContentGenerator.get_session")
|
||||
def test_tag_cg_build_no_tag_set(self, get_session):
|
||||
""" Test that the CG build is not tagged when no tag set. """
|
||||
koji_session = MagicMock()
|
||||
@@ -206,7 +206,7 @@ class TestBuild:
|
||||
|
||||
koji_session.tagBuild.assert_not_called()
|
||||
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.KojiModuleBuilder.get_session")
|
||||
@patch("module_build_service.builder.KojiContentGenerator.get_session")
|
||||
def test_tag_cg_build_no_tag_available(self, get_session):
|
||||
""" Test that the CG build is not tagged when no tag available. """
|
||||
koji_session = MagicMock()
|
||||
|
||||
@@ -619,6 +619,9 @@ class DummyModuleBuilder(GenericBuilder):
|
||||
def repo_from_tag(self, config, tag_name, arch):
|
||||
pass
|
||||
|
||||
def finalize(self):
|
||||
pass
|
||||
|
||||
|
||||
@patch("module_build_service.builder.GenericBuilder.default_buildroot_groups",
|
||||
return_value={'build': [], 'srpm-build': []})
|
||||
|
||||
Reference in New Issue
Block a user