Skip to content

Commit

Permalink
improve installer tests compatibility with pit
Browse files Browse the repository at this point in the history
  • Loading branch information
rmynar committed Jun 14, 2024
1 parent 32607ba commit 49f3e08
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 81 deletions.
2 changes: 1 addition & 1 deletion conf/capsule.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CAPSULE:
# The snap version currently testing (if applicable)
# SNAP:
# The source of Capsule packages. Can be one of:
# internal, ga, beta
# internal, ga
SOURCE: "internal"
# The base os rhel version where the capsule installed
# RHEL_VERSION:
Expand Down
3 changes: 3 additions & 0 deletions conf/robottelo.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ ROBOTTELO:
SATELLITE_VERSION: "6.17"
# The Base OS RHEL Version(x.y) where the satellite would be installed
RHEL_VERSION: "8.10"
# The source of RHEL packages. Can be one of:
# internal, ga (CDN)
RHEL_SOURCE: "ga"
# Dynaconf and Dynaconf hooks related options
SETTINGS:
GET_FRESH: true
8 changes: 4 additions & 4 deletions conf/server.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ SERVER:
# - replace.with.satellite.hostname
# - replace.with.satellite.hostname
VERSION:
# The full release version (6.9.2)
RELEASE: 6.9.2
# The full release version (6.15.0)
RELEASE: 6.15.0
# The snap version currently testing (if applicable)
SNAP: 1.0
# The source of Satellite packages. Can be one of:
# internal, ga, beta
# internal, ga
SOURCE: "internal"
# The RHEL Base OS Version(x.y) where the Satellite is installed
RHEL_VERSION: '7'
RHEL_VERSION: '8'
# If the the satellite server is IPv6 server
IS_IPV6: False
# HTTP Proxy url for IPv6 satellite to connect for outer world access
Expand Down
30 changes: 23 additions & 7 deletions pytest_fixtures/core/sat_cap_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,9 @@ def module_sat_ready_rhels(request):

@pytest.fixture
def cap_ready_rhel():
"""Deploy bare RHEL system ready for Capsule installation."""
rhel_version = Version(settings.capsule.version.rhel_version)
deploy_args = {
deploy_args = settings.capsule.deploy_arguments | {
'deploy_rhel_version': rhel_version.base_version,
'deploy_network_type': 'ipv6' if settings.server.is_ipv6 else 'ipv4',
'deploy_flavor': settings.flavors.default,
Expand All @@ -359,13 +360,28 @@ def installer_satellite(request):
else:
sat = lru_sat_ready_rhel(getattr(request, 'param', None))
sat.setup_firewall()
# # Register for RHEL8 repos, get Ohsnap repofile, and enable and download satellite

# register to cdn (also enables rhel repos from cdn)
sat.register_to_cdn(enable_proxy=True)
sat.download_repofile(
product='satellite',
release=settings.server.version.release,
snap=settings.server.version.snap,
)

# setup source repositories
if settings.server.version.source == "ga":
# enable satellite repos
for repo in sat.SATELLITE_CDN_REPOS.values():
sat.enable_repo(repo, force=True)
else:
# get ohsnap repofile
sat.download_repofile(
product='satellite',
release=settings.server.version.release,
snap=settings.server.version.snap,
)
if settings.robottelo.rhel_source == "internal":
# disable rhel repos from cdn
sat.disable_repo("rhel-*")
# add internal rhel repos
sat.create_custom_repos(**settings.repos.get(f'rhel{sat.os_version.major}_os'))

sat.install_satellite_or_capsule_package()
installed_version = sat.execute('rpm --query satellite').stdout
assert sat_version in installed_version
Expand Down
7 changes: 5 additions & 2 deletions robottelo/config/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Validator('server.hostname', is_type_of=str),
Validator('server.hostnames', must_exist=True, is_type_of=list),
Validator('server.version.release', must_exist=True),
Validator('server.version.source', must_exist=True),
Validator('server.version.source', default='internal', is_in=['internal', 'ga']),
Validator('server.version.rhel_version', must_exist=True, cast=str),
Validator(
'server.xdist_behavior', must_exist=True, is_in=['run-on-one', 'balance', 'on-demand']
Expand Down Expand Up @@ -74,7 +74,7 @@
],
capsule=[
Validator('capsule.version.release', must_exist=True),
Validator('capsule.version.source', must_exist=True),
Validator('capsule.version.source', default='internal', is_in=['internal', 'ga']),
Validator('capsule.deploy_workflows', must_exist=True, is_type_of=dict),
Validator('capsule.deploy_workflows.product', must_exist=True),
Validator('capsule.deploy_workflows.os', must_exist=True),
Expand Down Expand Up @@ -330,6 +330,9 @@
Validator('remotedb.ssl', default=True),
Validator('remotedb.port', default=5432),
],
robottelo=[
Validator('robottelo.rhel_source', default='ga', is_in=['ga', 'internal']),
],
shared_function=[
Validator('shared_function.storage', is_in=('file', 'redis'), default='file'),
Validator('shared_function.share_timeout', lte=86400, default=86400),
Expand Down
16 changes: 16 additions & 0 deletions robottelo/host_helpers/contenthost_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ def REPOS(self):
except KeyError as err:
raise ValueError(f'Unsupported system version: {self._v_major}') from err

@cached_property
def SATELLITE_CDN_REPOS(self):
sat_version = ".".join(settings.server.version.release.split('.')[0:2])
return {
'satellite': f"satellite-{sat_version}-for-rhel-{self._v_major}-x86_64-rpms",
'sat-maintenance': f"satellite-maintenance-{sat_version}-for-rhel-{self._v_major}-x86_64-rpms",
}

@cached_property
def CAPSULE_CDN_REPOS(self):
sat_version = ".".join(settings.server.version.release.split('.')[0:2])
return {
'capsule': f"satellite-capsule-{sat_version}-for-rhel-{self._v_major}-x86_64-rpms",
'sat-maintenance': f"satellite-maintenance-{sat_version}-for-rhel-{self._v_major}-x86_64-rpms",
}

@cached_property
def OSCAP(self):
return {
Expand Down
58 changes: 5 additions & 53 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from broker.hosts import Host
from dynaconf.vendor.box.exceptions import BoxKeyError
from fauxfactory import gen_alpha, gen_string
from manifester import Manifester
from nailgun import entities
from packaging.version import Version
import requests
Expand All @@ -41,12 +40,8 @@
CUSTOM_PUPPET_MODULE_REPOS,
CUSTOM_PUPPET_MODULE_REPOS_PATH,
CUSTOM_PUPPET_MODULE_REPOS_VERSION,
DEFAULT_ARCHITECTURE,
HAMMER_CONFIG,
KEY_CLOAK_CLI,
PRDS,
REPOS,
REPOSET,
RHSSO_NEW_GROUP,
RHSSO_NEW_USER,
RHSSO_RESET_PASSWORD,
Expand All @@ -70,8 +65,9 @@

@lru_cache
def lru_sat_ready_rhel(rhel_ver):
"""Deploy bare RHEL system ready for Satellite installation."""
rhel_version = rhel_ver or settings.server.version.rhel_version
deploy_args = {
deploy_args = settings.server.deploy_arguments | {
'deploy_rhel_version': rhel_version,
'deploy_network_type': 'ipv6' if settings.server.is_ipv6 else 'ipv4',
'deploy_flavor': settings.flavors.default,
Expand Down Expand Up @@ -109,53 +105,6 @@ def get_sat_rhel_version():
return Version(rhel_version)


def setup_capsule(satellite, capsule, org, registration_args=None, installation_args=None):
"""Given satellite and capsule instances, run the commands needed to set up the capsule
Note: This does not perform content setup actions on the Satellite
:param satellite: An instance of this module's Satellite class
:param capsule: An instance of this module's Capsule class
:param org: An instance of the org to use on the Satellite
:param registration_args: A dictionary mapping argument: value pairs for registration
:param installation_args: A dictionary mapping argument: value pairs for installation
:return: An ssh2-python result object for the installation command.
"""
# Unregister capsule incase it's registered to CDN
capsule.unregister()

# Add a manifest to the Satellite
with Manifester(manifest_category=settings.manifest.entitlement) as manifest:
satellite.upload_manifest(org.id, manifest.content)

# Enable RHEL 8 BaseOS and AppStream repos and sync
for rh_repo_key in ['rhel8_bos', 'rhel8_aps']:
satellite.api_factory.enable_rhrepo_and_fetchid(
basearch=DEFAULT_ARCHITECTURE,
org_id=org.id,
product=PRDS['rhel8'],
repo=REPOS[rh_repo_key]['name'],
reposet=REPOSET[rh_repo_key],
releasever=REPOS[rh_repo_key]['releasever'],
)
product = satellite.api.Product(name=PRDS['rhel8'], organization=org.id).search()[0]
product.sync(timeout=1800, synchronous=True)

if not registration_args:
registration_args = {}
file, _, cmd_args = satellite.capsule_certs_generate(capsule)
if installation_args:
cmd_args.update(installation_args)
satellite.execute(
f'sshpass -p "{capsule.password}" scp -o "StrictHostKeyChecking no" '
f'{file} root@{capsule.hostname}:{file}'
)
capsule.install_katello_ca(satellite)
capsule.register_contenthost(org=org.label, **registration_args)
return capsule.install(cmd_args)


class ContentHostError(Exception):
pass

Expand Down Expand Up @@ -525,6 +474,9 @@ def enable_repo(self, repo, force=False):
return self.execute(f'subscription-manager repos --enable {repo}')
return None

def disable_repo(self, repo):
return self.execute(f'subscription-manager repos --disable {repo}')

def subscription_manager_list_repos(self):
return self.execute('subscription-manager repos --list')

Expand Down
Loading

0 comments on commit 49f3e08

Please sign in to comment.