Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,27 @@
]
FAKE_9_YUM_SECURITY_ERRATUM_COUNT = len(FAKE_9_YUM_SECURITY_ERRATUM)

# Packages listed directly in the 3 security errata above
FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES = [
'bear-4.1-1.noarch',
'crow-0.8-1.noarch',
'duck-0.6-1.noarch',
'penguin-0.9.1-1.noarch',
'shark-0.1-1.noarch',
'stork-0.12-2.noarch',
'walrus-5.21-1.noarch',
]

# Transitive dependencies of the security erratum packages:
# penguin->dolphin->{lion,tiger}, duck->{cockateel,lion}, cockateel->wolf, lion->wolf
FAKE_9_YUM_SECURITY_ERRATUM_DEPS = [
'cockateel-3.1-1.noarch',
'dolphin-3.10.232-1.noarch',
'lion-0.4-1.noarch',
'tiger-1.0-4.noarch',
'wolf-9.4-2.noarch',
]

FAKE_10_YUM_BUGFIX_ERRATUM = [
'RHBA-2012:1030',
]
Expand Down
90 changes: 90 additions & 0 deletions tests/foreman/api/test_contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
FAKE_1_CUSTOM_PACKAGE_NAME,
FAKE_1_ERRATA_ID,
FAKE_2_CUSTOM_PACKAGE,
FAKE_9_YUM_SECURITY_ERRATUM,
FAKE_9_YUM_SECURITY_ERRATUM_DEPS,
FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES,
PERMISSIONS,
PRDS,
REPOS,
Expand Down Expand Up @@ -2476,6 +2479,93 @@ def test_ccv_publish_dependency_chaining(self, module_target_sat, module_sca_man
ccv = ccv.read()
assert set(v.read().version for v in ccv.version) == {'1.0'}

@pytest.mark.parametrize(
'resolve_dependencies',
[True, False, None],
ids=['dep_solving_enabled', 'dep_solving_disabled', 'dep_solving_default'],
)
def test_positive_inc_update_resolve_dependencies(
self,
target_sat,
module_org,
module_product,
resolve_dependencies,
):
"""Verify that the resolve_dependencies parameter controls whether
dependency packages are included in an incremental content view update.

:id: fa45c92d-d1df-4805-833a-bc6c25b8747c

:parametrized: yes

:steps:
1. Create and sync a custom yum repository containing errata
whose packages have known dependency chains.
2. Create a content view with the repository, add an erratum
inclusion filter with no rules to exclude all errata and
their packages, then publish.
3. Perform an incremental update to add 3 security errata back,
with resolve_dependencies set to True, False, or omitted
entirely to test the server default.

:expectedresults:
1. With resolve_dependencies=True, the incremental version includes
the direct errata packages and their transitive dependency
packages (12 total).
2. With resolve_dependencies=False, the incremental version includes
only the direct errata packages (7 total).
3. With resolve_dependencies omitted, the server default (False)
applies and only direct errata packages are included (7 total).
"""
repo = target_sat.api.Repository(
product=module_product,
url=settings.repos.yum_9.url,
).create()
repo.sync()

cv = target_sat.api.ContentView(
organization=module_org,
repository=[repo],
).create()
# Erratum inclusion filter with no rules: excludes all errata and
# their associated packages from the published version.
target_sat.api.ErratumContentViewFilter(
content_view=cv,
inclusion=True,
).create()
cv.publish()
cv = cv.read()
cvv = cv.version[0]

inc_data = {
'content_view_version_environments': [
{
'content_view_version_id': cvv.id,
'environment_ids': [module_org.library.id],
}
],
'add_content': {'errata_ids': FAKE_9_YUM_SECURITY_ERRATUM},
}
if resolve_dependencies is not None:
inc_data['resolve_dependencies'] = resolve_dependencies

response = target_sat.api.ContentViewVersion().incremental_update(data=inc_data)
assert response['result'] == 'success'

added_errata = response['output']['changed_content'][0]['added_units']['erratum']
added_packages = set(response['output']['changed_content'][0]['added_units']['rpm'])
# All 3 security errata are added regardless of resolve_dependencies
assert set(added_errata) == set(FAKE_9_YUM_SECURITY_ERRATUM)

expected = set(FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES)
if resolve_dependencies:
expected |= set(FAKE_9_YUM_SECURITY_ERRATUM_DEPS)

assert added_packages == expected, (
f'Expected {"direct + dependency" if resolve_dependencies else "only direct errata"} '
f'packages, got {sorted(added_packages)}'
)


class TestContentViewUpdate:
"""Tests for updating content views."""
Expand Down
8 changes: 6 additions & 2 deletions tests/foreman/api/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
FAKE_5_CUSTOM_PACKAGE,
FAKE_9_YUM_OUTDATED_PACKAGES,
FAKE_9_YUM_SECURITY_ERRATUM,
FAKE_9_YUM_SECURITY_ERRATUM_DEPS,
FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES,
FAKE_9_YUM_UPDATED_PACKAGES,
PRDS,
REAL_RHEL8_1_ERRATA_ID,
Expand Down Expand Up @@ -1568,6 +1570,7 @@ def test_positive_incremental_update_apply_to_envs_cvs(
}
],
'add_content': {'errata_ids': FAKE_9_YUM_SECURITY_ERRATUM},
'resolve_dependencies': True,
}
)
assert response['result'] == 'success'
Expand Down Expand Up @@ -1603,9 +1606,10 @@ def test_positive_incremental_update_apply_to_envs_cvs(
# newly added errata from incremental version are now applicable to host
post_app_errata_ids = errata_id_set(_fetch_available_errata_instances(target_sat, chost))
assert set(FAKE_9_YUM_SECURITY_ERRATUM) == post_app_errata_ids
# expected packages from the security erratum were added to host
# expected packages from the security erratum and their deps were added
added_packages = response['output']['changed_content'][0]['added_units']['rpm']
assert len(added_packages) == 12
expected_packages = set(FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES + FAKE_9_YUM_SECURITY_ERRATUM_DEPS)
assert set(added_packages) == expected_packages
# expected that not all of the added packages will be applicable
assert 8 == host_app_packages == chost.applicable_package_count
# install all of the newly added packages, recalculate applicability
Expand Down