@@ -2163,6 +2163,124 @@ def test_ccv_no_double_update_on_incremental_with_propagate_all_composites(
21632163 f'Auto-publish should create CCV 2.0 when CV 2.0 is published. Got { ccv_versions_after } '
21642164 )
21652165
2166+ def test_ccv_publish_dependency_chaining (self , module_target_sat , module_sca_manifest_org ):
2167+ """Test the Composite CV publish task is scheduled and waits for the component CV publish
2168+ tasks to complete before executing.
2169+
2170+ :id: 7c978b97-d9f0-444d-bc41-77f794032696
2171+
2172+ :setup:
2173+ 1. Organization with uploaded manifest.
2174+ 2. Custom yum repo from class setup.
2175+ 3. Synchronized one bigger RH repo (RHEL10 BaseOS).
2176+
2177+ :steps:
2178+ 1. Create a content view with the RH repo and errata filter, publish it.
2179+ 2. Create a content view with the custom repo, publish it.
2180+ 3. Create a composite CV with both component CVs, set to auto-publish latest version.
2181+ 4. Asynchronously publish both component CVs (simultaneously).
2182+ 5. Wait for the CCV publish task to be scheduled and wait until completed.
2183+ It should be scheduled after the component CV publish tasks are started.
2184+ 6. Verify all tasks succeeded.
2185+ 7. Verify the CCV publish task waited for component CV tasks to complete.
2186+ 8. Verify both component CVs have version 2.0, CCV has version 1.0 only.
2187+
2188+ :expectedresults:
2189+ 1. CCV publish task is scheduled after the component CV publish tasks are started.
2190+ 2. All publish tasks complete successfully.
2191+
2192+ :verifies: SAT-24497
2193+
2194+ :customerscenario: true
2195+ """
2196+ # Setup: Enable and sync RHEL10 BaseOS repository (bigger RH repo)
2197+ rh_repo_id = module_target_sat .api_factory .enable_sync_redhat_repo (
2198+ rh_repo = REPOS ['rhel10_bos' ],
2199+ org_id = module_sca_manifest_org .id ,
2200+ timeout = 600 ,
2201+ )
2202+ rh_repo = module_target_sat .api .Repository (id = rh_repo_id ).read ()
2203+
2204+ # 1. Create a content view with the RH repo and errata filter, publish it.
2205+ cv_rh = module_target_sat .api .ContentView (
2206+ organization = module_sca_manifest_org ,
2207+ repository = [rh_repo ],
2208+ ).create ()
2209+
2210+ errata_filter = module_target_sat .api .ErratumByDateContentViewFilter (
2211+ content_view = cv_rh , inclusion = True
2212+ ).create ()
2213+ module_target_sat .api .ContentViewFilterRule (
2214+ content_view_filter = errata_filter ,
2215+ date_type = 'issued' ,
2216+ start_date = '2025-07-01' ,
2217+ end_date = '2025-12-31' ,
2218+ ).create ()
2219+
2220+ cv_rh .publish ()
2221+ cv_rh = cv_rh .read ()
2222+ assert len (cv_rh .version ) == 1
2223+ assert cv_rh .version [0 ].read ().version == '1.0'
2224+
2225+ # 2. Create a content view with the custom repo, publish it.
2226+ cv_custom = module_target_sat .api .ContentView (
2227+ organization = module_sca_manifest_org ,
2228+ repository = [self .yum_repo ],
2229+ ).create ()
2230+ cv_custom .publish ()
2231+ cv_custom = cv_custom .read ()
2232+ assert len (cv_custom .version ) == 1
2233+ assert cv_custom .version [0 ].read ().version == '1.0'
2234+
2235+ # 3. Create a composite CV with both component CVs, set to auto-publish latest version.
2236+ ccv = module_target_sat .api .ContentView (
2237+ organization = module_sca_manifest_org ,
2238+ composite = True ,
2239+ auto_publish = True ,
2240+ component = [cv_rh .version [0 ], cv_custom .version [0 ]],
2241+ ).create ()
2242+ ccv = ccv .read ()
2243+ for comp in ccv .content_view_component :
2244+ comp = comp .read ()
2245+ comp .latest = True
2246+ comp .update (['latest' ])
2247+
2248+ # 4. Asynchronously publish both component CVs (simultaneously).
2249+ rh_task = cv_rh .publish (synchronous = False )
2250+ custom_task = cv_custom .publish (synchronous = False )
2251+
2252+ # 5. Wait for the CCV publish task to be scheduled and wait until completed.
2253+ # It should be scheduled after the component CV publish tasks are started.
2254+ ccv_task = module_target_sat .wait_for_tasks (
2255+ search_query = (
2256+ f'label = Actions::Katello::ContentView::Publish '
2257+ f'and action = "Auto Publish content view \' { ccv .name } \' ; '
2258+ f'organization \' { module_sca_manifest_org .name } \' "'
2259+ ),
2260+ search_rate = 2 ,
2261+ max_tries = 30 ,
2262+ poll_timeout = 600 ,
2263+ )[0 ]
2264+ assert ccv_task is not None , "CCV auto-publish task should be scheduled"
2265+
2266+ # 6. Verify all tasks succeeded.
2267+ rh_task = module_target_sat .api .ForemanTask (id = rh_task ['id' ]).read ()
2268+ custom_task = module_target_sat .api .ForemanTask (id = custom_task ['id' ]).read ()
2269+ ccv_task = module_target_sat .api .ForemanTask (id = ccv_task .id ).read ()
2270+ assert all (task .result == 'success' for task in [rh_task , custom_task , ccv_task ])
2271+
2272+ # 7. Verify the CCV publish task waited for component CV tasks to complete.
2273+ latest_component_finished = max ([rh_task .ended_at , custom_task .ended_at ])
2274+ assert ccv_task .started_at >= latest_component_finished
2275+
2276+ # 8. Verify both component CVs have version 2.0, CCV has version 1.0 only.
2277+ cv_rh = cv_rh .read ()
2278+ cv_custom = cv_custom .read ()
2279+ assert '2.0' in [v .read ().version for v in cv_rh .version ]
2280+ assert '2.0' in [v .read ().version for v in cv_custom .version ]
2281+ ccv = ccv .read ()
2282+ assert set (v .read ().version for v in ccv .version ) == {'1.0' }
2283+
21662284
21672285class TestContentViewUpdate :
21682286 """Tests for updating content views."""
0 commit comments