Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Dec 17, 2024
1 parent 7c22f61 commit ac2e263
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 133 deletions.
59 changes: 52 additions & 7 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
)


DISTRO_DEFAULT = 'rhel7'
DISTROS_SUPPORTED = ['rhel6', 'rhel7', 'rhel8', 'rhel9']
DISTRO_DEFAULT = 'rhel9'
DISTROS_SUPPORTED = ['rhel6', 'rhel7', 'rhel8', 'rhel9', 'rhel10']
DISTROS_MAJOR_VERSION = {
'rhel6': 6,
'rhel7': 7,
'rhel8': 8,
'rhel9': 9,
'rhel10': 10,
}
MAJOR_VERSION_DISTRO = {value: key for key, value in DISTROS_MAJOR_VERSION.items()}

Expand Down Expand Up @@ -303,14 +304,16 @@
'rhel8_bos': 'Red Hat Enterprise Linux 8 for x86_64 - BaseOS (Kickstart)',
'rhel8_aps': 'Red Hat Enterprise Linux 8 for x86_64 - AppStream (Kickstart)',
'rhel9_bos': 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS (Kickstart)',
'rhel9_aps': 'Red Hat Enterprise Linux 9 for x86_64 - AppStream (Kickstart)',
'rhel10_bos': 'Red Hat Enterprise Linux 10 for x86_64 - BaseOS (Kickstart)',
'rhel10_aps': 'Red Hat Enterprise Linux 10 for x86_64 - AppStream (Kickstart)',
'rhel9_aps': 'Red Hat Enterprise Linux 9 for x86_64 - AppStream (Kickstart)',
},
'rhel8_bos': 'Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)',
'rhel8_aps': 'Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)',
'rhel9_bos': 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)',
'rhel10_bos': 'Red Hat Enterprise Linux 10 for x86_64 - BaseOS (RPMs)',
'rhel10_aps': 'Red Hat Enterprise Linux 10 for x86_64 - AppStream (RPMs)',
'rhel9_bos': 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)',
'rhel9_aps': 'Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)',
'rhel8_bos': 'Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)',
'rhel8_aps': 'Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)',
'rhel7_extra': 'Red Hat Enterprise Linux 7 Server - Extras (RPMs)',
'rhel7_optional': 'Red Hat Enterprise Linux 7 Server - Optional (RPMs)',
'rhel7_sup': 'Red Hat Enterprise Linux 7 Server - Supplementary (RPMs)',
Expand Down Expand Up @@ -561,6 +564,44 @@
'product': PRDS['rhel9'],
'distro': 'rhel9',
},
'rhel10_bos': {
'id': 'rhel-10-for-x86_64-baseos-kickstart',
'name': 'Red Hat Enterprise Linux 10 for x86_64 - BaseOS (Kickstart) 10.0',
'version': '10.0',
'reposet': REPOSET['kickstart']['rhel10_bos'],
'product': PRDS['rhel10'],
'distro': 'rhel10',
},
'rhel10_aps': {
'id': 'rhel-10-for-x86_64-appstream-kickstart',
'name': 'Red Hat Enterprise Linux 10 for x86_64 - AppStream Kickstart 10.0',
'version': '10.0',
'reposet': REPOSET['kickstart']['rhel10_aps'],
'product': PRDS['rhel10'],
'distro': 'rhel10',
},
},
'rhel10_bos': {
'id': 'rhel-10-for-x86_64-baseos-rpms',
'name': 'Red Hat Enterprise Linux 10 for x86_64 - BaseOS RPMs 10',
'releasever': '10',
'basearch': 'x86_64',
'version': '10.0',
'reposet': REPOSET['rhel10_bos'],
'product': PRDS['rhel10'],
'distro': 'rhel10',
'key': 'rhel10_bos',
},
'rhel10_aps': {
'id': 'rhel-10-for-x86_64-appstream-rpms',
'name': 'Red Hat Enterprise Linux 10 for x86_64 - AppStream RPMs 10',
'releasever': '10',
'basearch': 'x86_64',
'version': '10.0',
'reposet': REPOSET['rhel10_aps'],
'product': PRDS['rhel10'],
'distro': 'rhel10',
'key': 'rhel10_aps',
},
'rhel8_bos': {
'id': 'rhel-8-for-x86_64-baseos-rpms',
Expand Down Expand Up @@ -807,7 +848,11 @@
REAL_RHEL8_1_PACKAGE_FILENAME = 'puppet-agent-6.19.1-1.el8sat.x86_64'
REAL_RHEL8_2_PACKAGE_FILENAME = 'puppet-agent-6.26.0-1.el8sat.x86_64'
REAL_RHEL9_PACKAGE_FILENAME = ''
REAL_RHEL10_PACKAGE_FILENAME = ''
REAL_RHEL10_REPO_URL = 'https://download.eng.bos.redhat.com/rhel-10/composes/RHEL-10/'
REAL_RHEL10_PACKAGE_NAME = ''
REAL_RHEL10_OUTDATED_PACKAGE = ''
REAL_RHEL10_UPDATED_PACKAGE = ''
REAL_RHEL10_ERRATA_ID = ''
FAKE_0_CUSTOM_PACKAGE_GROUP_NAME = 'birds'
FAKE_3_YUM_OUTDATED_PACKAGES = [
'acme-package-1.0.1-1.noarch',
Expand Down
174 changes: 92 additions & 82 deletions tests/foreman/api/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,92 @@ def custom_repo(module_sca_manifest_org, module_lce, module_cv, activation_key,
)


@pytest.fixture(scope='module')
def rh_repo_module_manifest(module_sca_manifest_org, module_target_sat):
"""Use module manifest org, creates RHEL8 sat-tools repo, syncs and returns RH repo."""
# enable rhel repo and return its ID
rh_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid(
basearch=DEFAULT_ARCHITECTURE,
org_id=module_sca_manifest_org.id,
product=PRDS['rhel8'],
repo=REPOS['rhst8']['name'],
reposet=REPOSET['rhst8'],
releasever='None',
)
# Sync step because repo is not synced by default
rh_repo = module_target_sat.api.Repository(id=rh_repo_id).read()
rh_repo.sync()
return rh_repo


@pytest.fixture(scope='module')
def rhel10_module_repo(module_sca_manifest_org, module_target_sat):
"""In module manifest org, creates RHEL10 repo with synced content, returns it."""
repo_id = module_target_sat.api_factory.create_sync_custom_repo(
module_sca_manifest_org.id,
repo_url=settings.repos.RHEL10_OS.APPSTREAM,
)
return module_target_sat.api.Repository(id=repo_id).read()


@pytest.fixture(scope='module')
def setup_fake_yum_content(
module_sca_manifest_org,
rhel10_module_repo,
activation_key,
module_lce,
module_cv,
module_target_sat,
return_result=True,
):
"""Setup yum content for rhel content host w/ errata
Using RHEL10 Appstream RH repo, and custom repo FAKE_YUM_9.
Published to content-view and promoted to lifecycle-environment.
Raises `AssertionError` if one or more of the setup components read are empty.
:return: if return_result is True: otherwise None
A dictionary (_result) with the satellite instances of activaton-key, organization,
content-view, lifecycle-environment, rh_repo, custom_repo.
"""
org = module_sca_manifest_org
# Setup Custom and RH repos
custom_repo_id = module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': CUSTOM_REPO_URL,
'organization-id': org.id,
'lifecycle-environment-id': module_lce.id,
'activationkey-id': activation_key.id,
'content-view-id': module_cv.id,
}
)['repository-id']
custom_repo = module_target_sat.api.Repository(id=custom_repo_id).read()
custom_repo.sync()
# Sync and add RH repo
rh_repo = module_target_sat.api.Repository(id=rhel10_module_repo.id).read()
rh_repo.sync()
module_target_sat.cli.ContentView.add_repository(
{'id': module_cv.id, 'organization-id': org.id, 'repository-id': rh_repo.id}
)
_cv = cv_publish_promote(module_target_sat, org, module_cv, module_lce)
module_cv = _cv['content-view']
latest_cvv = _cv['content-view-version']

_result = {
'activation-key': activation_key.read(),
'organization': org.read(),
'content-view': module_cv.read(),
'content-view-version': latest_cvv.read(),
'lifecycle-environment': module_lce.read(),
'rh_repo': rh_repo.read(),
'custom_repo': custom_repo.read(),
}
assert all(
entry for entry in _result.values()
), f'One or more necessary components are not present: {_result}'
return _result if return_result else None


def _validate_errata_counts(host, errata_type, expected_value, timeout=120):
"""Check whether host contains expected errata counts."""
for _ in range(timeout // 5):
Expand Down Expand Up @@ -1007,64 +1093,6 @@ def test_positive_list_sorted_filtered(custom_repo, target_sat):
assert cve_ids == sorted(cve_ids, reverse=True)


@pytest.fixture(scope='module')
def setup_fake_yum_content(
module_sca_manifest_org,
rh_repo_module_manifest,
activation_key,
module_lce,
module_cv,
module_target_sat,
return_result=True,
):
"""Setup yum content for rhel content host w/ errata
Using rh repo satellite-tools, and custom repo FAKE_YUM_9.
Published to content-view and promoted to lifecycle-environment.
Raises `AssertionError` if one or more of the setup components read are empty.
:return: if return_result is True: otherwise None
A dictionary (_result) with the satellite instances of activaton-key, organization,
content-view, lifecycle-environment, rh_repo, custom_repo.
"""
org = module_sca_manifest_org
# Setup Custom and RH repos
custom_repo_id = module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': CUSTOM_REPO_URL,
'organization-id': org.id,
'lifecycle-environment-id': module_lce.id,
'activationkey-id': activation_key.id,
'content-view-id': module_cv.id,
}
)['repository-id']
custom_repo = module_target_sat.api.Repository(id=custom_repo_id).read()
custom_repo.sync()
# Sync and add RH repo
rh_repo = module_target_sat.api.Repository(id=rh_repo_module_manifest.id).read()
rh_repo.sync()
module_target_sat.cli.ContentView.add_repository(
{'id': module_cv.id, 'organization-id': org.id, 'repository-id': rh_repo.id}
)
_cv = cv_publish_promote(module_target_sat, org, module_cv, module_lce)
module_cv = _cv['content-view']
latest_cvv = _cv['content-view-version']

_result = {
'activation-key': activation_key.read(),
'organization': org.read(),
'content-view': module_cv.read(),
'content-view-version': latest_cvv.read(),
'lifecycle-environment': module_lce.read(),
'rh_repo': rh_repo.read(),
'custom_repo': custom_repo.read(),
}
assert all(
entry for entry in _result.values()
), f'One or more necessary components are not present: {_result}'
return _result if return_result else None


@pytest.mark.tier2
def test_positive_get_count_for_host(
setup_fake_yum_content, activation_key, rhel10_contenthost, module_target_sat
Expand Down Expand Up @@ -1135,10 +1163,10 @@ def test_positive_get_count_for_host(
@pytest.mark.upgrade
@pytest.mark.tier3
def test_positive_get_applicable_for_host(
activation_key,
setup_fake_yum_content,
rhel10_contenthost,
activation_key,
target_sat,
setup_fake_yum_content,
):
"""Get applicable errata ids for a host
Expand All @@ -1163,9 +1191,8 @@ def test_positive_get_applicable_for_host(
:CaseImportance: Medium
"""
org = setup_fake_yum_content['organization']
custom_repo = setup_fake_yum_content['rh_repo']

rhel10_contenthost.create_custom_repos(**{f'{custom_repo.name}': custom_repo.url})
# rh_repo = setup_fake_yum_content['rh_repo']
# rhel10_contenthost.create_custom_repos(**{f'{rh_repo.name}': rh_repo.url})
result = rhel10_contenthost.register(
activation_keys=activation_key.name,
target=target_sat,
Expand Down Expand Up @@ -1196,7 +1223,8 @@ def test_positive_get_applicable_for_host(
assert len(erratum) == 1
assert CUSTOM_REPO_ERRATA_ID in [errata['errata_id'] for errata in erratum]
# Install outdated applicable real package (from RH repo)
rhel10_contenthost.run(f'yum install -y {REAL_RHEL8_1_PACKAGE_FILENAME}')
# rhel10_contenthost.run(f'yum install -y {REAL_RHEL8_1_PACKAGE_FILENAME}')
# rhel10_contenthost.run(f'yum install -y {REAL_RHEL10_OUTDATED_FILENAME}')
erratum = _fetch_available_errata(host, 2)
assert len(erratum) == 2
assert REAL_RHEL8_1_ERRATA_ID in [errata['errata_id'] for errata in erratum]
Expand Down Expand Up @@ -1355,24 +1383,6 @@ def errata_host_lce(module_sca_manifest_org, target_sat):
return target_sat.api.LifecycleEnvironment(organization=module_sca_manifest_org).create()


@pytest.fixture(scope='module')
def rh_repo_module_manifest(module_sca_manifest_org, module_target_sat):
"""Use module manifest org, creates RHEL8 tools repo, syncs and returns RH repo."""
# enable rhel repo and return its ID
rh_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid(
basearch=DEFAULT_ARCHITECTURE,
org_id=module_sca_manifest_org.id,
product=PRDS['rhel8'],
repo=REPOS['rhst8']['name'],
reposet=REPOSET['rhst8'],
releasever='None',
)
# Sync step because repo is not synced by default
rh_repo = module_target_sat.api.Repository(id=rh_repo_id).read()
rh_repo.sync()
return rh_repo


@pytest.mark.tier3
def test_positive_incremental_update_apply_to_envs_cvs(
target_sat,
Expand Down
4 changes: 4 additions & 0 deletions tests/foreman/longrun/test_oscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@
from robottelo.logging import logger

ak_name = {
'rhel10': f'ak_{gen_string("alpha")}_rhel10',
'rhel9': f'ak_{gen_string("alpha")}_rhel9',
'rhel8': f'ak_{gen_string("alpha")}_rhel8',
'rhel7': f'ak_{gen_string("alpha")}_rhel7',
}
cv_name = {
'rhel10': f'cv_{gen_string("alpha")}_rhel10',
'rhel9': f'cv_{gen_string("alpha")}_rhel9',
'rhel8': f'cv_{gen_string("alpha")}_rhel8',
'rhel7': f'cv_{gen_string("alpha")}_rhel7',
}
profiles = {
'rhel10': OSCAP_PROFILE[''],
'rhel9': OSCAP_PROFILE['cbrhel9'],
'rhel8': OSCAP_PROFILE['ospp8'],
'rhel7': OSCAP_PROFILE['security7'],
}
rhel_repos = {
'rhel10': settings.repos.rhel10_os,
'rhel9': settings.repos.rhel9_os,
'rhel8': settings.repos.rhel8_os,
'rhel7': settings.repos.rhel7_os,
Expand Down
Loading

0 comments on commit ac2e263

Please sign in to comment.