Skip to content

Commit

Permalink
Sanity Testing fixes for Ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
jyejare committed May 15, 2024
1 parent 44dc56a commit 2ee0fee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
7 changes: 3 additions & 4 deletions pytest_fixtures/core/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ def _default_sat(align_to_satellite):
"""Returns a Satellite object for settings.server.hostname"""
if settings.server.hostname:
try:
sat = Satellite.get_host_by_hostname(settings.server.hostname)
http_proxy = sat.enable_ipv6_http_proxy()
yield sat
sat.disable_ipv6_http_proxy(http_proxy)
return Satellite.get_host_by_hostname(settings.server.hostname)
except ContentHostError:
return Satellite()
return None
Expand All @@ -37,7 +34,9 @@ def _target_sat_imp(request, _default_sat, satellite_factory):
settings.set('server.hostname', installer_sat.hostname)
yield installer_sat
else:
_default_sat.enable_ipv6_http_proxy()
yield _default_sat
_default_sat.disable_ipv6_http_proxy()


@pytest.fixture
Expand Down
7 changes: 2 additions & 5 deletions pytest_fixtures/core/sat_cap_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,8 @@ def installer_satellite(request):
else:
sat = lru_sat_ready_rhel(getattr(request, 'param', None))
sat.setup_firewall()
http_proxy = sat.enable_ipv6_http_proxy()
# # Register for RHEL8 repos, get Ohsnap repofile, and enable and download satellite
sat.register_to_cdn()
sat.register_to_cdn(enable_proxy=True)
sat.download_repofile(
product='satellite',
release=settings.server.version.release,
Expand All @@ -386,14 +385,12 @@ def installer_satellite(request):
).get_command(),
timeout='30m',
)
sat.enable_ipv6_http_proxy()
if 'sanity' in request.config.option.markexpr:
configure_nailgun()
configure_airgun()
yield sat
if 'sanity' not in request.config.option.markexpr:
sat = Satellite.get_host_by_hostname(sat.hostname)
sat.unregister()
sat.disable_ipv6_http_proxy(http_proxy)
Broker(hosts=[sat]).checkin()
else:
sat.disable_ipv6_http_proxy(http_proxy)
20 changes: 16 additions & 4 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ def register_contenthost(
auto_attach=False,
serverurl=None,
baseurl=None,
enable_proxy=False,
):
"""Registers content host on foreman server either by specifying
organization name and activation key name or by specifying organization
Expand Down Expand Up @@ -869,6 +870,12 @@ def register_contenthost(
cmd += f' --serverurl {serverurl}'
if baseurl:
cmd += f' --baseurl {baseurl}'

# Enabling proxy for Ipv6
if enable_proxy and all([settings.server.is_ipv6, settings.server.http_proxy_ipv6_url]):
url = urlparse(settings.server.http_proxy_ipv6_url)
self.enable_server_proxy(url.hostname, url.port)

return self.execute(cmd)

def unregister(self):
Expand Down Expand Up @@ -915,6 +922,12 @@ def put_ssh_key(self, source_key_path, destination_key_name):
if result.status != 0:
raise CLIFactoryError(f'Failed to chmod ssh key file:\n{result.stderr}')

def enable_server_proxy(self, hostname, port=None):
cmd = f"subscription-manager config --server.proxy_hostname={hostname}"
if port:
cmd += f' --server.proxy_port={port}'
self.execute(cmd)

def add_authorized_key(self, pub_key):
"""Inject a public key into the authorized keys file
Expand Down Expand Up @@ -1459,7 +1472,7 @@ def install_tracer(self):
raise ContentHostError('There was an error installing katello-host-tools-tracer')
self.execute('katello-tracer-upload')

def register_to_cdn(self, pool_ids=None):
def register_to_cdn(self, pool_ids=None, enable_proxy=False):
"""Subscribe satellite to CDN"""
if pool_ids is None:
pool_ids = [settings.subscription.rhn_poolid]
Expand All @@ -1469,6 +1482,7 @@ def register_to_cdn(self, pool_ids=None):
lce=None,
username=settings.subscription.rhn_username,
password=settings.subscription.rhn_password,
enable_proxy=enable_proxy,
)
if cmd_result.status != 0:
raise ContentHostError(
Expand Down Expand Up @@ -1626,9 +1640,7 @@ def enable_capsule_downstream_repos(self):
def enable_ipv6_http_proxy(self):
if all([settings.server.is_ipv6, settings.server.http_proxy_ipv6_url]):
url = urlparse(settings.server.http_proxy_ipv6_url)
self.execute(
f'subscription-manager config --server.proxy_hostname={url.hostname} --server.proxy_port={url.port}'
)
self.enable_server_proxy(url.hostname, url.port)

def disable_ipv6_http_proxy(self):
if settings.server.is_ipv6:
Expand Down

0 comments on commit 2ee0fee

Please sign in to comment.