From 78819482590a69e948931f77be329ee292e2f579 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 25 Nov 2021 08:14:10 -0800 Subject: [PATCH] Start of unittests for the find_pkg_names() function --- ...nc_output_expect_deps_for_3_pkgs_found.txt | 294 ++++++++++++++++++ convert2rhel/unit_tests/pkghandler_test.py | 51 +++ 2 files changed, 345 insertions(+) create mode 100644 convert2rhel/unit_tests/data/pkghandler_yum_distro_sync_output_expect_deps_for_3_pkgs_found.txt diff --git a/convert2rhel/unit_tests/data/pkghandler_yum_distro_sync_output_expect_deps_for_3_pkgs_found.txt b/convert2rhel/unit_tests/data/pkghandler_yum_distro_sync_output_expect_deps_for_3_pkgs_found.txt new file mode 100644 index 0000000000..e1a20ef30c --- /dev/null +++ b/convert2rhel/unit_tests/data/pkghandler_yum_distro_sync_output_expect_deps_for_3_pkgs_found.txt @@ -0,0 +1,294 @@ +Loaded plugins: product-id, search-disabled-repos, subscription-manager +Repository rhel-7-server-rpms is listed more than once in the configuration +Repository rhel-7-server-optional-rpms is listed more than once in the configuration +Repository rhel-7-server-extras-rpms is listed more than once in the configuration +Resolving Dependencies +--> Running transaction check +---> Package glibc.x86_64 0:2.17-325.el7_9 will be a downgrade +---> Package glibc.x86_64 0:2.17-325.0.1.el7_9 will be erased +---> Package glibc-common.x86_64 0:2.17-325.el7_9 will be a downgrade +---> Package glibc-common.x86_64 0:2.17-325.0.1.el7_9 will be erased +---> Package glibc-devel.x86_64 0:2.17-325.el7_9 will be a downgrade +---> Package glibc-devel.x86_64 0:2.17-325.0.1.el7_9 will be erased +---> Package glibc-headers.x86_64 0:2.17-325.el7_9 will be a downgrade +---> Package glibc-headers.x86_64 0:2.17-325.0.1.el7_9 will be erased +---> Package libgcc.x86_64 0:4.8.5-44.el7 will be a downgrade +---> Package libgcc.x86_64 0:4.8.5-44.0.3.el7 will be erased +---> Package libstdc++.x86_64 0:4.8.5-44.el7 will be a downgrade +---> Package libstdc++.x86_64 0:4.8.5-44.0.3.el7 will be erased +---> Package systemd.x86_64 0:219-78.el7_9.3 will be a downgrade +---> Package systemd.x86_64 0:219-78.0.5.el7_9.3 will be erased +---> Package systemd-libs.x86_64 0:219-78.el7_9.3 will be a downgrade +---> Package systemd-libs.x86_64 0:219-78.0.5.el7_9.3 will be erased +---> Package systemd-sysv.x86_64 0:219-78.el7_9.3 will be a downgrade +---> Package systemd-sysv.x86_64 0:219-78.0.5.el7_9.3 will be erased +--> Finished Dependency Resolution +Error: Package: gcc-c++-4.8.5-44.0.3.el7.x86_64 (@ol7_latest) + Requires: libstdc++ = 4.8.5-44.0.3.el7 + Removing: libstdc++-4.8.5-44.0.3.el7.x86_64 (installed) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-44.0.3.el7 + Downgraded By: libstdc++-4.8.5-44.el7.x86_64 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-44.el7 + Available: libstdc++-4.8.2-16.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + Available: libstdc++-4.8.2-16.2.el7_0.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.2.el7_0 + Available: libstdc++-4.8.3-9.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.3-9.el7 + Available: libstdc++-4.8.5-4.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-4.el7 + Available: libstdc++-4.8.5-11.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-11.el7 + Available: libstdc++-4.8.5-16.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-16.el7 + Available: libstdc++-4.8.5-16.el7_4.1.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7_4 + libstdc++ = 4.8.5-16.el7_4.1 + Available: libstdc++-4.8.5-16.el7_4.2.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7_4 + libstdc++ = 4.8.5-16.el7_4.2 + Available: libstdc++-4.8.5-28.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-28.el7 + Available: libstdc++-4.8.5-28.el7_5.1.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7_5 + libstdc++ = 4.8.5-28.el7_5.1 + Available: libstdc++-4.8.5-36.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-36.el7 + Available: libstdc++-4.8.5-36.el7_6.1.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7_6 + libstdc++ = 4.8.5-36.el7_6.1 + Available: libstdc++-4.8.5-36.el7_6.2.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7_6 + libstdc++ = 4.8.5-36.el7_6.2 + Available: libstdc++-4.8.5-39.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-39.el7 +Error: Package: libstdc++-devel-4.8.5-44.0.3.el7.x86_64 (@ol7_latest) + Requires: libstdc++(x86-64) = 4.8.5-44.0.3.el7 + Removing: libstdc++-4.8.5-44.0.3.el7.x86_64 (installed) + libstdc++(x86-64) = 4.8.5-44.0.3.el7 + Downgraded By: libstdc++-4.8.5-44.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-44.el7 + Available: libstdc++-4.8.2-16.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.2-16.el7 + Available: libstdc++-4.8.2-16.2.el7_0.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.2-16.2.el7_0 + Available: libstdc++-4.8.3-9.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.3-9.el7 + Available: libstdc++-4.8.5-4.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-4.el7 + Available: libstdc++-4.8.5-11.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-11.el7 + Available: libstdc++-4.8.5-16.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-16.el7 + Available: libstdc++-4.8.5-16.el7_4.1.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-16.el7_4.1 + Available: libstdc++-4.8.5-16.el7_4.2.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-16.el7_4.2 + Available: libstdc++-4.8.5-28.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-28.el7 + Available: libstdc++-4.8.5-28.el7_5.1.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-28.el7_5.1 + Available: libstdc++-4.8.5-36.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-36.el7 + Available: libstdc++-4.8.5-36.el7_6.1.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-36.el7_6.1 + Available: libstdc++-4.8.5-36.el7_6.2.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-36.el7_6.2 + Available: libstdc++-4.8.5-39.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-39.el7 +Error: Package: gcc-4.8.5-44.0.3.el7.x86_64 (@ol7_latest) + Requires: libgcc >= 4.8.5-44.0.3.el7 + Removing: libgcc-4.8.5-44.0.3.el7.x86_64 (installed) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-44.0.3.el7 + Downgraded By: libgcc-4.8.5-44.el7.x86_64 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-44.el7 + Available: libgcc-4.8.2-16.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + Available: libgcc-4.8.2-16.2.el7_0.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.2.el7_0 + Available: libgcc-4.8.3-9.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.3-9.el7 + Available: libgcc-4.8.5-4.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-4.el7 + Available: libgcc-4.8.5-11.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-11.el7 + Available: libgcc-4.8.5-16.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-16.el7 + Available: libgcc-4.8.5-16.el7_4.1.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7_4 + libgcc = 4.8.5-16.el7_4.1 + Available: libgcc-4.8.5-16.el7_4.2.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7_4 + libgcc = 4.8.5-16.el7_4.2 + Available: libgcc-4.8.5-28.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-28.el7 + Available: libgcc-4.8.5-28.el7_5.1.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7_5 + libgcc = 4.8.5-28.el7_5.1 + Available: libgcc-4.8.5-36.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-36.el7 + Available: libgcc-4.8.5-36.el7_6.1.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7_6 + libgcc = 4.8.5-36.el7_6.1 + Available: libgcc-4.8.5-36.el7_6.2.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7_6 + libgcc = 4.8.5-36.el7_6.2 + Available: libgcc-4.8.5-39.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-39.el7 +********************************************************************** +yum can be configured to try to resolve such errors by temporarily enabling +disabled repos and searching for missing dependencies. +To enable this functionality please set 'notify_only=0' in /etc/yum/pluginconf.d/search-disabled-repos.conf +********************************************************************** + +Error: Package: gcc-c++-4.8.5-44.0.3.el7.x86_64 (@ol7_latest) + Requires: libstdc++ = 4.8.5-44.0.3.el7 + Removing: libstdc++-4.8.5-44.0.3.el7.x86_64 (installed) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-44.0.3.el7 + Downgraded By: libstdc++-4.8.5-44.el7.x86_64 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-44.el7 + Available: libstdc++-4.8.2-16.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + Available: libstdc++-4.8.2-16.2.el7_0.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.2.el7_0 + Available: libstdc++-4.8.3-9.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.3-9.el7 + Available: libstdc++-4.8.5-4.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-4.el7 + Available: libstdc++-4.8.5-11.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-11.el7 + Available: libstdc++-4.8.5-16.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-16.el7 + Available: libstdc++-4.8.5-16.el7_4.1.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7_4 + libstdc++ = 4.8.5-16.el7_4.1 + Available: libstdc++-4.8.5-16.el7_4.2.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7_4 + libstdc++ = 4.8.5-16.el7_4.2 + Available: libstdc++-4.8.5-28.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-28.el7 + Available: libstdc++-4.8.5-28.el7_5.1.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7_5 + libstdc++ = 4.8.5-28.el7_5.1 + Available: libstdc++-4.8.5-36.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-36.el7 + Available: libstdc++-4.8.5-36.el7_6.1.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7_6 + libstdc++ = 4.8.5-36.el7_6.1 + Available: libstdc++-4.8.5-36.el7_6.2.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7_6 + libstdc++ = 4.8.5-36.el7_6.2 + Available: libstdc++-4.8.5-39.el7.i686 (rhel-7-server-rpms) + libstdc++ = 4.8.2-16.el7 + libstdc++ = 4.8.5-39.el7 +Error: Package: libstdc++-devel-4.8.5-44.0.3.el7.x86_64 (@ol7_latest) + Requires: libstdc++(x86-64) = 4.8.5-44.0.3.el7 + Removing: libstdc++-4.8.5-44.0.3.el7.x86_64 (installed) + libstdc++(x86-64) = 4.8.5-44.0.3.el7 + Downgraded By: libstdc++-4.8.5-44.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-44.el7 + Available: libstdc++-4.8.2-16.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.2-16.el7 + Available: libstdc++-4.8.2-16.2.el7_0.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.2-16.2.el7_0 + Available: libstdc++-4.8.3-9.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.3-9.el7 + Available: libstdc++-4.8.5-4.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-4.el7 + Available: libstdc++-4.8.5-11.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-11.el7 + Available: libstdc++-4.8.5-16.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-16.el7 + Available: libstdc++-4.8.5-16.el7_4.1.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-16.el7_4.1 + Available: libstdc++-4.8.5-16.el7_4.2.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-16.el7_4.2 + Available: libstdc++-4.8.5-28.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-28.el7 + Available: libstdc++-4.8.5-28.el7_5.1.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-28.el7_5.1 + Available: libstdc++-4.8.5-36.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-36.el7 + Available: libstdc++-4.8.5-36.el7_6.1.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-36.el7_6.1 + Available: libstdc++-4.8.5-36.el7_6.2.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-36.el7_6.2 + Available: libstdc++-4.8.5-39.el7.x86_64 (rhel-7-server-rpms) + libstdc++(x86-64) = 4.8.5-39.el7 +Error: Package: gcc-4.8.5-44.0.3.el7.x86_64 (@ol7_latest) + Requires: libgcc >= 4.8.5-44.0.3.el7 + Removing: libgcc-4.8.5-44.0.3.el7.x86_64 (installed) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-44.0.3.el7 + Downgraded By: libgcc-4.8.5-44.el7.x86_64 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-44.el7 + Available: libgcc-4.8.2-16.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + Available: libgcc-4.8.2-16.2.el7_0.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.2.el7_0 + Available: libgcc-4.8.3-9.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.3-9.el7 + Available: libgcc-4.8.5-4.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-4.el7 + Available: libgcc-4.8.5-11.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-11.el7 + Available: libgcc-4.8.5-16.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-16.el7 + Available: libgcc-4.8.5-16.el7_4.1.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7_4 + libgcc = 4.8.5-16.el7_4.1 + Available: libgcc-4.8.5-16.el7_4.2.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7_4 + libgcc = 4.8.5-16.el7_4.2 + Available: libgcc-4.8.5-28.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-28.el7 + Available: libgcc-4.8.5-28.el7_5.1.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7_5 + libgcc = 4.8.5-28.el7_5.1 + Available: libgcc-4.8.5-36.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-36.el7 + Available: libgcc-4.8.5-36.el7_6.1.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7_6 + libgcc = 4.8.5-36.el7_6.1 + Available: libgcc-4.8.5-36.el7_6.2.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7_6 + libgcc = 4.8.5-36.el7_6.2 + Available: libgcc-4.8.5-39.el7.i686 (rhel-7-server-rpms) + libgcc = 4.8.2-16.el7 + libgcc = 4.8.5-39.el7 + You could try using --skip-broken to work around the problem +** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows: +initscripts-9.49.53-1.0.1.el7_9.1.x86_64 has missing requires of oraclelinux-release diff --git a/convert2rhel/unit_tests/pkghandler_test.py b/convert2rhel/unit_tests/pkghandler_test.py index 11e89c18cf..dc06275197 100644 --- a/convert2rhel/unit_tests/pkghandler_test.py +++ b/convert2rhel/unit_tests/pkghandler_test.py @@ -1453,3 +1453,54 @@ def test_fix_default_kernel_with_no_incorrect_kernel(self): kernel.x86_64 4.7.4-200.fc24 @updates Available Packages kernel.x86_64 4.7.4-200.fc24 @updates""" + +with open( + os.path.join(os.path.dirname(__file__), "data/pkghandler_yum_distro_sync_output_expect_deps_for_3_pkgs_found.txt") +) as f: + YUM_DISTRO_SYNC_OUTPUT = f.read() + + +@pytest.mark.parametrize( + "output, message, expected_names", + ( + # Test just the regex itself + ("Test", "%s", set()), + ("Error: Package: not_a_package_name", "%s", set()), + ("gcc-10.3.1-1.el8.x86_64", "%s", set(["gcc"])), + ("gcc-c++-10.3.1-1.el8.x86_64", "%s", set(["gcc-c++"])), + ("NetworkManager-1.26.8-1.fc33.x86_64", "%s", set(["NetworkManager"])), + # Test with simple error messages that we"ve pre-compiled + ("Error: Package: gcc-10.3.1-1.el8.x86_64", "Error: Package: %s", set(["gcc"])), + ("multilib versions: gcc-10.3.1-1.el8.i686", "multilib versions: %s", set(["gcc"])), + ("problem with installed package: gcc-10.3.1-1.el8.x86_64", "problem with installed package: %s", set(["gcc"])), + # Test with strings more like actual yum output + ( + """Junk + Test gcc-1-2.i686 + Test gcc-c++-1-2.i686 + More Junk + Test bash-3-4.x86_64""", + "Test %s", + set(["gcc", "gcc-c++", "bash"]), + ), + (YUM_DISTRO_SYNC_OUTPUT, "Error: Package: %s", set(["gcc", "gcc-c++", "libstdc++-devel"])), + ), +) +def test_find_pkg_names(output, message, expected_names): + """Test that find_pkg_names finds the expected packages.""" + assert pkghandler.find_pkg_names(output, message) == expected_names + + +@pytest.mark.parametrize( + "output, message", + ( + # Test just the regex itself + ("Test", "%s"), + ("Error: Package: not_a_package_name", "%s"), + # Test that the message key is having an influence + ("multilib versions: gcc-10.3.1-1.el8.i686", "Error: Package: %s"), + ), +) +def test_find_pkg_names_no_names(output, message): + """Test that find_pkg_names does not find any names in these outputs.""" + assert pkghandler.find_pkg_names(output, message) == set()