diff --git a/src/core/src/package_managers/YumPackageManager.py b/src/core/src/package_managers/YumPackageManager.py index 1fa7b025..a6ccceae 100644 --- a/src/core/src/package_managers/YumPackageManager.py +++ b/src/core/src/package_managers/YumPackageManager.py @@ -202,6 +202,10 @@ def is_package(chunk): lines = output.strip().split('\n') for line_index in range(0, len(lines)): + # Do not install Obsoleting Packages. The obsoleting packages list comes towards end in the output. + if lines[line_index].strip().startswith("Obsoleting Packages"): + break + line = re.split(r'\s+', lines[line_index].strip()) next_line = [] diff --git a/src/core/tests/Test_YumPackageManager.py b/src/core/tests/Test_YumPackageManager.py index 6a185261..e8c2c13f 100644 --- a/src/core/tests/Test_YumPackageManager.py +++ b/src/core/tests/Test_YumPackageManager.py @@ -609,6 +609,15 @@ def test_is_reboot_pending_return_true_when_exception_raised(self): package_manager.do_processes_require_restart = backup_do_process_require_restart + def test_obsolete_packages_should_not_considered_in_available_updates(self): + self.runtime.set_legacy_test_type('ObsoletePackages') + package_manager = self.container.get('package_manager') + package_filter = self.container.get('package_filter') + available_updates, package_versions = package_manager.get_available_updates(package_filter) + self.assertEqual(len(available_updates), 1) + self.assertEqual(len(package_versions), 1) + self.assertTrue(available_updates[0] == "grub2-tools.x86_64") + self.assertTrue(package_versions[0] == "1:2.02-142.el8") if __name__ == '__main__': unittest.main() diff --git a/src/core/tests/library/LegacyEnvLayerExtensions.py b/src/core/tests/library/LegacyEnvLayerExtensions.py index 56635906..d0316722 100644 --- a/src/core/tests/library/LegacyEnvLayerExtensions.py +++ b/src/core/tests/library/LegacyEnvLayerExtensions.py @@ -1144,6 +1144,21 @@ def run_command_output(self, cmd, no_output=False, chk_err=True): entry = template.replace('', package) entry = entry.replace('', version) output += entry + elif self.legacy_test_type == 'ObsoletePackages': + if self.legacy_package_manager_name is Constants.YUM: + if cmd.find("check-update") > -1: + code = 100 + output = "\n" + \ + "grub2-tools.x86_64 " + \ + "1:2.02-142.el8 " + \ + "rhel-8-baseos-rhui-rpms\n" + \ + "Obsoleting Packages\n" + \ + "grub2-tools.x86_64 " + \ + "1:2.02-123.el8_6.8 " + \ + "rhel-8-baseos-rhui-rpms\n" + \ + " grub2-tools.x86_64 " + \ + "1:2.02-123.el8 " + \ + "@System\n" major_version = self.get_python_major_version() if major_version == 2: