Skip to content

Commit 4713552

Browse files
committed
Add fixes for new inc update dep solving default: false
1 parent d29715e commit 4713552

3 files changed

Lines changed: 117 additions & 2 deletions

File tree

robottelo/constants/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,27 @@
10121012
]
10131013
FAKE_9_YUM_SECURITY_ERRATUM_COUNT = len(FAKE_9_YUM_SECURITY_ERRATUM)
10141014

1015+
# Packages listed directly in the 3 security errata above
1016+
FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES = [
1017+
'bear-4.1-1.noarch',
1018+
'crow-0.8-1.noarch',
1019+
'duck-0.6-1.noarch',
1020+
'penguin-0.9.1-1.noarch',
1021+
'shark-0.1-1.noarch',
1022+
'stork-0.12-2.noarch',
1023+
'walrus-5.21-1.noarch',
1024+
]
1025+
1026+
# Transitive dependencies of the security erratum packages:
1027+
# penguin->dolphin->{lion,tiger}, duck->{cockateel,lion}, cockateel->wolf, lion->wolf
1028+
FAKE_9_YUM_SECURITY_ERRATUM_DEPS = [
1029+
'cockateel-3.1-1.noarch',
1030+
'dolphin-3.10.232-1.noarch',
1031+
'lion-0.4-1.noarch',
1032+
'tiger-1.0-4.noarch',
1033+
'wolf-9.4-2.noarch',
1034+
]
1035+
10151036
FAKE_10_YUM_BUGFIX_ERRATUM = [
10161037
'RHBA-2012:1030',
10171038
]

tests/foreman/api/test_contentview.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
FAKE_1_CUSTOM_PACKAGE_NAME,
3131
FAKE_1_ERRATA_ID,
3232
FAKE_2_CUSTOM_PACKAGE,
33+
FAKE_9_YUM_SECURITY_ERRATUM,
34+
FAKE_9_YUM_SECURITY_ERRATUM_DEPS,
35+
FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES,
3336
PERMISSIONS,
3437
PRDS,
3538
REPOS,
@@ -2476,6 +2479,93 @@ def test_ccv_publish_dependency_chaining(self, module_target_sat, module_sca_man
24762479
ccv = ccv.read()
24772480
assert set(v.read().version for v in ccv.version) == {'1.0'}
24782481

2482+
@pytest.mark.parametrize(
2483+
'resolve_dependencies',
2484+
[True, False, None],
2485+
ids=['dep_solving_enabled', 'dep_solving_disabled', 'dep_solving_default'],
2486+
)
2487+
def test_positive_inc_update_resolve_dependencies(
2488+
self,
2489+
target_sat,
2490+
module_org,
2491+
module_product,
2492+
resolve_dependencies,
2493+
):
2494+
"""Verify that the resolve_dependencies parameter controls whether
2495+
dependency packages are included in an incremental content view update.
2496+
2497+
:id: fa45c92d-d1df-4805-833a-bc6c25b8747c
2498+
2499+
:parametrized: yes
2500+
2501+
:steps:
2502+
1. Create and sync a custom yum repository containing errata
2503+
whose packages have known dependency chains.
2504+
2. Create a content view with the repository, add an erratum
2505+
inclusion filter with no rules to exclude all errata and
2506+
their packages, then publish.
2507+
3. Perform an incremental update to add 3 security errata back,
2508+
with resolve_dependencies set to True, False, or omitted
2509+
entirely to test the server default.
2510+
2511+
:expectedresults:
2512+
1. With resolve_dependencies=True, the incremental version includes
2513+
the direct errata packages and their transitive dependency
2514+
packages (12 total).
2515+
2. With resolve_dependencies=False, the incremental version includes
2516+
only the direct errata packages (7 total).
2517+
3. With resolve_dependencies omitted, the server default (False)
2518+
applies and only direct errata packages are included (7 total).
2519+
"""
2520+
repo = target_sat.api.Repository(
2521+
product=module_product,
2522+
url=settings.repos.yum_9.url,
2523+
).create()
2524+
repo.sync()
2525+
2526+
cv = target_sat.api.ContentView(
2527+
organization=module_org,
2528+
repository=[repo],
2529+
).create()
2530+
# Erratum inclusion filter with no rules: excludes all errata and
2531+
# their associated packages from the published version.
2532+
target_sat.api.ErratumContentViewFilter(
2533+
content_view=cv,
2534+
inclusion=True,
2535+
).create()
2536+
cv.publish()
2537+
cv = cv.read()
2538+
cvv = cv.version[0]
2539+
2540+
inc_data = {
2541+
'content_view_version_environments': [
2542+
{
2543+
'content_view_version_id': cvv.id,
2544+
'environment_ids': [module_org.library.id],
2545+
}
2546+
],
2547+
'add_content': {'errata_ids': FAKE_9_YUM_SECURITY_ERRATUM},
2548+
}
2549+
if resolve_dependencies is not None:
2550+
inc_data['resolve_dependencies'] = resolve_dependencies
2551+
2552+
response = target_sat.api.ContentViewVersion().incremental_update(data=inc_data)
2553+
assert response['result'] == 'success'
2554+
2555+
added_errata = response['output']['changed_content'][0]['added_units']['erratum']
2556+
added_packages = set(response['output']['changed_content'][0]['added_units']['rpm'])
2557+
# All 3 security errata are added regardless of resolve_dependencies
2558+
assert set(added_errata) == set(FAKE_9_YUM_SECURITY_ERRATUM)
2559+
2560+
expected = set(FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES)
2561+
if resolve_dependencies:
2562+
expected |= set(FAKE_9_YUM_SECURITY_ERRATUM_DEPS)
2563+
2564+
assert added_packages == expected, (
2565+
f'Expected {"direct + dependency" if resolve_dependencies else "only direct errata"} '
2566+
f'packages, got {sorted(added_packages)}'
2567+
)
2568+
24792569

24802570
class TestContentViewUpdate:
24812571
"""Tests for updating content views."""

tests/foreman/api/test_errata.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
FAKE_5_CUSTOM_PACKAGE,
3131
FAKE_9_YUM_OUTDATED_PACKAGES,
3232
FAKE_9_YUM_SECURITY_ERRATUM,
33+
FAKE_9_YUM_SECURITY_ERRATUM_DEPS,
34+
FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES,
3335
FAKE_9_YUM_UPDATED_PACKAGES,
3436
PRDS,
3537
REAL_RHEL8_1_ERRATA_ID,
@@ -1568,6 +1570,7 @@ def test_positive_incremental_update_apply_to_envs_cvs(
15681570
}
15691571
],
15701572
'add_content': {'errata_ids': FAKE_9_YUM_SECURITY_ERRATUM},
1573+
'resolve_dependencies': True,
15711574
}
15721575
)
15731576
assert response['result'] == 'success'
@@ -1603,9 +1606,10 @@ def test_positive_incremental_update_apply_to_envs_cvs(
16031606
# newly added errata from incremental version are now applicable to host
16041607
post_app_errata_ids = errata_id_set(_fetch_available_errata_instances(target_sat, chost))
16051608
assert set(FAKE_9_YUM_SECURITY_ERRATUM) == post_app_errata_ids
1606-
# expected packages from the security erratum were added to host
1609+
# expected packages from the security erratum and their deps were added
16071610
added_packages = response['output']['changed_content'][0]['added_units']['rpm']
1608-
assert len(added_packages) == 12
1611+
expected_packages = set(FAKE_9_YUM_SECURITY_ERRATUM_PACKAGES + FAKE_9_YUM_SECURITY_ERRATUM_DEPS)
1612+
assert set(added_packages) == expected_packages
16091613
# expected that not all of the added packages will be applicable
16101614
assert 8 == host_app_packages == chost.applicable_package_count
16111615
# install all of the newly added packages, recalculate applicability

0 commit comments

Comments
 (0)