#1041 get_reusable_component now checks the architecture
Merged 9 months ago by mprahl. Opened 9 months ago by vmaljulin.
vmaljulin/fm-orchestrator FACTORY-1935-2  into  master

@@ -51,7 +51,8 @@ 

  

  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)

  

@@ -334,6 +334,15 @@ 

                       '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!')

@@ -144,6 +144,31 @@ 

              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()

get_reusable_component now checks the architecture + test
Signed-off-by: Valerij Maljulin vmaljuli@redhat.com

@vmaljulin, actually, the flake8 test is failing, you can see it on the right side from this comment. You can open the Jenkins job, then open "Console output", click on "Full log" and search for "/usr/bin/flake8" to see the errors.

You can also run flake8 locally using "tox -e flake8".

I know some of the errors pointed there are not caused directly by the code in your PR, but I usually fix all of them I found... Sometimes some PRs are merged even with those errors by mistake...

You can use following without needing to use the comments in the code.

@pytest.mark.parametrize('set_architecture_for_current_build', [True, False])
@pytest.mark.parametrize('set_architecture_for_build_in_db', [True, False])

rebased onto 94c39e5693f17b29849005f414c70eea2f2bb92a

9 months ago

Btw, how could I rerun the Jenkins job? Or how could I login to this Jenkins?

Could you use an underscore and call this pkg_name instead of pkgname? It's just easier to read.

@vmaljulin :thumbsup: after you rename the variable. I'll merge it once that is addressed.

rebased onto 8ee7168

9 months ago

Commit 8ef445c fixes this pull-request

Pull-Request has been merged by mprahl

9 months ago

Pull-Request has been merged by mprahl

9 months ago