From 6190280beb7a9c8d20775016d508d5a935c45d55 Mon Sep 17 00:00:00 2001 From: Jitendra Yejare Date: Thu, 20 Jun 2024 21:45:35 +0530 Subject: [PATCH] [6.13.z] Installer Assertions in test context rather than in helper (#15461) (#15467) Installer Assertions in test context rather than in helper (#15461) --- pytest_fixtures/core/sat_cap_factory.py | 5 +---- robottelo/hosts.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/pytest_fixtures/core/sat_cap_factory.py b/pytest_fixtures/core/sat_cap_factory.py index 6c2d0d61f75..0ec281b3e59 100644 --- a/pytest_fixtures/core/sat_cap_factory.py +++ b/pytest_fixtures/core/sat_cap_factory.py @@ -326,7 +326,6 @@ def installer_satellite(request): :params request: A pytest request object and this fixture is looking for broker object of class satellite """ - sat_version = settings.server.version.release if 'sanity' in request.config.option.markexpr: sat = Satellite(settings.server.hostname) else: @@ -339,9 +338,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') - installed_version = sat.execute('rpm --query satellite').stdout - assert sat_version in installed_version + sat.install_satellite_or_capsule_package() # Install Satellite sat.execute( InstallerCommand( diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 98c6434a7fa..a64bdfcee30 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -1486,6 +1486,7 @@ def update_host_location(self, location): class Capsule(ContentHost, CapsuleMixins): + product_rpm_name = 'satellite-capsule' rex_key_path = '~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub' @property @@ -1713,8 +1714,29 @@ def cli(self): self._cli._configured = True return self._cli + def enable_satellite_or_capsule_module_for_rhel8(self): + """Enable Satellite/Capsule module for RHEL8. + Note: Make sure required repos are enabled before using this. + """ + if self.os_version.major == 8: + assert ( + self.execute( + f'dnf -y module enable {self.product_rpm_name}:el{self.os_version.major}' + ).status + == 0 + ) + + def install_satellite_or_capsule_package(self): + """Install Satellite/Capsule package. Also handles module enablement for RHEL8. + Note: Make sure required repos are enabled before using this. + """ + self.enable_satellite_or_capsule_module_for_rhel8() + assert self.execute(f'dnf -y install {self.product_rpm_name}').status == 0 + class Satellite(Capsule, SatelliteMixins): + product_rpm_name = 'satellite' + def __init__(self, hostname=None, **kwargs): hostname = hostname or settings.server.hostname # instance attr set by broker.Host self.omitting_credentials = False