From d3e6becb729fda0283f048c409d7bb93c756c970 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:37:13 -0400 Subject: [PATCH] [6.15.z] [CV Eval] Test for CV Eval/BZ (#15626) [CV Eval] Test for CV Eval/BZ (#15519) * Test for CV Eval/BZ * Apply suggestions from code review Co-authored-by: vsedmik <46570670+vsedmik@users.noreply.github.com> * Fix docstring --------- Co-authored-by: vsedmik <46570670+vsedmik@users.noreply.github.com> (cherry picked from commit 9e40aa9559a1606deaede61ebff0d6f4cb89fcdc) Co-authored-by: Samuel Bible --- robottelo/cli/contentview.py | 7 +++++ tests/foreman/cli/test_contentview.py | 41 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/robottelo/cli/contentview.py b/robottelo/cli/contentview.py index 5dfcd87721b..1f77918630c 100644 --- a/robottelo/cli/contentview.py +++ b/robottelo/cli/contentview.py @@ -20,6 +20,7 @@ info Show a content view list List content views publish Publish a content view + purge Delete old versions of a content view remove Remove versions and/or environments from a content view and reassign systems and keys remove-from-environment Remove a content view from an environment @@ -113,6 +114,12 @@ def publish(cls, options, timeout=1500000): cls.command_sub = 'publish' return cls.execute(cls._construct_command(options), ignore_stderr=True, timeout=timeout) + @classmethod + def purge(cls, options, timeout='25m'): + """Purges old versions of content-view. Defaults to keeping 3""" + cls.command_sub = 'purge' + return cls.execute(cls._construct_command(options), ignore_stderr=True, timeout=timeout) + @classmethod def version_info(cls, options, output_format=None): """Provides version info related to content-view's version.""" diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index a794d859691..8bef814d9ad 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -3132,6 +3132,47 @@ def test_show_all_repo_ids(self, module_org, module_product, module_target_sat): list_info = module_target_sat.cli.ContentView.list({'name': cv.name}) assert set(list_info[0]['repository-ids'].split(', ')) == set(id_list) + @pytest.mark.tier2 + def test_cv_version_purge(self, module_org, module_target_sat): + """Hammer content-view purge correctly purges CV Versions, instead + of just up to the per page value + + :id: c2db24cd-946a-4cb6-828d-0e0f38b8ef00 + + :steps: + 1. Create a CV + 2. Publish the CV 50 times + 3. Run hammer content-view purge --id + + :expectedresults: Hammer should purge all but 3 old versions, not just up to the per page value + + :Verifies: SAT-15185 + + :customerscenario: true + """ + content_view = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_org.id} + ) + cv_count = 50 + for _ in range(cv_count): + module_target_sat.cli.ContentView.publish({'id': content_view['id']}) + cvv = module_target_sat.cli.ContentView.version_list( + {'content-view-id': content_view['id']} + ) + assert len(cvv) == cv_count + response = module_target_sat.cli.ContentView.purge({'id': content_view['id']}) + assert all( + [ + f"Version '{v+1}.0' of content view '{content_view.name}' deleted." in response + for v in range(cv_count - 4) + ] + ) + # Check that the correct number of Versions were purged. + cvv = module_target_sat.cli.ContentView.version_list( + {'content-view-id': content_view['id']} + ) + assert len(cvv) == 4 + def test_positive_validate_force_promote_warning(self, target_sat, function_org): """Test cv promote shows warning of 'force promotion' for out of sequence LCE