From 3a63b787512e06b444fd60d3fd387078428214ec Mon Sep 17 00:00:00 2001 From: jyejare Date: Mon, 10 Jun 2024 18:34:04 +0530 Subject: [PATCH] Removed the explicit http proxy teardowns --- pytest_fixtures/component/maintain.py | 3 +-- pytest_fixtures/core/broker.py | 4 +--- pytest_fixtures/core/sat_cap_factory.py | 10 ++-------- pytest_fixtures/core/xdist.py | 3 --- robottelo/hosts.py | 2 +- robottelo/utils/url.py | 14 ++++++-------- tests/foreman/installer/test_installer.py | 10 ++++------ 7 files changed, 15 insertions(+), 31 deletions(-) diff --git a/pytest_fixtures/component/maintain.py b/pytest_fixtures/component/maintain.py index e2da180f646..1e0e264e0ca 100644 --- a/pytest_fixtures/component/maintain.py +++ b/pytest_fixtures/component/maintain.py @@ -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} diff --git a/pytest_fixtures/core/broker.py b/pytest_fixtures/core/broker.py index fd1c386a34a..0b9c114211d 100644 --- a/pytest_fixtures/core/broker.py +++ b/pytest_fixtures/core/broker.py @@ -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) @@ -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 diff --git a/pytest_fixtures/core/sat_cap_factory.py b/pytest_fixtures/core/sat_cap_factory.py index 6ee72bcb412..4c38c77546f 100644 --- a/pytest_fixtures/core/sat_cap_factory.py +++ b/pytest_fixtures/core/sat_cap_factory.py @@ -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 @@ -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: @@ -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() @@ -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() @@ -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: @@ -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() @@ -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') diff --git a/pytest_fixtures/core/xdist.py b/pytest_fixtures/core/xdist.py index a703b1911d3..216589e85d7 100644 --- a/pytest_fixtures/core/xdist.py +++ b/pytest_fixtures/core/xdist.py @@ -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", "")) @@ -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 @@ -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() diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 832eb0693b8..68c789d050c 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -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) diff --git a/robottelo/utils/url.py b/robottelo/utils/url.py index 5f4d4f7a49f..a84a85d4c1c 100644 --- a/robottelo/utils/url.py +++ b/robottelo/utils/url.py @@ -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): @@ -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') diff --git a/tests/foreman/installer/test_installer.py b/tests/foreman/installer/test_installer.py index 9c5181509db..506dddef312 100644 --- a/tests/foreman/installer/test_installer.py +++ b/tests/foreman/installer/test_installer.py @@ -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') @@ -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