From f56e68cd78f7e85c20781192a879b277d2b7192c Mon Sep 17 00:00:00 2001 From: Jameer Pathan <21165044+jameerpathan111@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:34:49 +0200 Subject: [PATCH] Fix tests failing on enabling satellite/capsule module --- pytest_fixtures/core/sat_cap_factory.py | 2 +- robottelo/hosts.py | 13 +++++++++++++ tests/foreman/destructive/test_clone.py | 5 ++++- tests/foreman/installer/test_installer.py | 6 ++---- tests/foreman/sys/test_katello_certs_check.py | 5 +---- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/pytest_fixtures/core/sat_cap_factory.py b/pytest_fixtures/core/sat_cap_factory.py index 0c23b1ee4d2..4e1af634691 100644 --- a/pytest_fixtures/core/sat_cap_factory.py +++ b/pytest_fixtures/core/sat_cap_factory.py @@ -346,7 +346,7 @@ def installer_satellite(request): release=settings.server.version.release, snap=settings.server.version.snap, ) - sat.execute('dnf -y module enable satellite:el8 && dnf -y install satellite') + sat.install_satellite_or_capsule_package() installed_version = sat.execute('rpm --query satellite').stdout assert sat_version in installed_version # Install Satellite diff --git a/robottelo/hosts.py b/robottelo/hosts.py index a5d5e2319f7..9e08ad9fa35 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -1754,6 +1754,19 @@ def cli(self): self._cli._configured = True return self._cli + def install_satellite_or_capsule_package(self): + """Install Satellite/Capsule package. + Note: Make sure required repos are enabled before using this. + """ + if settings.server.version.rhel_version != 9: + assert ( + self.execute( + f"dnf -y module enable {self.product_rpm_name}:el{settings.server.version.rhel_version}" + ).status + == 0 + ) + assert self.execute(f"dnf -y install {self.product_rpm_name}").status == 0 + class Satellite(Capsule, SatelliteMixins): product_rpm_name = 'satellite' diff --git a/tests/foreman/destructive/test_clone.py b/tests/foreman/destructive/test_clone.py index fade8abcf6a..fa349a6c84c 100644 --- a/tests/foreman/destructive/test_clone.py +++ b/tests/foreman/destructive/test_clone.py @@ -90,7 +90,10 @@ def test_positive_clone_backup( for repo in getattr(constants, f"OHSNAP_RHEL{rhel_version}_REPOS"): sat_ready_rhel.enable_repo(repo, force=True) # Enabling satellite module - assert sat_ready_rhel.execute(f'dnf module enable -y satellite:el{rhel_version}').status == 0 + if settings.server.version.rhel_version != 9: + assert ( + sat_ready_rhel.execute(f'dnf module enable -y satellite:el{rhel_version}').status == 0 + ) # Install satellite-clone assert sat_ready_rhel.execute('yum install satellite-clone -y').status == 0 # Disabling CDN repos as we install from dogfdood diff --git a/tests/foreman/installer/test_installer.py b/tests/foreman/installer/test_installer.py index da64593642e..54dcc38b3d1 100644 --- a/tests/foreman/installer/test_installer.py +++ b/tests/foreman/installer/test_installer.py @@ -1358,7 +1358,7 @@ def install_satellite(satellite, installer_args, enable_fapolicyd=False): satellite.execute('dnf -y install fapolicyd && systemctl enable --now fapolicyd').status == 0 ) - satellite.execute('dnf -y module enable satellite:el8 && dnf -y install satellite') + satellite.install_satellite_or_capsule_package() if enable_fapolicyd: assert satellite.execute('rpm -q foreman-fapolicyd').status == 0 assert satellite.execute('rpm -q foreman-proxy-fapolicyd').status == 0 @@ -1441,9 +1441,7 @@ def test_capsule_installation(sat_non_default_install, cap_ready_rhel, setting_u ).status == 0 ) - cap_ready_rhel.execute( - 'dnf -y module enable satellite-capsule:el8 && dnf -y install satellite-capsule' - ) + cap_ready_rhel.install_satellite_or_capsule_package() assert cap_ready_rhel.execute('rpm -q foreman-proxy-fapolicyd').status == 0 # Setup Capsule setup_capsule(sat_non_default_install, cap_ready_rhel, org) diff --git a/tests/foreman/sys/test_katello_certs_check.py b/tests/foreman/sys/test_katello_certs_check.py index 640add5a0ae..820501f3713 100644 --- a/tests/foreman/sys/test_katello_certs_check.py +++ b/tests/foreman/sys/test_katello_certs_check.py @@ -44,10 +44,7 @@ def test_positive_install_sat_with_katello_certs(certs_data, sat_ready_rhel): ) sat_ready_rhel.register_to_cdn() sat_ready_rhel.execute('dnf -y update') - result = sat_ready_rhel.execute( - 'dnf -y module enable satellite:el8 && dnf -y install satellite' - ) - assert result.status == 0 + sat_ready_rhel.install_satellite_or_capsule_package() command = InstallerCommand( scenario='satellite', certs_server_cert=f'/root/{certs_data["cert_file_name"]}',