From effe311f8a199ca046f60687f1f9e4bc8517e430 Mon Sep 17 00:00:00 2001 From: Gaurav Talreja Date: Tue, 10 Dec 2024 23:01:03 +0530 Subject: [PATCH 1/3] Add ELS option for convert2rhel for EL7 Signed-off-by: Gaurav Talreja --- tests/foreman/api/test_convert2rhel.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/foreman/api/test_convert2rhel.py b/tests/foreman/api/test_convert2rhel.py index 5ae7a3ed392..fe723c6c421 100644 --- a/tests/foreman/api/test_convert2rhel.py +++ b/tests/foreman/api/test_convert2rhel.py @@ -280,6 +280,9 @@ def test_convert2rhel_oracle_with_pre_conversion_template_check( 'job_template_id': template_id, 'targeting_type': 'static_query', 'search_query': f'name = {oracle.hostname}', + 'inputs': { + 'ELS': 'yes' if major <= '7' else 'no', + }, }, ) # wait for job to complete @@ -301,6 +304,7 @@ def test_convert2rhel_oracle_with_pre_conversion_template_check( 'inputs': { 'Activation Key': activation_key_rhel.id, 'Restart': 'yes', + 'ELS': 'yes' if major <= '7' else 'no', }, 'targeting_type': 'static_query', 'search_query': f'name = {oracle.hostname}', @@ -370,6 +374,9 @@ def test_convert2rhel_centos_with_pre_conversion_template_check( 'job_template_id': template_id, 'targeting_type': 'static_query', 'search_query': f'name = {centos.hostname}', + 'inputs': { + 'ELS': 'yes' if major <= '7' else 'no', + }, }, ) # wait for job to complete @@ -392,6 +399,7 @@ def test_convert2rhel_centos_with_pre_conversion_template_check( 'inputs': { 'Activation Key': activation_key_rhel.id, 'Restart': 'yes', + 'ELS': 'yes' if major <= '7' else 'no', }, 'targeting_type': 'static_query', 'search_query': f'name = {centos.hostname}', From 2c0bf498880895fdb14ad9ba202c379ae91d6e88 Mon Sep 17 00:00:00 2001 From: Gaurav Talreja Date: Fri, 10 Jan 2025 17:19:23 +0530 Subject: [PATCH 2/3] Add ELS manifest fixtures, and update Convert2RHEL test to use ELS manifest Signed-off-by: Gaurav Talreja --- pytest_fixtures/component/taxonomy.py | 45 ++++++++++++++++++++++++++ tests/foreman/api/test_convert2rhel.py | 30 +++++++++-------- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/pytest_fixtures/component/taxonomy.py b/pytest_fixtures/component/taxonomy.py index 5d58a61b488..207ad864db8 100644 --- a/pytest_fixtures/component/taxonomy.py +++ b/pytest_fixtures/component/taxonomy.py @@ -138,6 +138,27 @@ def module_gt_manifest_org(module_target_sat): return org +@pytest.fixture +def function_els_sca_manifest_org(function_org, function_sca_els_manifest, target_sat): + """Creates an organization and uploads an SCA mode manifest generated with manifester""" + target_sat.upload_manifest(function_org.id, function_sca_els_manifest.content) + return function_org + + +@pytest.fixture(scope='module') +def module_els_sca_manifest_org(module_org, module_sca_els_manifest, module_target_sat): + """Creates an organization and uploads an SCA mode manifest generated with manifester""" + module_target_sat.upload_manifest(module_org.id, module_sca_els_manifest.content) + return module_org + + +@pytest.fixture(scope='class') +def class_els_sca_manifest_org(class_org, class_sca_els_manifest, class_target_sat): + """Creates an organization and uploads an SCA mode manifest generated with manifester""" + class_target_sat.upload_manifest(class_org.id, class_sca_els_manifest.content) + return class_org + + # Note: Manifester should not be used with the Satellite QE RHSM account until # subscription needs are scoped and sufficient subscriptions added to the # Satellite QE RHSM account. Manifester can be safely used locally with personal @@ -195,6 +216,30 @@ def second_function_sca_manifest(): yield manifest +@pytest.fixture(scope='module') +def module_sca_els_manifest(): + """Yields a manifest in Simple Content Access mode with subscriptions determined by the + `manifest_category.els_rhel_manifest` setting in conf/manifest.yaml.""" + with Manifester(manifest_category=settings.manifest.els_rhel_manifest) as manifest: + yield manifest + + +@pytest.fixture(scope='class') +def class_sca_els_manifest(): + """Yields a manifest in Simple Content Access mode with subscriptions determined by the + `manifest_category.els_rhel_manifest` setting in conf/manifest.yaml.""" + with Manifester(manifest_category=settings.manifest.els_rhel_manifest) as manifest: + yield manifest + + +@pytest.fixture +def function_sca_els_manifest(): + """Yields a manifest in Simple Content Access mode with subscriptions determined by the + `manifest_category.els_rhel_manifest` setting in conf/manifest.yaml.""" + with Manifester(manifest_category=settings.manifest.els_rhel_manifest) as manifest: + yield manifest + + @pytest.fixture(scope='module') def smart_proxy_location(module_org, module_target_sat, default_smart_proxy): location = module_target_sat.api.Location(organization=[module_org]).create() diff --git a/tests/foreman/api/test_convert2rhel.py b/tests/foreman/api/test_convert2rhel.py index fe723c6c421..830a455fdbf 100644 --- a/tests/foreman/api/test_convert2rhel.py +++ b/tests/foreman/api/test_convert2rhel.py @@ -50,27 +50,29 @@ def update_cv(sat, cv, lce, repos): @pytest.fixture(scope='module') -def ssl_cert(module_target_sat, module_sca_manifest_org): +def ssl_cert(module_target_sat, module_els_sca_manifest_org): """Create credetial with SSL cert for Oracle Linux""" res = requests.get(settings.repos.convert2rhel.ssl_cert_oracle) res.raise_for_status() return module_target_sat.api.ContentCredential( - content=res.text, organization=module_sca_manifest_org, content_type='cert' + content=res.text, organization=module_els_sca_manifest_org, content_type='cert' ).create() @pytest.fixture -def activation_key_rhel(module_target_sat, module_sca_manifest_org, module_lce, module_promoted_cv): +def activation_key_rhel( + module_target_sat, module_els_sca_manifest_org, module_lce, module_promoted_cv +): """Create activation key that will be used after conversion for registration""" return module_target_sat.api.ActivationKey( - organization=module_sca_manifest_org, + organization=module_els_sca_manifest_org, content_view=module_promoted_cv, environment=module_lce, ).create() @pytest.fixture(scope='module') -def enable_rhel_subscriptions(module_target_sat, module_sca_manifest_org, version): +def enable_rhel_subscriptions(module_target_sat, module_els_sca_manifest_org, version): """Enable and sync RHEL rpms repos""" major = version.split('.')[0] minor = '' @@ -85,7 +87,7 @@ def enable_rhel_subscriptions(module_target_sat, module_sca_manifest_org, versio for name in repo_names: rh_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( basearch=DEFAULT_ARCHITECTURE, - org_id=module_sca_manifest_org.id, + org_id=module_els_sca_manifest_org.id, product=REPOS[name]['product'], repo=REPOS[name]['name'] + minor, reposet=REPOS[name]['reposet'], @@ -112,7 +114,7 @@ def enable_rhel_subscriptions(module_target_sat, module_sca_manifest_org, versio def centos( module_target_sat, centos_host, - module_sca_manifest_org, + module_els_sca_manifest_org, smart_proxy_location, module_promoted_cv, module_lce, @@ -123,12 +125,12 @@ def centos( major = version.split('.')[0] assert centos_host.execute('yum -y update').status == 0 repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major) - repo = create_repo(module_target_sat, module_sca_manifest_org, repo_url) + repo = create_repo(module_target_sat, module_els_sca_manifest_org, repo_url) cv = update_cv( module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo] ) ak = module_target_sat.api.ActivationKey( - organization=module_sca_manifest_org, + organization=module_els_sca_manifest_org, content_view=cv, environment=module_lce, ).create() @@ -140,7 +142,7 @@ def centos( # Register CentOS host with Satellite result = centos_host.api_register( module_target_sat, - organization=module_sca_manifest_org, + organization=module_els_sca_manifest_org, activation_keys=[ak.name], location=smart_proxy_location, ) @@ -158,7 +160,7 @@ def centos( def oracle( module_target_sat, oracle_host, - module_sca_manifest_org, + module_els_sca_manifest_org, smart_proxy_location, module_promoted_cv, module_lce, @@ -195,12 +197,12 @@ def oracle( oracle_host.power_control(state='reboot') repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major) - repo = create_repo(module_target_sat, module_sca_manifest_org, repo_url, ssl_cert) + repo = create_repo(module_target_sat, module_els_sca_manifest_org, repo_url, ssl_cert) cv = update_cv( module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo] ) ak = module_target_sat.api.ActivationKey( - organization=module_sca_manifest_org, + organization=module_els_sca_manifest_org, content_view=cv, environment=module_lce, ).create() @@ -215,7 +217,7 @@ def oracle( # Register Oracle host with Satellite result = oracle_host.api_register( module_target_sat, - organization=module_sca_manifest_org, + organization=module_els_sca_manifest_org, activation_keys=[ak.name], location=smart_proxy_location, repo=ubi_url, From 94bacfab5f077064bf1eb05c851e3cc69f5f200c Mon Sep 17 00:00:00 2001 From: Gaurav Talreja Date: Sat, 11 Jan 2025 02:13:01 +0530 Subject: [PATCH 3/3] Add RHEL7 ELS repository constants and use it for Convert2RHEL tests Signed-off-by: Gaurav Talreja --- robottelo/constants/__init__.py | 20 ++++++++++++++++++-- tests/foreman/api/test_convert2rhel.py | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 7ef51f27892..ba7e7498492 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -272,12 +272,14 @@ 'rhel8': 'Red Hat Enterprise Linux for x86_64', 'rhel9': 'Red Hat Enterprise Linux for x86_64', 'rhel10_beta': 'Red Hat Enterprise Linux for x86_64 Beta', + 'rhel_els': 'Red Hat Enterprise Linux Server - Extended Life Cycle Support', } REPOSET = { 'rhct6': 'Red Hat CloudForms Tools for RHEL 6 (RPMs)', 'rhel6': 'Red Hat Enterprise Linux 6 Server (RPMs)', 'rhel7': 'Red Hat Enterprise Linux 7 Server (RPMs)', + 'rhel7_els': 'Red Hat Enterprise Linux 7 Server - Extended Life Cycle Support (RPMs)', 'rhva6': ('Red Hat Enterprise Virtualization Agents for RHEL 6 Server (RPMs)'), 'rhs7': 'Red Hat Satellite 6.11 (for RHEL 7 Server) (RPMs)', 'rhs8': 'Red Hat Satellite 6.13 for RHEL 8 x86_64 (RPMs)', @@ -356,8 +358,22 @@ 'releasever': '7Server', 'arch': 'x86_64', 'distro': 'rhel7', - 'reposet': REPOSET['rhel7'], - 'product': PRDS['rhel'], + 'reposet': REPOSET['rhel7_els'], + 'product': PRDS['rhel_els'], + 'major_version': 7, + 'distro_repository': True, + 'key': 'rhel', + 'version': '7.9', + 'basearch': 'x86_64', + }, + 'rhel7_els': { + 'id': 'rhel-7-server-els-rpms', + 'name': 'Red Hat Enterprise Linux 7 Server - Extended Life Cycle Support RPMs x86_64', + 'releasever': '7Server', + 'arch': 'x86_64', + 'distro': 'rhel7', + 'reposet': REPOSET['rhel7_els'], + 'product': PRDS['rhel_els'], 'major_version': 7, 'distro_repository': True, 'key': 'rhel', diff --git a/tests/foreman/api/test_convert2rhel.py b/tests/foreman/api/test_convert2rhel.py index 830a455fdbf..43697ff6fbf 100644 --- a/tests/foreman/api/test_convert2rhel.py +++ b/tests/foreman/api/test_convert2rhel.py @@ -80,7 +80,7 @@ def enable_rhel_subscriptions(module_target_sat, module_els_sca_manifest_org, ve repo_names = ['rhel8_bos', 'rhel8_aps'] minor = version[1:] else: - repo_names = ['rhel7'] + repo_names = ['rhel7_els'] rh_repos = [] tasks = []