Merge #1041 get_reusable_component now checks the architecture

This commit is contained in:
Matt Prahl
2018-10-16 13:24:09 +00:00
3 changed files with 36 additions and 1 deletions

View File

@@ -51,7 +51,8 @@ from module_build_service.errors import ProgrammingError
from module_build_service.builder.base import GenericBuilder
from module_build_service.builder.KojiContentGenerator import KojiContentGenerator
from module_build_service.utils import get_reusable_components, get_reusable_module, get_build_arches
from module_build_service.utils import get_reusable_components, get_reusable_module
from module_build_service.utils import get_build_arches
logging.basicConfig(level=logging.DEBUG)

View File

@@ -334,6 +334,15 @@ def get_reusable_component(session, module, component_name,
'previous batches differ.')
return None
for pkg_name, pkg in mmd.get_rpm_components().items():
if pkg_name not in old_mmd.get_rpm_components():
log.info('Cannot re-use. Package lists are different.')
return None
if set(pkg.get_arches().get()) != \
set(old_mmd.get_rpm_components()[pkg_name].get_arches().get()):
log.info('Cannot re-use. Architectures are different for package: %s.' % pkg_name)
return None
reusable_component = models.ComponentBuild.query.filter_by(
package=component_name, module_id=previous_module_build.id).one()
log.debug('Found reusable component!')

View File

@@ -144,6 +144,31 @@ class TestUtilsComponentReuse:
db.session, second_module_build, 'perl-Tangerine')
assert pt_rv is None
@pytest.mark.parametrize('set_current_arch', [True, False])
@pytest.mark.parametrize('set_database_arch', [True, False])
def test_get_reusable_component_different_arches(self, set_database_arch, set_current_arch):
second_module_build = models.ModuleBuild.query.filter_by(id=3).one()
if set_current_arch: # set architecture for current build
mmd = second_module_build.mmd()
arches = Modulemd.SimpleSet()
arches.set(['i686'])
mmd.get_rpm_components()['tangerine'].set_arches(arches)
second_module_build.modulemd = mmd.dumps()
if set_database_arch: # set architecture for build in database
second_module_changed_component = models.ComponentBuild.query.filter_by(
package='tangerine', module_id=2).one()
mmd = second_module_changed_component.module_build.mmd()
arches = Modulemd.SimpleSet()
arches.set(['i686'])
mmd.get_rpm_components()['tangerine'].set_arches(arches)
second_module_changed_component.module_build.modulemd = mmd.dumps()
db.session.add(second_module_changed_component)
db.session.commit()
tangerine = module_build_service.utils.get_reusable_component(
db.session, second_module_build, 'tangerine')
assert bool(tangerine is None) != bool(set_current_arch == set_database_arch)
@pytest.mark.parametrize('rebuild_strategy', models.ModuleBuild.rebuild_strategies.keys())
def test_get_reusable_component_different_buildrequires_hash(self, rebuild_strategy):
first_module_build = models.ModuleBuild.query.filter_by(id=2).one()