Skip to content

Commit

Permalink
Initial pass, prt candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Oct 13, 2023
1 parent 40f8783 commit 3f6b2ee
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions tests/foreman/cli/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from robottelo.cli.activationkey import ActivationKey
from robottelo.cli.base import CLIReturnCodeError
from robottelo.cli.contentview import ContentView, ContentViewFilter
from robottelo.cli.contentview import ContentViewFilter
from robottelo.cli.erratum import Erratum
from robottelo.cli.factory import (
make_content_view_filter,
Expand Down Expand Up @@ -361,25 +361,28 @@ def filter_sort_errata(org, sort_by_date='issued', filter_by_org=None):
assert errata_ids == sorted_errata_ids


def cv_publish_promote(cv, org, lce):
def cv_publish_promote(sat, cv, lce):
"""Publish and promote a new version into the given lifecycle environment.
:param cv: content view
:type cv: entities.ContentView
:param org: organization
:type org: entities.Organization
#:param org: organization
#:type org: entities.Organization
:param lce: lifecycle environment
:type lce: entities.LifecycleEnvironment
"""
ContentView.publish({'id': cv.id})
cvv = ContentView.info({'id': cv.id})['versions'][-1]
ContentView.version_promote(
cv.publish()
cv = cv.read()
cvv = cv.version[-1].read()
cvv.promote(data={'environment_ids': lce.id, 'force': True})
"""ContentView.version_promote(
{
'id': cvv['id'],
'organization-id': org.id,
'to-lifecycle-environment-id': lce.id,
'activation-key-id': ak.id
}
)
)"""


def cv_filter_cleanup(filter_id, cv, org, lce):
Expand Down Expand Up @@ -689,7 +692,13 @@ def test_install_errata_to_one_host(
@pytest.mark.tier3
@pytest.mark.e2e
def test_positive_list_affected_chosts_by_erratum_restrict_flag(
target_sat, request, module_entitlement_manifest_org, module_cv, module_lce, errata_hosts
target_sat,
request,
module_entitlement_manifest_org,
module_cv,
module_lce,
errata_hosts,
module_ak,
):
"""View a list of affected content hosts for an erratum filtered
with restrict flags. Applicability is calculated using the Library,
Expand Down Expand Up @@ -721,13 +730,20 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag(
:CaseAutomation: Automated
"""
applicable_errata_num = {}
# Uninstall package so that only the first errata applies.
for host in errata_hosts:
host.execute(r'subscription-manager repos --enable \*')
host.execute(r'yum-config-manager --enable \*')
host.execute(f'yum erase -y {REPO_WITH_ERRATA["errata"][1]["package_name"]}')
host.execute('subscription-manager repos')
sleep(20)
sleep(20)
target_sat.cli.Host.errata_recalculate({'host-id': host.nailgun_host.id})
applicable_errata_num[host.hostname] = host.applicable_errata_count

for host in errata_hosts:
print(applicable_errata_num[host.hostname])

# Create list of uninstallable errata.
errata = REPO_WITH_ERRATA['errata'][0]
uninstallable = REPO_WITH_ERRATA['errata_ids'].copy()
Expand All @@ -740,20 +756,20 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag(
'per-page': PER_PAGE_LARGE,
}
errata_ids = get_errata_ids(param)
assert errata_ids, 'No installable errata found'
assert errata['id'] in errata_ids, 'Errata not found in list of installable errata'
assert not set(uninstallable) & set(errata_ids), 'Unexpected errata found'

# Check search of errata is not affected by installable=0 restrict flag
param = {
'errata-restrict-installable': 0,
'content-view-id': module_cv.id,
'lifecycle-environment-id': module_lce.id,
'organization-id': module_entitlement_manifest_org.id,
'per-page': PER_PAGE_LARGE,
}
errata_ids = get_errata_ids(param)
assert set(REPO_WITH_ERRATA['errata_ids']).issubset(
errata_ids
set(errata_ids)
), 'Errata not found in list of installable errata'

# Check list of applicable errata
Expand All @@ -773,7 +789,7 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag(
}
errata_ids = get_errata_ids(param)
assert set(REPO_WITH_ERRATA['errata_ids']).issubset(
errata_ids
set(errata_ids)
), 'Errata not found in list of applicable errata'

# Apply a filter and rule to the CV to hide the RPM, thus making erratum not installable
Expand Down Expand Up @@ -808,7 +824,7 @@ def cleanup():
)

# Publish and promote a new version with the filter
cv_publish_promote(module_cv, module_entitlement_manifest_org, module_lce)
cv_publish_promote(sat=target_sat, cv=module_cv, lce=module_lce)

# Check that the installable erratum is no longer present in the list
param = {
Expand Down

0 comments on commit 3f6b2ee

Please sign in to comment.