From 8c98a3d6f40131d9eb527c57e6b24a0b9e11b479 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Tue, 30 Jun 2026 08:27:41 -0500 Subject: [PATCH 1/2] Add test for cv synchronous-distribution delete --- tests/foreman/api/test_contentview.py | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/foreman/api/test_contentview.py b/tests/foreman/api/test_contentview.py index b52a567f46b..35526184f42 100644 --- a/tests/foreman/api/test_contentview.py +++ b/tests/foreman/api/test_contentview.py @@ -21,6 +21,7 @@ import pytest from requests.exceptions import HTTPError +from robottelo import constants from robottelo.config import settings, user_nailgun_config from robottelo.constants import ( CUSTOM_RPM_SHA_512_FEED_COUNT, @@ -1869,6 +1870,67 @@ def test_positive_publish_multiple_repos(self, content_view, module_org, module_ content_view.publish() assert len(content_view.read().version) == 1 + def test_positive_synchronous_distribution_delete( + self, content_view, module_sca_manifest_org, module_target_sat + ): + """Delete a Content View containing a synced Repository, and verify the DeleteDistributions dynflow task output + is not empty, and contains proper information. + + :id: cb317252-b60a-4adb-8333-160f594ae5d7 + + :steps: + 1. Create and Sync a repository. + 2. Add it to a Content View and publish it. + 3. Remove that CV from Library, then delete it. + 4. Using the rake console, get the DeleteDistribution task output associated with + the CV deletion. + + :expectedresults: + 1. CV is deleted successfully, and the DeleteDistributions pulp task output isn't empty, and contains + proper information. + + :Verifies: SAT-45529 + + :CaseImportance: High + """ + repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( + basearch='x86_64', + org_id=module_sca_manifest_org.id, + product=constants.PRDS['rhel'], + repo=constants.REPOS['rhst7']['name'], + reposet=constants.REPOSET['rhst7'], + releasever=None, + ) + module_target_sat.api.Repository(id=repo_id).sync() + rh_repo = module_target_sat.api.Repository(id=repo_id).read() + content_view.repository.append(rh_repo) + content_view = content_view.update(['repository']) + content_view = content_view.read() + assert len(content_view.repository) == 1 + content_view.publish() + content_view = content_view.read() + assert len(content_view.version) == 1 + # Remove from Library environment before deleting + content_view.delete_from_environment(content_view.environment[0].id) + content_view.delete() + task = module_target_sat.wait_for_tasks( + search_query=( + f'label = Actions::Katello::ContentView::RemoveFromEnvironment ' + f'and action = "Remove from Environment content view \'{content_view.name}\'; ' + f'organization \'{module_sca_manifest_org.name}\'"' + ), + search_rate=20, + max_tries=15, + )[0] + rake_command = ( + f'task = ForemanTasks::Task.find("{task.id}"); ' + 'dist_task = task.execution_plan_action.execution_plan.actions.find do |action| action.is_a?(::Actions::Pulp3::Repository::DeleteDistributions) end; ' + 'dist_task.output;' + ) + output = module_target_sat.execute(f"foreman-rake console <<< '{rake_command}'") + assert '''"state"=>"completed"''' in output.stdout + assert '''"name"=>"pulpcore.app.tasks.base.ageneral_delete"''' in output.stdout + @pytest.mark.skipif( (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' ) From 9b1e8aa469c0021804b09829059bd730c4fdb303 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Tue, 7 Jul 2026 12:32:37 -0500 Subject: [PATCH 2/2] Update docstring and improve logic --- tests/foreman/api/test_contentview.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/foreman/api/test_contentview.py b/tests/foreman/api/test_contentview.py index 35526184f42..7966a824847 100644 --- a/tests/foreman/api/test_contentview.py +++ b/tests/foreman/api/test_contentview.py @@ -1882,16 +1882,12 @@ def test_positive_synchronous_distribution_delete( 1. Create and Sync a repository. 2. Add it to a Content View and publish it. 3. Remove that CV from Library, then delete it. - 4. Using the rake console, get the DeleteDistribution task output associated with - the CV deletion. + 4. Using the rake console, get the DeleteDistribution task output associated with the CV deletion. :expectedresults: - 1. CV is deleted successfully, and the DeleteDistributions pulp task output isn't empty, and contains - proper information. + 1. CV is deleted successfully, and the DeleteDistributions pulp task output isn't empty, and contains proper information. :Verifies: SAT-45529 - - :CaseImportance: High """ repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( basearch='x86_64', @@ -1921,9 +1917,10 @@ def test_positive_synchronous_distribution_delete( ), search_rate=20, max_tries=15, - )[0] + ) + assert len(task) == 1 rake_command = ( - f'task = ForemanTasks::Task.find("{task.id}"); ' + f'task = ForemanTasks::Task.find("{task[0].id}"); ' 'dist_task = task.execution_plan_action.execution_plan.actions.find do |action| action.is_a?(::Actions::Pulp3::Repository::DeleteDistributions) end; ' 'dist_task.output;' )