Skip to content

Commit

Permalink
Add ELS manifest fixtures, and update Convert2RHEL test to use ELS ma…
Browse files Browse the repository at this point in the history
…nifest

Signed-off-by: Gaurav Talreja <[email protected]>
  • Loading branch information
Gauravtalreja1 committed Jan 10, 2025
1 parent 6c6977d commit 80a20aa
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 14 deletions.
45 changes: 45 additions & 0 deletions pytest_fixtures/component/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
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
Expand Down Expand Up @@ -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.golden_ticket` 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.golden_ticket` 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.golden_ticket` 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()
Expand Down
30 changes: 16 additions & 14 deletions tests/foreman/api/test_convert2rhel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand All @@ -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'],
Expand All @@ -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,
Expand All @@ -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()
Expand All @@ -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,
)
Expand All @@ -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,
Expand Down Expand Up @@ -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()
Expand All @@ -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,
Expand Down

0 comments on commit 80a20aa

Please sign in to comment.