From f6944edcef4016e4b08eab873e594084efb28f87 Mon Sep 17 00:00:00 2001 From: vijaysawant Date: Fri, 8 Mar 2024 17:25:46 +0530 Subject: [PATCH 1/4] validate that cv warning to force promote --- tests/foreman/cli/test_contentview.py | 68 +++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 0b4ee4041ef..1ec6bb5c8d8 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -4065,6 +4065,74 @@ def test_version_info_by_lce(self, module_org, module_target_sat): ) assert content_view['version'] == '1.0' + 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 + + :id: 1bfb76be-ab40-48b4-b5a3-428a2a9ab99b + + :steps: + 1. Create an environment path ex- Library >> Test >> Preprod >> Prod + 2. Create a CV and publish into the Library + 3. Promote version 1.0 to Preprod, skip Library, this should fail with warning + 4. Promote version 1.0 to Preprod using force, this should success + 5. Try to promote version 1.0 from Preprod to Prod, this should success without warning + + :expectedresults: + 1. CV version 1.0 should be present on Prod LCE + + :CaseImportance: High + + :BZ: 2125728 + + :customerscenario: true + """ + # Create an environment path ex- Library >> Test >> Preprod >> Prod + lce_test = target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': function_org.id} + ) + lce_preprod = target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': function_org.id, 'prior': lce_test['name']} + ) + lce_prod = target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': function_org.id, 'prior': lce_preprod['name']} + ) + + # Create a CV and publish into the Library + cv = target_sat.cli_factory.make_content_view({'organization-id': function_org.id}) + target_sat.cli.ContentView.publish({'id': cv['id']}) + + # Promote version 1.0 to Preprod, skip Library, this should fail with warning + cv_version = target_sat.cli.ContentView.info({'id': cv['id']})['versions'][0] + with pytest.raises(CLIReturnCodeError) as error: + target_sat.cli.ContentView.version_promote( + {'id': cv_version['id'], 'to-lifecycle-environment-id': lce_preprod['id']} + ) + assert ( + 'Cannot promote environment out of sequence. Use force to bypass restriction' + in error.value.stderr + ) + + # Promote version 1.0 to Preprod using force, this should success + target_sat.cli.ContentView.version_promote( + { + 'id': cv_version['id'], + 'to-lifecycle-environment-id': lce_preprod['id'], + 'force': True, + } + ) + promoted_lce = target_sat.cli.ContentView.info({'id': cv['id']})['lifecycle-environments'][ + -1 + ] + assert lce_preprod['id'] == promoted_lce['id'] + # Try to promote version 1.0 from Preprod to Prod, this should success without warning + target_sat.cli.ContentView.version_promote( + {'id': cv_version['id'], 'to-lifecycle-environment-id': lce_prod['id']} + ) + promoted_lce = target_sat.cli.ContentView.info({'id': cv['id']})['lifecycle-environments'][ + -1 + ] + assert lce_prod['id'] == promoted_lce['id'] + class TestContentViewFileRepo: """Specific tests for Content Views with File Repositories containing From 57b5c1d2ef058bb03621f9a1d0153a7b491b301a Mon Sep 17 00:00:00 2001 From: vijay sawant Date: Mon, 18 Mar 2024 17:19:23 +0530 Subject: [PATCH 2/4] small change in step Co-authored-by: vsedmik <46570670+vsedmik@users.noreply.github.com> --- tests/foreman/cli/test_contentview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 1ec6bb5c8d8..5c7161f89df 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -4073,7 +4073,7 @@ def test_positive_validate_force_promote_warning(self, target_sat, function_org) :steps: 1. Create an environment path ex- Library >> Test >> Preprod >> Prod 2. Create a CV and publish into the Library - 3. Promote version 1.0 to Preprod, skip Library, this should fail with warning + 3. Promote version 1.0 to Preprod, skip Test, this should fail with warning 4. Promote version 1.0 to Preprod using force, this should success 5. Try to promote version 1.0 from Preprod to Prod, this should success without warning From 4a7156eb5bd0dd140d375d29e27109caecdd8cc7 Mon Sep 17 00:00:00 2001 From: vijay sawant Date: Mon, 18 Mar 2024 17:19:57 +0530 Subject: [PATCH 3/4] add new line Co-authored-by: vsedmik <46570670+vsedmik@users.noreply.github.com> --- tests/foreman/cli/test_contentview.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 5c7161f89df..291bdcf88bb 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -4124,6 +4124,7 @@ def test_positive_validate_force_promote_warning(self, target_sat, function_org) -1 ] assert lce_preprod['id'] == promoted_lce['id'] + # Try to promote version 1.0 from Preprod to Prod, this should success without warning target_sat.cli.ContentView.version_promote( {'id': cv_version['id'], 'to-lifecycle-environment-id': lce_prod['id']} From 2839f562d7d99a590306bdf2ccb9f3c331088440 Mon Sep 17 00:00:00 2001 From: vijay sawant Date: Mon, 18 Mar 2024 17:30:05 +0530 Subject: [PATCH 4/4] small change in commented line Co-authored-by: vsedmik <46570670+vsedmik@users.noreply.github.com> --- tests/foreman/cli/test_contentview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 291bdcf88bb..0e35bd1da68 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -4101,7 +4101,7 @@ def test_positive_validate_force_promote_warning(self, target_sat, function_org) cv = target_sat.cli_factory.make_content_view({'organization-id': function_org.id}) target_sat.cli.ContentView.publish({'id': cv['id']}) - # Promote version 1.0 to Preprod, skip Library, this should fail with warning + # Promote version 1.0 to Preprod, skip Test, this should fail with warning cv_version = target_sat.cli.ContentView.info({'id': cv['id']})['versions'][0] with pytest.raises(CLIReturnCodeError) as error: target_sat.cli.ContentView.version_promote(