def test_get_reusable_component_different_buildrequires_stream( self, rebuild_strategy): first_module_build = models.ModuleBuild.get_by_id(db_session, 2) first_module_build.rebuild_strategy = rebuild_strategy db_session.commit() second_module_build = models.ModuleBuild.get_by_id(db_session, 3) mmd = second_module_build.mmd() xmd = mmd.get_xmd() xmd["mbs"]["buildrequires"]["platform"]["stream"] = "different" deps = Modulemd.Dependencies() deps.add_buildtime_stream("platform", "different") deps.add_runtime_stream("platform", "different") mmd.clear_dependencies() mmd.add_dependencies(deps) mmd.set_xmd(xmd) second_module_build.modulemd = mmd_to_str(mmd) second_module_build.build_context = \ models.ModuleBuild.contexts_from_mmd(second_module_build.modulemd).build_context second_module_build.rebuild_strategy = rebuild_strategy db_session.commit() plc_rv = get_reusable_component(second_module_build, "perl-List-Compare") pt_rv = get_reusable_component(second_module_build, "perl-Tangerine") tangerine_rv = get_reusable_component(second_module_build, "tangerine") assert plc_rv is None assert pt_rv is None assert tangerine_rv is None
def test_get_reusable_component_different_buildrequires(self): second_module_build = models.ModuleBuild.get_by_id(db_session, 3) mmd = second_module_build.mmd() mmd.get_dependencies()[0].add_buildtime_stream("some_module", "master") xmd = mmd.get_xmd() xmd["mbs"]["buildrequires"] = { "some_module": { "ref": "da39a3ee5e6b4b0d3255bfef95601890afd80709", "stream": "master", "version": "20170123140147", } } mmd.set_xmd(xmd) second_module_build.modulemd = mmd_to_str(mmd) second_module_build.build_context = models.ModuleBuild.calculate_build_context( xmd["mbs"]["buildrequires"]) db_session.commit() plc_rv = get_reusable_component(second_module_build, "perl-List-Compare") assert plc_rv is None pt_rv = get_reusable_component(second_module_build, "perl-Tangerine") assert pt_rv is None tangerine_rv = get_reusable_component(second_module_build, "tangerine") assert tangerine_rv is None
def test_get_reusable_component_different_rpm_macros(self): second_module_build = models.ModuleBuild.get_by_id(db_session, 3) mmd = second_module_build.mmd() buildopts = Modulemd.Buildopts() buildopts.set_rpm_macros("%my_macro 1") mmd.set_buildopts(buildopts) second_module_build.modulemd = mmd_to_str(mmd) db_session.commit() plc_rv = get_reusable_component(second_module_build, "perl-List-Compare") assert plc_rv is None pt_rv = get_reusable_component(second_module_build, "perl-Tangerine") assert pt_rv is None
def test_get_reusable_component_different_arches(self, set_database_arch, set_current_arch): second_module_build = models.ModuleBuild.get_by_id(db_session, 3) if set_current_arch: # set architecture for current build mmd = second_module_build.mmd() component = mmd.get_rpm_component("tangerine") component.reset_arches() component.add_restricted_arch("i686") second_module_build.modulemd = mmd_to_str(mmd) db_session.commit() if set_database_arch: # set architecture for build in database second_module_changed_component = models.ComponentBuild.from_component_name( db_session, "tangerine", 2) mmd = second_module_changed_component.module_build.mmd() component = mmd.get_rpm_component("tangerine") component.reset_arches() component.add_restricted_arch("i686") second_module_changed_component.module_build.modulemd = mmd_to_str( mmd) db_session.commit() tangerine = get_reusable_component(second_module_build, "tangerine") assert bool(tangerine is None) != bool( set_current_arch == set_database_arch)
def test_get_reusable_component_different_arch_in_batch( self, changed_component, reuse_component): """ Test that we get the correct reuse behavior for the changed-and-after strategy. Changes to the architectures in earlier batches should prevent reuse, but such changes to later batches should not. For context, see https://pagure.io/fm-orchestrator/issue/1298 """ if changed_component == reuse_component: # we're only testing the cases where these are different # this case is already covered by test_get_reusable_component_different_arches return second_module_build = models.ModuleBuild.get_by_id(db_session, 3) # update arch for changed component mmd = second_module_build.mmd() component = mmd.get_rpm_component(changed_component) component.reset_arches() component.add_restricted_arch("i686") second_module_build.modulemd = mmd_to_str(mmd) db_session.commit() changed_component = models.ComponentBuild.from_component_name( db_session, changed_component, second_module_build.id) reuse_component = models.ComponentBuild.from_component_name( db_session, reuse_component, second_module_build.id) reuse_result = get_reusable_component(second_module_build, reuse_component.package) # Changing the arch of a component should prevent reuse only when the changed component # is in a batch earlier than the component being considered for reuse. assert bool(reuse_result is None) == bool( reuse_component.batch > changed_component.batch)
def test_get_reusable_component_different_batch(self, changed_component, reuse_component): """ Test that we get the correct reuse behavior for the changed-and-after strategy. Changes to earlier batches should prevent reuse, but changes to later batches should not. For context, see https://pagure.io/fm-orchestrator/issue/1298 """ if changed_component == reuse_component: # we're only testing the cases where these are different # this case is already covered by test_get_reusable_component_different_component return second_module_build = models.ModuleBuild.get_by_id(db_session, 3) # update batch for changed component changed_component = models.ComponentBuild.from_component_name( db_session, changed_component, second_module_build.id) orig_batch = changed_component.batch changed_component.batch = orig_batch + 1 db_session.commit() reuse_component = models.ComponentBuild.from_component_name( db_session, reuse_component, second_module_build.id) reuse_result = get_reusable_component(second_module_build, reuse_component.package) # Component reuse should only be blocked when an earlier batch has been changed. # In this case, orig_batch is the earliest batch that has been changed (the changed # component has been removed from it and added to the following one). assert bool(reuse_result is None) == bool( reuse_component.batch > orig_batch)
def test_get_reusable_component_shared_userspace_ordering(self): """ For modules with lot of components per batch, there is big chance that the database will return them in different order than what we have for current `new_module`. In this case, reuse code should still be able to reuse the components. """ old_module = models.ModuleBuild.get_by_id(db_session, 2) new_module = models.ModuleBuild.get_by_id(db_session, 3) rv = get_reusable_component(new_module, "llvm", previous_module_build=old_module) assert rv.package == "llvm"
def test_get_reusable_component_different_component( self, changed_component): second_module_build = models.ModuleBuild.get_by_id(db_session, 3) if changed_component: mmd = second_module_build.mmd() mmd.get_rpm_component("tangerine").set_ref( "00ea1da4192a2030f9ae023de3b3143ed647bbab") second_module_build.modulemd = mmd_to_str(mmd) second_module_changed_component = models.ComponentBuild.from_component_name( db_session, changed_component, second_module_build.id) second_module_changed_component.ref = "00ea1da4192a2030f9ae023de3b3143ed647bbab" db_session.add(second_module_changed_component) db_session.commit() plc_rv = get_reusable_component(second_module_build, "perl-List-Compare") pt_rv = get_reusable_component(second_module_build, "perl-Tangerine") tangerine_rv = get_reusable_component(second_module_build, "tangerine") if changed_component == "perl-List-Compare": # perl-Tangerine can be reused even though a component in its batch has changed assert plc_rv is None assert pt_rv.package == "perl-Tangerine" assert tangerine_rv is None elif changed_component == "perl-Tangerine": # perl-List-Compare can be reused even though a component in its batch has changed assert plc_rv.package == "perl-List-Compare" assert pt_rv is None assert tangerine_rv is None elif changed_component == "tangerine": # perl-List-Compare and perl-Tangerine can be reused since they are in an earlier # buildorder than tangerine assert plc_rv.package == "perl-List-Compare" assert pt_rv.package == "perl-Tangerine" assert tangerine_rv is None elif changed_component is None: # Nothing has changed so everthing can be used assert plc_rv.package == "perl-List-Compare" assert pt_rv.package == "perl-Tangerine" assert tangerine_rv.package == "tangerine"