Skip to content

Commit 2732788

Browse files
committed
CCV auto-publish on child CV minor version publish
rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
1 parent 312bd01 commit 2732788

1 file changed

Lines changed: 119 additions & 0 deletions

File tree

tests/foreman/api/test_contentview.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,6 +2040,125 @@ def test_inc_update_composite_updated_expected_version(
20402040
# Control CV, no changes
20412041
assert comp.version == '1.0'
20422042

2043+
def test_ccv_no_double_update_on_incremental_with_propagate_all_composites(
2044+
self,
2045+
target_sat,
2046+
module_org,
2047+
module_product,
2048+
):
2049+
"""CCV with auto-publish and 'Always update to latest' updates once (to 1.1) on
2050+
incremental update with --propagate-all-composites, not twice (no spurious 2.0).
2051+
2052+
Verification steps for SAT-34620 bug fix: composite content views must not
2053+
auto-publish on child CV *minor* version updates when propagate-all-composites
2054+
is set; only the incremental 1.1 is created. Auto-publish still works for
2055+
child *major* version updates (e.g. CV 2.0 -> CCV 2.0).
2056+
2057+
:id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
2058+
2059+
:steps:
2060+
1. Create and sync a product with a repo containing missing errata
2061+
(e.g. needed_errata / yum_6).
2062+
2. Add repo to a content view and publish it (CV Version 1.0).
2063+
3. Add this content view to a composite content view; set component to
2064+
'Always update to latest version'; set CCV to auto-publish.
2065+
4. Manually publish the composite content view (CCV Version 1.0).
2066+
5. Run incremental update on the CV with --propagate-all-composites:
2067+
hammer content-view version incremental-update
2068+
--content-view-version-id <cvv-id> --errata-ids <erratum-id>
2069+
--propagate-all-composites true
2070+
6. Assert: new CV version 1.1 and new CCV version 1.1 exist; no CCV 2.0.
2071+
7. Manually publish a new major version of the content view (2.0).
2072+
8. Assert: composite content view auto-published to 2.0.
2073+
2074+
:expectedresults:
2075+
- After step 5, only CV 1.1 and CCV 1.1 exist (no CCV 2.0).
2076+
- After step 7, CCV auto-publishes to 2.0.
2077+
2078+
:verifies: SAT-34620
2079+
2080+
:customerscenario: true
2081+
"""
2082+
# Step 1: repo with missing errata (needed_errata / yum_6)
2083+
repo = target_sat.api.Repository(
2084+
product=module_product,
2085+
url=settings.repos.yum_6.url,
2086+
).create()
2087+
repo.sync()
2088+
repo = repo.read()
2089+
errata_id = settings.repos.yum_6.errata[0]
2090+
2091+
# Step 2: CV with repo, publish 1.0
2092+
cv = target_sat.api.ContentView(
2093+
organization=module_org,
2094+
repository=[repo],
2095+
auto_publish=False,
2096+
).create()
2097+
cv.publish()
2098+
cv = cv.read()
2099+
cvv_1_0 = cv.version[0].read()
2100+
assert cvv_1_0.version == '1.0'
2101+
2102+
# Step 3 & 4: CCV with CV as component (latest=True), auto_publish=True; publish CCV 1.0
2103+
ccv = target_sat.api.ContentView(
2104+
organization=module_org,
2105+
composite=True,
2106+
auto_publish=True,
2107+
component=[cvv_1_0],
2108+
).create()
2109+
ccv = ccv.read()
2110+
for comp in ccv.content_view_component:
2111+
comp = comp.read()
2112+
comp.latest = True
2113+
comp.update(['latest'])
2114+
ccv.publish()
2115+
ccv = ccv.read()
2116+
assert len(ccv.version) == 1
2117+
assert ccv.version[0].read().version == '1.0'
2118+
2119+
# Step 5: incremental update with propagate_all_composites
2120+
target_sat.api.ContentViewVersion().incremental_update(
2121+
data={
2122+
'content_view_version_environments': [
2123+
{
2124+
'content_view_version_id': cvv_1_0.id,
2125+
'environment_ids': [module_org.library.id],
2126+
}
2127+
],
2128+
'add_content': {'errata_ids': [errata_id]},
2129+
'propagate_all_composites': True,
2130+
}
2131+
)
2132+
2133+
# Step 6: CV 1.1 and CCV 1.1 only; no CCV 2.0
2134+
cv = cv.read()
2135+
ccv = ccv.read()
2136+
cv_versions = sorted([v.read().version for v in cv.version])
2137+
ccv_versions = sorted([v.read().version for v in ccv.version])
2138+
assert cv_versions == ['1.0', '1.1'], f'Expected CV versions 1.0 and 1.1, got {cv_versions}'
2139+
assert ccv_versions == ['1.0', '1.1'], (
2140+
f'SAT-34620: CCV must not create 2.0 on incremental update. Got {ccv_versions}'
2141+
)
2142+
2143+
# Step 7: new major version of CV (add content and publish 2.0)
2144+
extra_repo = target_sat.api.Repository(
2145+
product=module_product,
2146+
url=settings.repos.yum_1.url,
2147+
).create()
2148+
extra_repo.sync()
2149+
cv.repository.append(extra_repo.read())
2150+
cv.update(['repository'])
2151+
cv = cv.read()
2152+
cv.publish()
2153+
cv = cv.read()
2154+
2155+
# Step 8: CCV auto-published to 2.0
2156+
ccv = ccv.read()
2157+
ccv_versions_after = sorted([v.read().version for v in ccv.version])
2158+
assert '2.0' in ccv_versions_after, (
2159+
f'Auto-publish should create CCV 2.0 when CV 2.0 is published. Got {ccv_versions_after}'
2160+
)
2161+
20432162

20442163
class TestContentViewUpdate:
20452164
"""Tests for updating content views."""

0 commit comments

Comments
 (0)