@@ -2040,6 +2040,129 @@ 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+ Composite Content Views must not auto-publish on child CV minor version updates
2052+ when propagate-all-composites is set; only the incremental 1.1 is created.
2053+ Auto-publish still works for child major version updates (e.g. CV 2.0 -> CCV 2.0).
2054+
2055+ :id: c7572e4d-3079-486e-93c9-fb0b183a4e08
2056+
2057+ :steps:
2058+ 1. Create and sync a product with a repo containing missing errata
2059+ (e.g. needed_errata / yum_6).
2060+ 2. Add repo to a Content View and publish it (CV Version 1.0).
2061+ 3. Add this content view to a Composite Content View; set component to
2062+ 'Always update to latest version'; set CCV to auto-publish.
2063+ 4. Manually publish the Composite Content View (CCV Version 1.0).
2064+ 5. Incrementally update the content view with propagate_all_composites: True
2065+ 6. Assert: new CV version 1.1 and new CCV version 1.1 exist; no CCV 2.0.
2066+ 7. Manually publish a new major version of the content view (2.0).
2067+ 8. Assert: Composite Content View auto-published to 2.0.
2068+
2069+ :expectedresults:
2070+ - After step 5, only CV 1.1 and CCV 1.1 exist (no CCV 2.0).
2071+ - After step 7, CCV auto-publishes to 2.0.
2072+
2073+ :verifies: SAT-34620
2074+
2075+ :customerscenario: true
2076+ """
2077+ # Step 1: repo with missing errata (needed_errata / yum_6)
2078+ repo = target_sat .api .Repository (
2079+ product = module_product ,
2080+ url = settings .repos .yum_6 .url ,
2081+ ).create ()
2082+ repo .sync ()
2083+ repo = repo .read ()
2084+ errata_id = settings .repos .yum_6 .errata [0 ]
2085+
2086+ # Step 2: CV with repo, publish 1.0
2087+ cv = target_sat .api .ContentView (
2088+ organization = module_org ,
2089+ repository = [repo ],
2090+ auto_publish = False ,
2091+ ).create ()
2092+ cv .publish ()
2093+ cv = cv .read ()
2094+ cvv_1_0 = cv .version [0 ].read ()
2095+ assert cvv_1_0 .version == '1.0'
2096+
2097+ # Step 3 & 4: CCV with CV as component (latest=True), auto_publish=True; publish CCV 1.0
2098+ ccv = target_sat .api .ContentView (
2099+ organization = module_org ,
2100+ composite = True ,
2101+ auto_publish = True ,
2102+ component = [cvv_1_0 ],
2103+ ).create ()
2104+ ccv = ccv .read ()
2105+ for comp in ccv .content_view_component :
2106+ comp = comp .read ()
2107+ comp .latest = True
2108+ comp .update (['latest' ])
2109+ ccv .publish ()
2110+ ccv = ccv .read ()
2111+ assert len (ccv .version ) == 1
2112+ assert ccv .version [0 ].read ().version == '1.0'
2113+
2114+ # Step 5: incremental update with propagate_all_composites with True flag
2115+ target_sat .api .ContentViewVersion ().incremental_update (
2116+ data = {
2117+ 'content_view_version_environments' : [
2118+ {
2119+ 'content_view_version_id' : cvv_1_0 .id ,
2120+ 'environment_ids' : [module_org .library .id ],
2121+ }
2122+ ],
2123+ 'add_content' : {'errata_ids' : [errata_id ]},
2124+ 'propagate_all_composites' : True ,
2125+ }
2126+ )
2127+
2128+ # Step 6: CV 1.1 and CCV 1.1 only; no CCV 2.0
2129+ cv = cv .read ()
2130+ ccv = ccv .read ()
2131+ assert set ([v .read ().version for v in cv .version ]) == {'1.0' , '1.1' }, (
2132+ f'Expected CV versions 1.0 and 1.1, got { set ([v .read ().version for v in cv .version ])} '
2133+ )
2134+ assert set ([v .read ().version for v in ccv .version ]) == {'1.0' , '1.1' }, (
2135+ f'Expected CCV versions 1.0 and 1.1, got { set ([v .read ().version for v in ccv .version ])} '
2136+ )
2137+ # Step 7: new major version of CV (add content and publish 2.0)
2138+ extra_repo = target_sat .api .Repository (
2139+ product = module_product ,
2140+ url = settings .repos .yum_1 .url ,
2141+ ).create ()
2142+ extra_repo .sync ()
2143+ cv .repository .append (extra_repo .read ())
2144+ cv .update (['repository' ])
2145+ cv = cv .read ()
2146+ cv .publish ()
2147+ # Wait for CV 2.0 publish and CCV 2.0 auto-publish tasks to complete
2148+ target_sat .wait_for_tasks (
2149+ search_query = (
2150+ f'label = Actions::Katello::ContentView::Publish and organization_id = { module_org .id } '
2151+ ),
2152+ search_rate = 10 ,
2153+ max_tries = 18 ,
2154+ )
2155+ cv = cv .read ()
2156+ cv_version_after = sorted ([v .read ().version for v in cv .version ])
2157+ assert '2.0' in cv_version_after
2158+
2159+ # Step 8: CCV auto-published to 2.0
2160+ ccv = ccv .read ()
2161+ ccv_versions_after = sorted ([v .read ().version for v in ccv .version ])
2162+ assert '2.0' in ccv_versions_after , (
2163+ f'Auto-publish should create CCV 2.0 when CV 2.0 is published. Got { ccv_versions_after } '
2164+ )
2165+
20432166
20442167class TestContentViewUpdate :
20452168 """Tests for updating content views."""
0 commit comments