Skip to content

Commit

Permalink
Removed the explicit http proxy teardowns
Browse files Browse the repository at this point in the history
  • Loading branch information
jyejare committed Jun 13, 2024
1 parent d447cb3 commit 3a63b78
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 31 deletions.
3 changes: 1 addition & 2 deletions pytest_fixtures/component/maintain.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ def module_stash(request):
def sat_maintain(request, module_target_sat, module_capsule_configured):
if settings.remotedb.server:
sat = Satellite(settings.remotedb.server)
http_proxy = sat.enable_ipv6_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
4 changes: 1 addition & 3 deletions pytest_fixtures/core/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ 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()
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 All @@ -36,7 +35,6 @@ def _target_sat_imp(request, _default_sat, satellite_factory):
else:
_default_sat.enable_ipv6_http_proxy()
yield _default_sat
_default_sat.disable_ipv6_http_proxy()


@pytest.fixture
Expand Down
10 changes: 2 additions & 8 deletions pytest_fixtures/core/sat_cap_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ 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()
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 All @@ -53,7 +52,6 @@ def _target_capsule_host(request, capsule_factory):
new_cap.enable_ipv6_http_proxy()
yield new_cap
new_cap.teardown()
new_cap.disable_ipv6_http_proxy()
Broker(hosts=[new_cap]).checkin()
elif request.config.option.n_minus:
if not settings.capsule.hostname:
Expand Down Expand Up @@ -101,7 +99,6 @@ def large_capsule_host(capsule_factory):
new_cap.enable_ipv6_http_proxy()
yield new_cap
new_cap.teardown()
new_cap.disable_ipv6_http_proxy()
Broker(hosts=[new_cap]).checkin()


Expand Down Expand Up @@ -254,7 +251,6 @@ def module_lb_capsule(retry_limit=3, delay=300, **broker_args):
yield cap_hosts.out

[cap.teardown() for cap in cap_hosts.out]
[cap.disable_ipv6_http_proxy() for cap in cap_hosts.out]
Broker(hosts=cap_hosts.out).checkin()


Expand Down Expand Up @@ -286,7 +282,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()
new_sat.enable_ipv6_http_proxy()
ipa_host = IPAHost(new_sat)
new_sat.register_to_cdn()
if 'IDM' in request.param:
Expand All @@ -298,7 +294,6 @@ 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 @@ -347,7 +342,6 @@ def cap_ready_rhel():
with Broker(**deploy_args, host_class=Capsule) as host:
host.enable_ipv6_http_proxy()
yield host
host.disable_ipv6_http_proxy()


@pytest.fixture(scope='session')
Expand Down
3 changes: 0 additions & 3 deletions pytest_fixtures/core/xdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ 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

worker_pos = 0 if worker_id in ["master", "local"] else int(worker_id.replace("gw", ""))

Expand All @@ -53,7 +52,6 @@ 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 @@ -73,5 +71,4 @@ def align_to_satellite(request, worker_id, satellite_factory):
f'{worker_id=}: Checking in on-demand Satellite ' f'{on_demand_sat.hostname}'
)
on_demand_sat.teardown()
on_demand_sat.disable_ipv6_http_proxy(http_proxy)
Broker(hosts=[on_demand_sat]).checkin()
2 changes: 1 addition & 1 deletion robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,7 @@ def register_contenthost(
enable_proxy=False,
):
"""Satellite Registration to CDN"""
# Enabling proxy for Ipv6
# 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_rhsm_proxy(url.hostname, url.port)
Expand Down
14 changes: 6 additions & 8 deletions robottelo/utils/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def is_ipv4_url(text):
return isinstance(text, str) and 'ipv4' in text and 'redhat.com' in text


def ipv6_translator(settings_list, setting_major, settings, data):
"""Translates the hostname containing ipv4 to ipv6 and updates the settings object"""
def ipv6_translator(settings_list, setting_major, data):
"""Translates the hostname containing IPv4 to IPv6 and updates the settings object"""
dotted_settings = '.'.join(setting_major)
for _key, _val in settings_list.items():
if is_ipv4_url(_val):
Expand All @@ -35,18 +35,16 @@ def ipv6_translator(settings_list, setting_major, settings, data):
logger.debug(f'Setting translated to IPv6, Path: {dotted_settings}.{_key}')
elif isinstance(_val, dict):
new_setting_major = setting_major + [_key]
ipv6_translator(
settings_list=_val, setting_major=new_setting_major, settings=settings, data=data
)
ipv6_translator(settings_list=_val, setting_major=new_setting_major, data=data)


def ipv6_hostname_translation(settings, data):
"""Migrates any ipv4 containing hostname in conf to ipv6 hostname"""
"""Migrates any IPv4 containing hostname in conf to IPv6 hostname"""
settings_path = []
if settings.server.is_ipv6:
all_settings = settings.loaded_by_loaders.items()
for loader_name, loader_settings in tuple(all_settings):
if loader_name.loader == 'yaml':
ipv6_translator(loader_settings, settings_path, settings, data)
ipv6_translator(loader_settings, settings_path, data)
else:
logger.debug('Ipv6 Hostname dynaconf migration hook is skipped for ipv4 testing')
logger.debug('IPv6 Hostname dynaconf migration hook is skipped for IPv4 testing')
10 changes: 4 additions & 6 deletions tests/foreman/installer/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ def sat_default_install(module_sat_ready_rhels):
]
install_satellite(module_sat_ready_rhels[0], installer_args)
sat = module_sat_ready_rhels[0]
http_proxy = sat.enable_ipv6_http_proxy()
yield sat
sat.disable_ipv6_http_proxy(http_proxy)
sat.enable_ipv6_http_proxy()
return sat


@pytest.fixture(scope='module')
Expand All @@ -179,10 +178,9 @@ def sat_non_default_install(module_sat_ready_rhels):
]
install_satellite(module_sat_ready_rhels[1], installer_args, enable_fapolicyd=True)
sat = module_sat_ready_rhels[1]
http_proxy = sat.enable_ipv6_http_proxy()
sat.enable_ipv6_http_proxy()
sat.execute('dnf -y --disableplugin=foreman-protector install foreman-discovery-image')
yield sat
sat.disable_ipv6_http_proxy(http_proxy)
return sat


@pytest.mark.e2e
Expand Down

0 comments on commit 3a63b78

Please sign in to comment.