Skip to content

Commit

Permalink
Enabling Robottelo for IPv6 Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jyejare committed Mar 20, 2024
1 parent 73b7bd2 commit 52ae4c7
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 7 deletions.
4 changes: 4 additions & 0 deletions conf/server.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ SERVER:
SOURCE: "internal"
# The RHEL Base OS Version(x.y) where the Satellite is installed
RHEL_VERSION: '7'
# If the the satellite server is IPv6 server
# IS_IPV6:
# HTTP Proxy url for IPv6 satellite to connect for outer world access
# HTTP_PROXY_IPv6_URL:
# run-on-one - All xdist runners default to the first satellite
# balance - xdist runners will be split between available satellites
# on-demand - any xdist runner without a satellite will have a new one provisioned.
Expand Down
5 changes: 4 additions & 1 deletion pytest_fixtures/component/maintain.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ def module_stash(request):
@pytest.fixture(scope='module')
def sat_maintain(request, module_target_sat, module_capsule_configured):
if settings.remotedb.server:
yield Satellite(settings.remotedb.server)
sat = Satellite(settings.remotedb.server)
http_proxy = sat.enable_ipv6_http_proxy()
yield sat
sat.disable_ipv6_http_proxy(http_proxy)
else:
module_target_sat.register_to_cdn(pool_ids=settings.subscription.fm_rhn_poolid.split())
hosts = {'satellite': module_target_sat, 'capsule': module_capsule_configured}
Expand Down
7 changes: 6 additions & 1 deletion pytest_fixtures/core/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def _default_sat(align_to_satellite):
"""Returns a Satellite object for settings.server.hostname"""
if settings.server.hostname:
try:
return Satellite.get_host_by_hostname(settings.server.hostname)
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)
except ContentHostError:
return Satellite()
return None
Expand All @@ -24,8 +27,10 @@ def _target_sat_imp(request, _default_sat, satellite_factory):
"""This is the actual working part of the following target_sat fixtures"""
if request.node.get_closest_marker(name='destructive'):
new_sat = satellite_factory()
http_proxy = new_sat.sat.enable_ipv6_http_proxy()
yield new_sat
new_sat.teardown()
new_sat.disable_ipv6_http_proxy(http_proxy)
Broker(hosts=[new_sat]).checkin()
elif 'sanity' in request.config.option.markexpr:
installer_sat = lru_sat_ready_rhel(settings.server.version.rhel_version)
Expand Down
16 changes: 13 additions & 3 deletions pytest_fixtures/core/sat_cap_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ def resolve_deploy_args(args_dict):
def _target_satellite_host(request, satellite_factory):
if 'sanity' not in request.config.option.markexpr:
new_sat = satellite_factory()
http_proxy = new_sat.enable_ipv6_http_proxy()
yield new_sat
new_sat.teardown()
new_sat.disable_ipv6_http_proxy(http_proxy)
Broker(hosts=[new_sat]).checkin()
else:
yield
Expand Down Expand Up @@ -94,6 +96,7 @@ def factory(retry_limit=3, delay=300, workflow=None, **broker_args):
def large_capsule_host(capsule_factory):
"""A fixture that provides a Capsule based on config settings"""
new_cap = capsule_factory(deploy_flavor=settings.flavors.custom_db)
# TO_DO - a question to resolve - How does the dynamic capsule talks to the CDN for contents ?
yield new_cap
new_cap.teardown()
Broker(hosts=[new_cap]).checkin()
Expand All @@ -117,6 +120,7 @@ def factory(retry_limit=3, delay=300, workflow=None, **broker_args):
)
timeout = (1200 + delay) * retry_limit
cap = wait_for(vmb.checkout, timeout=timeout, delay=delay, fail_condition=[])
## TO-DO: Need to add http proxy here for this capsule to talk outside/CDN
return cap.out

return factory
Expand Down Expand Up @@ -244,6 +248,7 @@ def module_lb_capsule(retry_limit=3, delay=300, **broker_args):
)
cap_hosts = wait_for(hosts.checkout, timeout=timeout, delay=delay)

## TO_DO : Need to add Proxy here for these capsules
yield cap_hosts.out

[cap.teardown() for cap in cap_hosts.out]
Expand All @@ -266,6 +271,7 @@ def parametrized_enrolled_sat(
):
"""Yields a Satellite enrolled into [IDM, AD] as parameter."""
new_sat = satellite_factory()
http_proxy = new_sat.enable_ipv6_http_proxy()
ipa_host = IPAHost(new_sat)
new_sat.register_to_cdn()
if 'IDM' in request.param:
Expand All @@ -277,6 +283,7 @@ def parametrized_enrolled_sat(
yield new_sat
new_sat.unregister()
new_sat.teardown()
new_sat.disable_ipv6_http_proxy(http_proxy)
Broker(hosts=[new_sat]).checkin()


Expand Down Expand Up @@ -321,6 +328,7 @@ def cap_ready_rhel():
'workflow': settings.capsule.deploy_workflows.os,
}
with Broker(**deploy_args, host_class=Capsule) as host:
## TO_DO: Need to add Proxy here for this capsule
yield host


Expand All @@ -339,6 +347,7 @@ 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.download_repofile(
Expand All @@ -364,7 +373,8 @@ def installer_satellite(request):
configure_airgun()
yield sat
if 'sanity' not in request.config.option.markexpr:
sanity_sat = Satellite(sat.hostname)
sanity_sat.unregister()
broker_sat = Satellite.get_host_by_hostname(sanity_sat.hostname)
sat = Satellite(sat.hostname)
sat.unregister()
broker_sat = Satellite.get_host_by_hostname(sat.hostname)
Broker(hosts=[broker_sat]).checkin()
sat.disable_ipv6_http_proxy(http_proxy)
3 changes: 3 additions & 0 deletions pytest_fixtures/core/xdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def align_to_satellite(request, worker_id, satellite_factory):
# clear any hostname that may have been previously set
settings.set("server.hostname", None)
on_demand_sat = None
http_proxy = None

if worker_id in ['master', 'local']:
worker_pos = 0
Expand All @@ -44,6 +45,7 @@ def align_to_satellite(request, worker_id, satellite_factory):
# get current satellite information
elif settings.server.xdist_behavior == 'on-demand':
on_demand_sat = satellite_factory()
http_proxy = on_demand_sat.enable_ipv6_http_proxy()
if on_demand_sat.hostname:
settings.set("server.hostname", on_demand_sat.hostname)
# if no satellite was received, fallback to balance
Expand All @@ -58,4 +60,5 @@ def align_to_satellite(request, worker_id, satellite_factory):
yield
if on_demand_sat and settings.server.auto_checkin:
on_demand_sat.teardown()
on_demand_sat.disable_ipv6_http_proxy(http_proxy)
Broker(hosts=[on_demand_sat]).checkin()
43 changes: 43 additions & 0 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,7 @@ def capsule_setup(self, sat_host=None, capsule_cert_opts=None, **installer_kwarg
self.satellite.session.remote_copy(certs_tar, self)
installer.update(**installer_kwargs)
result = self.install(installer)
## TO_DO : Add a http proxy for this to communicate outside
if result.status:
# before exit download the capsule log file
self.session.sftp_read(
Expand Down Expand Up @@ -1776,6 +1777,48 @@ def _swap_nailgun(self, new_version):
to_clear = [k for k in sys.modules if 'nailgun' in k]
[sys.modules.pop(k) for k in to_clear]

def enable_ipv6_http_proxy(self):
# Execute procedures for enabling IPv6 HTTP Proxy
if all[settings.server.is_ipv6, settings.server.http_proxy_ipv6_url]:
proxy_name = 'Robottelo IPv6 Automation Proxy'
if self.cli.HttpProxy.exists(search=('name', proxy_name)):
http_proxy = self.cli.HttpProxy.create(
{
'name': proxy_name,
'url': settings.server.http_proxy_ipv6_url,
}
)
self.cli.Settings.set(
{
'name': 'content_default_http_proxy',
'value': proxy_name,
}
)
return http_proxy
else:
logger.info(
'The IPv6 HTTP Proxy is already enabled!! Skipping the IPv6 HTTP Proxy setup.'
)
http_proxy = self.cli.HttpProxy.list({'search': f'name={proxy_name}'})
if http_proxy:
return http_proxy[0]
else:
logger.warning(
'The IPv6 HTTP Proxy setting is not enabled!! Skipping the IPv6 HTTP Proxy setup.'
)

def disable_ipv6_http_proxy(self, http_proxy):
# Execute procedures for enabling IPv6 HTTP Proxy
if http_proxy:
# TO_DO: Enable only if its not already enabled
self.cli.HttpProxy.delete({'id': http_proxy['id']})
self.cli.Settings.set(
{
'name': 'content_default_http_proxy',
'value': '',
}
)

@property
def api(self):
"""Import all nailgun entities and wrap them under self.api"""
Expand Down
10 changes: 8 additions & 2 deletions tests/foreman/installer/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1381,8 +1381,11 @@ def sat_default_install(module_sat_ready_rhels):
f'foreman-initial-admin-password {settings.server.admin_password}',
]
install_satellite(module_sat_ready_rhels[0], installer_args)
yield module_sat_ready_rhels[0]
sat = module_sat_ready_rhels[0]
http_proxy = sat.enable_ipv6_http_proxy()
yield
common_sat_install_assertions(module_sat_ready_rhels[0])
sat.disable_ipv6_http_proxy(http_proxy)


@pytest.fixture(scope='module')
Expand All @@ -1395,8 +1398,11 @@ def sat_non_default_install(module_sat_ready_rhels):
'foreman-proxy-content-pulpcore-hide-guarded-distributions false',
]
install_satellite(module_sat_ready_rhels[1], installer_args, enable_fapolicyd=True)
yield module_sat_ready_rhels[1]
sat = module_sat_ready_rhels[1]
http_proxy = sat.enable_ipv6_http_proxy()
yield sat
common_sat_install_assertions(module_sat_ready_rhels[1])
sat.disable_ipv6_http_proxy(http_proxy)


@pytest.mark.e2e
Expand Down

0 comments on commit 52ae4c7

Please sign in to comment.