Skip to content

Commit 0af3f42

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

2 files changed

Lines changed: 112 additions & 0 deletions

File tree

tests/foreman/api/test_contentview.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
FAKE_1_CUSTOM_PACKAGE_NAME,
3131
FAKE_1_ERRATA_ID,
3232
FAKE_2_CUSTOM_PACKAGE,
33+
FAKE_9_YUM_SECURITY_ERRATUM,
3334
PERMISSIONS,
3435
PRDS,
3536
REPOS,
@@ -2476,6 +2477,116 @@ def test_ccv_publish_dependency_chaining(self, module_target_sat, module_sca_man
24762477
ccv = ccv.read()
24772478
assert set(v.read().version for v in ccv.version) == {'1.0'}
24782479

2480+
@pytest.mark.parametrize(
2481+
'resolve_dependencies',
2482+
[True, False, None],
2483+
ids=['dep_solving_enabled', 'dep_solving_disabled', 'dep_solving_default'],
2484+
)
2485+
def test_positive_inc_update_resolve_dependencies(
2486+
self,
2487+
target_sat,
2488+
module_org,
2489+
module_product,
2490+
resolve_dependencies,
2491+
):
2492+
"""Verify that the resolve_dependencies parameter controls whether
2493+
dependency packages are included in an incremental content view update.
2494+
2495+
:id: fa45c92d-d1df-4805-833a-bc6c25b8747c
2496+
2497+
:parametrized: yes
2498+
2499+
:steps:
2500+
1. Create and sync a custom yum repository containing errata
2501+
whose packages have known dependency chains.
2502+
2. Create a content view with the repository, add an erratum
2503+
inclusion filter with no rules to exclude all errata and
2504+
their packages, then publish.
2505+
3. Perform an incremental update to add 3 security errata back,
2506+
with resolve_dependencies set to True, False, or omitted
2507+
entirely to test the server default.
2508+
2509+
:expectedresults:
2510+
1. With resolve_dependencies=True, the incremental version includes
2511+
the direct errata packages and their transitive dependency
2512+
packages (12 total).
2513+
2. With resolve_dependencies=False, the incremental version includes
2514+
only the direct errata packages (7 total).
2515+
3. With resolve_dependencies omitted, the server default (False)
2516+
applies and only direct errata packages are included (7 total).
2517+
"""
2518+
repo = target_sat.api.Repository(
2519+
product=module_product,
2520+
url=settings.repos.yum_9.url,
2521+
).create()
2522+
repo.sync()
2523+
2524+
cv = target_sat.api.ContentView(
2525+
organization=module_org,
2526+
repository=[repo],
2527+
).create()
2528+
# Erratum inclusion filter with no rules: excludes all errata and
2529+
# their associated packages from the published version.
2530+
target_sat.api.ErratumContentViewFilter(
2531+
content_view=cv,
2532+
inclusion=True,
2533+
).create()
2534+
cv.publish()
2535+
cv = cv.read()
2536+
cvv = cv.version[0]
2537+
2538+
inc_data = {
2539+
'content_view_version_environments': [
2540+
{
2541+
'content_view_version_id': cvv.id,
2542+
'environment_ids': [module_org.library.id],
2543+
}
2544+
],
2545+
'add_content': {'errata_ids': FAKE_9_YUM_SECURITY_ERRATUM},
2546+
}
2547+
if resolve_dependencies is not None:
2548+
inc_data['resolve_dependencies'] = resolve_dependencies
2549+
2550+
response = target_sat.api.ContentViewVersion().incremental_update(data=inc_data)
2551+
assert response['result'] == 'success'
2552+
2553+
added_errata = response['output']['changed_content'][0]['added_units']['erratum']
2554+
added_packages = set(response['output']['changed_content'][0]['added_units']['rpm'])
2555+
# All 3 security errata are added regardless of resolve_dependencies
2556+
assert set(added_errata) == set(FAKE_9_YUM_SECURITY_ERRATUM)
2557+
2558+
# Packages listed directly in the 3 security errata
2559+
direct_packages = {
2560+
'bear-4.1-1.noarch',
2561+
'crow-0.8-1.noarch',
2562+
'duck-0.6-1.noarch',
2563+
'penguin-0.9.1-1.noarch',
2564+
'shark-0.1-1.noarch',
2565+
'stork-0.12-2.noarch',
2566+
'walrus-5.21-1.noarch',
2567+
}
2568+
# Transitive dependencies: penguin->dolphin->{lion,tiger},
2569+
# duck->{cockateel,lion}, cockateel->wolf, lion->wolf
2570+
dep_packages = {
2571+
'cockateel-3.1-1.noarch',
2572+
'dolphin-3.10.232-1.noarch',
2573+
'lion-0.4-1.noarch',
2574+
'tiger-1.0-4.noarch',
2575+
'wolf-9.4-2.noarch',
2576+
}
2577+
2578+
if resolve_dependencies:
2579+
assert added_packages == direct_packages | dep_packages, (
2580+
f'Expected direct + dependency packages with dependency solving, '
2581+
f'got {sorted(added_packages)}'
2582+
)
2583+
else:
2584+
# resolve_dependencies=False or omitted (server default: False).
2585+
assert added_packages == direct_packages, (
2586+
f'Expected only direct errata packages without dependency solving, '
2587+
f'got {sorted(added_packages)}'
2588+
)
2589+
24792590

24802591
class TestContentViewUpdate:
24812592
"""Tests for updating content views."""

tests/foreman/api/test_errata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,7 @@ def test_positive_incremental_update_apply_to_envs_cvs(
15681568
}
15691569
],
15701570
'add_content': {'errata_ids': FAKE_9_YUM_SECURITY_ERRATUM},
1571+
'resolve_dependencies': True,
15711572
}
15721573
)
15731574
assert response['result'] == 'success'

0 commit comments

Comments
 (0)