diff --git a/tests/foreman/api/test_contentview.py b/tests/foreman/api/test_contentview.py index c822234a628..f5f6f3a3b95 100644 --- a/tests/foreman/api/test_contentview.py +++ b/tests/foreman/api/test_contentview.py @@ -21,7 +21,6 @@ from robottelo.constants import ( CONTAINER_REGISTRY_HUB, CUSTOM_RPM_SHA_512_FEED_COUNT, - FILTER_ERRATA_TYPE, PERMISSIONS, PRDS, REPOS, @@ -187,33 +186,6 @@ def test_positive_add_custom_content(self, module_product, module_org, module_ta assert len(content_view.repository) == 1 assert content_view.repository[0].read().name == yum_repo.name - @pytest.mark.tier2 - @pytest.mark.skipif( - (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' - ) - def test_positive_add_custom_module_streams( - self, content_view, module_product, module_org, module_target_sat - ): - """Associate custom content (module streams) in a view - - :id: 9e4821cb-293a-4d84-bd1f-bb9fff36b143 - - :expectedresults: Custom content (module streams) assigned and present in content view - - :CaseImportance: High - """ - yum_repo = module_target_sat.api.Repository( - product=module_product, url=settings.repos.module_stream_1.url - ).create() - yum_repo.sync() - assert len(content_view.repository) == 0 - content_view.repository = [yum_repo] - content_view = content_view.update(['repository']) - assert len(content_view.repository) == 1 - repo = content_view.repository[0].read() - assert repo.name == yum_repo.name - assert repo.content_counts['module_stream'] == 7 - @pytest.mark.tier2 def test_negative_add_dupe_repos( self, content_view, module_product, module_org, module_target_sat @@ -282,22 +254,6 @@ def test_positive_add_sha512_rpm(self, content_view, module_org, module_target_s class TestContentViewCreate: """Create tests for content views.""" - @pytest.mark.parametrize('composite', [True, False]) - @pytest.mark.tier1 - def test_positive_create_composite(self, composite, target_sat): - """Create composite and non-composite content views. - - :id: 4a3b616d-53ab-4396-9a50-916d6c42a401 - - :parametrized: yes - - :expectedresults: Creation succeeds and content-view is composite or - non-composite, respectively. - - :CaseImportance: Critical - """ - assert target_sat.api.ContentView(composite=composite).create().composite == composite - @pytest.mark.parametrize('name', **parametrized(valid_data_list())) @pytest.mark.tier1 def test_positive_create_with_name(self, name, target_sat): @@ -503,61 +459,6 @@ def test_positive_promote_with_yum_multiple(self, content_view, module_org, modu assert len(cvv_attrs['environments']) == REPEAT + 1 assert cvv_attrs['package_count'] > 0 - @pytest.mark.tier2 - def test_positive_add_to_composite(self, content_view, module_org, module_target_sat): - """Create normal content view, publish and add it to a new - composite content view - - :id: 36894150-5321-4ffd-ab5a-a7ad01401cf4 - - :expectedresults: Content view can be created and assigned to composite - one through content view versions mechanism - - :CaseImportance: Critical - """ - content_view.repository = [self.yum_repo] - content_view.update(['repository']) - content_view.publish() - content_view = content_view.read() - - composite_cv = module_target_sat.api.ContentView( - composite=True, - organization=module_org, - ).create() - composite_cv.component = content_view.version # list of one CV version - composite_cv = composite_cv.update(['component']) - - # composite CV → CV version == CV → CV version - assert composite_cv.component[0].id == content_view.version[0].id - # composite CV → CV version → CV == CV - assert composite_cv.component[0].read().content_view.id == content_view.id - - @pytest.mark.tier2 - def test_negative_add_components_to_composite( - self, content_view, module_org, module_target_sat - ): - """Attempt to associate components in a non-composite content - view - - :id: 60aa7a4e-df6e-407e-86c7-a4c540bda8b5 - - :expectedresults: User cannot add components to the view - - :CaseImportance: Low - """ - content_view.repository = [self.yum_repo] - content_view.update(['repository']) - content_view.publish() - content_view = content_view.read() - non_composite_cv = module_target_sat.api.ContentView( - composite=False, - organization=module_org, - ).create() - non_composite_cv.component = content_view.version # list of one cvv - with pytest.raises(HTTPError): - non_composite_cv.update(['component']) - assert len(non_composite_cv.read().component) == 0 - @pytest.mark.upgrade @pytest.mark.tier2 def test_positive_promote_composite_multiple_content_once( @@ -897,27 +798,6 @@ def test_negative_update_name(self, module_cv, new_name, module_target_sat): assert cv.name != new_name -class TestContentViewDelete: - """Tests for deleting content views.""" - - @pytest.mark.parametrize('name', **parametrized(valid_data_list())) - @pytest.mark.tier1 - def test_positive_delete(self, content_view, name, target_sat): - """Create content view and then delete it. - - :id: d582f1b3-8118-4e78-a639-237c6f9d27c6 - - :parametrized: yes - - :expectedresults: Content View is successfully deleted. - - :CaseImportance: Critical - """ - content_view.delete() - with pytest.raises(HTTPError): - target_sat.api.ContentView(id=content_view.id).read() - - @pytest.mark.run_in_one_thread class TestContentViewRedHatContent: """Tests for publishing and promoting content views.""" @@ -942,85 +822,6 @@ def initiate_testclass( module_cv.update(['repository']) request.cls.yumcv = module_cv.read() - @pytest.mark.tier2 - def test_positive_add_rh(self): - """associate Red Hat content in a view - - :id: f011a269-813d-4e82-afe8-f106b23cb03e - - :expectedresults: RH Content assigned and present in a view - - :CaseImportance: High - """ - assert len(self.yumcv.repository) == 1 - assert self.yumcv.repository[0].read().name == REPOS['rhst7']['name'] - - @pytest.mark.tier2 - def test_positive_add_rh_custom_spin(self, target_sat): - """Associate Red Hat content in a view and filter it using rule - - :id: 30c3103d-9503-4501-8117-1f2d25353215 - - :expectedresults: Filtered RH content is available and can be seen in a - view - - :CaseImportance: High - """ - # content_view ← cv_filter - cv_filter = target_sat.api.RPMContentViewFilter( - content_view=self.yumcv, - inclusion='true', - name=gen_string('alphanumeric'), - ).create() - assert self.yumcv.id == cv_filter.content_view.id - - # content_view ← cv_filter ← cv_filter_rule - cv_filter_rule = target_sat.api.ContentViewFilterRule( - content_view_filter=cv_filter, name=gen_string('alphanumeric'), version='1.0' - ).create() - assert cv_filter.id == cv_filter_rule.content_view_filter.id - - @pytest.mark.tier2 - def test_positive_update_rh_custom_spin(self, target_sat): - """Edit content views for a custom rh spin. For example, - modify a filter - - :id: 81d77ecd-8bac-44c6-8bc2-b6e38ad77a0b - - :expectedresults: edited content view save is successful and info is - updated - - :CaseImportance: High - """ - cvf = target_sat.api.ErratumContentViewFilter( - content_view=self.yumcv, - ).create() - assert self.yumcv.id == cvf.content_view.id - - cv_filter_rule = target_sat.api.ContentViewFilterRule( - content_view_filter=cvf, types=[FILTER_ERRATA_TYPE['enhancement']] - ).create() - assert cv_filter_rule.types == [FILTER_ERRATA_TYPE['enhancement']] - - cv_filter_rule.types = [FILTER_ERRATA_TYPE['bugfix']] - cv_filter_rule = cv_filter_rule.update(['types']) - assert cv_filter_rule.types == [FILTER_ERRATA_TYPE['bugfix']] - - @pytest.mark.tier2 - def test_positive_publish_rh(self, module_org, content_view): - """Attempt to publish a content view containing Red Hat content - - :id: 4f1698ef-a23b-48d6-be25-dbbf2d76c95c - - :expectedresults: Content view can be published - - :CaseImportance: Critical - """ - content_view.repository = [self.repo] - content_view.update(['repository']) - content_view.publish() - assert len(content_view.read().version) == 1 - @pytest.mark.tier2 def test_positive_publish_rh_custom_spin(self, module_org, content_view, module_target_sat): """Attempt to publish a content view containing Red Hat spin - i.e., @@ -1061,27 +862,6 @@ def test_positive_promote_rh(self, module_org, content_view, module_lce): ) assert len(content_view.read().version[0].read().environment) == 2 - @pytest.mark.upgrade - @pytest.mark.tier2 - def test_positive_promote_rh_custom_spin(self, content_view, module_lce, module_target_sat): - """Attempt to promote a content view containing Red Hat spin - i.e., - contains filters. - - :id: 8331ba11-1742-425f-83b1-6b06c5785572 - - :expectedresults: Content view can be promoted - - :CaseImportance: High - """ - content_view.repository = [self.repo] - content_view = content_view.update(['repository']) - module_target_sat.api.RPMContentViewFilter( - content_view=content_view, inclusion='true', name=gen_string('alphanumeric') - ).create() - content_view.publish() - content_view.read().version[0].promote(data={'environment_ids': module_lce.id}) - assert len(content_view.read().version[0].read().environment) == 2 - @pytest.mark.e2e @pytest.mark.tier2 def test_cv_audit_scenarios(self, module_product, target_sat): @@ -1169,127 +949,6 @@ def test_cv_audit_scenarios(self, module_product, target_sat): assert not self.yumcv.read().needs_publish -@pytest.mark.tier2 -def test_positive_admin_user_actions( - target_sat, content_view, function_role, module_org, module_lce -): - """Attempt to manage content views - - :id: 75b638af-d132-4b5e-b034-a373565c72b4 - - :steps: with global admin account: - - 1. create a user with all content views permissions - 2. create lifecycle environment - 3. create 2 content views (one to delete, the other to manage) - - :setup: create a user with all content views permissions - - :expectedresults: The user can Read, Modify, Delete, Publish, Promote - the content views - - :CaseImportance: Critical - """ - user_login = gen_string('alpha') - user_password = gen_string('alphanumeric') - # create a role with all content views permissions - for res_type in ['Katello::ContentView', 'Katello::KTEnvironment']: - permission = target_sat.api.Permission().search( - query={'search': f'resource_type="{res_type}"'} - ) - target_sat.api.Filter( - organization=[module_org], permission=permission, role=function_role - ).create() - # create a user and assign the above created role - target_sat.api.User( - organization=[module_org], - role=[function_role], - login=user_login, - password=user_password, - ).create() - cfg = user_nailgun_config(user_login, user_password) - # Check that we cannot create random entity due permission restriction - with pytest.raises(HTTPError): - target_sat.api.Domain(server_config=cfg).create() - # Check Read functionality - content_view = target_sat.api.ContentView(server_config=cfg, id=content_view.id).read() - # Check Modify functionality - target_sat.api.ContentView( - server_config=cfg, id=content_view.id, name=gen_string('alpha') - ).update(['name']) - # Publish the content view. - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - # Promote the content view version. - content_view.version[0].promote(data={'environment_ids': module_lce.id}) - # Check Delete functionality - content_view = target_sat.api.ContentView(organization=module_org).create() - content_view = target_sat.api.ContentView(server_config=cfg, id=content_view.id).read() - content_view.delete() - with pytest.raises(HTTPError): - content_view.read() - - -@pytest.mark.tier2 -def test_positive_readonly_user_actions(target_sat, function_role, content_view, module_org): - """Attempt to view content views - - :id: cdfd6e51-cd46-4afa-807c-98b2195fcf0e - - :setup: - - 1. create a user with the Content View read-only role - 2. create content view - 3. add a custom repository to content view - - :expectedresults: User with read-only role for content view can view - the repository in the content view - - :CaseImportance: Critical - """ - user_login = gen_string('alpha') - user_password = gen_string('alphanumeric') - # create a role with content views read only permissions - target_sat.api.Filter( - organization=[module_org], - permission=target_sat.api.Permission().search( - filters={'name': 'view_content_views'}, - query={'search': 'resource_type="Katello::ContentView"'}, - ), - role=function_role, - ).create() - # create read only products permissions and assign it to our role - target_sat.api.Filter( - organization=[module_org], - permission=target_sat.api.Permission().search( - filters={'name': 'view_products'}, - query={'search': 'resource_type="Katello::Product"'}, - ), - role=function_role, - ).create() - # create a user and assign the above created role - target_sat.api.User( - organization=[module_org], - role=[function_role], - login=user_login, - password=user_password, - ).create() - # add repository to the created content view - product = target_sat.api.Product(organization=module_org).create() - yum_repo = target_sat.api.Repository(product=product).create() - yum_repo.sync() - content_view.repository = [yum_repo] - content_view = content_view.update(['repository']) - assert len(content_view.repository) == 1 - cfg = user_nailgun_config(user_login, user_password) - # Check that we can read content view repository information using user - # with read only permissions - content_view = target_sat.api.ContentView(server_config=cfg, id=content_view.id).read() - assert len(content_view.repository) == 1 - assert content_view.repository[0].read().name == yum_repo.name - - @pytest.mark.tier2 def test_negative_readonly_user_actions( target_sat, function_role, content_view, module_org, module_lce diff --git a/tests/foreman/api/test_contentviewfilter.py b/tests/foreman/api/test_contentviewfilter.py index 6360bf5da16..c2f05cd7ce7 100644 --- a/tests/foreman/api/test_contentviewfilter.py +++ b/tests/foreman/api/test_contentviewfilter.py @@ -15,18 +15,15 @@ :CaseImportance: High """ -import http from random import randint from fauxfactory import gen_integer, gen_string -from nailgun import client import pytest from requests.exceptions import HTTPError -from robottelo.config import get_credentials, settings +from robottelo.config import settings from robottelo.constants import CONTAINER_REGISTRY_HUB from robottelo.utils.datafactory import ( - invalid_names_list, parametrized, valid_data_list, ) @@ -65,43 +62,6 @@ def content_view_module_stream(module_org, sync_repo_module_stream, module_targe class TestContentViewFilter: """Tests for content view filters.""" - @pytest.mark.tier2 - def test_negative_get_with_no_args(self, target_sat): - """Issue an HTTP GET to the base content view filters path. - - :id: da29fd90-cd96-49f9-b94e-71d4e3a35a57 - - :expectedresults: An HTTP 200 response is received if a GET request is - issued with no arguments specified. - - :CaseImportance: Low - """ - response = client.get( - target_sat.api.AbstractContentViewFilter().path(), - auth=get_credentials(), - verify=False, - ) - assert response.status_code == http.client.OK - - @pytest.mark.tier2 - def test_negative_get_with_bad_args(self, target_sat): - """Issue an HTTP GET to the base content view filters path. - - :id: e6fea726-930b-4b74-b784-41528811994f - - :expectedresults: An HTTP 200 response is received if a GET request is - issued with bad arguments specified. - - :CaseImportance: Low - """ - response = client.get( - target_sat.api.AbstractContentViewFilter().path(), - auth=get_credentials(), - verify=False, - data={'foo': 'bar'}, - ) - assert response.status_code == http.client.OK - @pytest.mark.tier2 @pytest.mark.parametrize('name', **parametrized(valid_data_list())) def test_positive_create_erratum_with_name(self, name, content_view, target_sat): @@ -270,65 +230,6 @@ def test_positive_create_with_docker_repos( for repo in cvf.repository: assert repo.id in (sync_repo.id, docker_repository.id) - @pytest.mark.tier2 - @pytest.mark.skipif( - (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' - ) - def test_positive_create_with_module_streams( - self, module_product, sync_repo, sync_repo_module_stream, content_view, target_sat - ): - """Verify Include and Exclude Filters creation for modulemd (module streams) - - :id: 4734dcca-ea5b-47d6-8f5f-239da0dc7629 - - :expectedresults: Content view filter created successfully for both - Include and Exclude Type - - """ - content_view.repository += [sync_repo_module_stream] - content_view.update(['repository']) - for inclusion in (True, False): - cvf = target_sat.api.ModuleStreamContentViewFilter( - content_view=content_view, - inclusion=inclusion, - repository=[sync_repo, sync_repo_module_stream], - ).create() - assert cvf.inclusion == inclusion - assert len(cvf.repository) == 2 - assert content_view.id == cvf.content_view.id - assert cvf.type == 'modulemd' - - @pytest.mark.tier2 - @pytest.mark.parametrize('name', **parametrized(invalid_names_list())) - def test_negative_create_with_invalid_name(self, name, content_view, target_sat): - """Try to create content view filter using invalid names only - - :id: 8cf4227b-75c4-4d6f-b94f-88e4eb586435 - - :parametrized: yes - - :expectedresults: Content view filter was not created - - :CaseImportance: Critical - """ - with pytest.raises(HTTPError): - target_sat.api.RPMContentViewFilter(content_view=content_view, name=name).create() - - @pytest.mark.tier2 - def test_negative_create_with_same_name(self, content_view, target_sat): - """Try to create content view filter using same name twice - - :id: 73a64ca7-07a3-49ee-8921-0474a16a23ff - - :expectedresults: Second content view filter was not created - - :CaseImportance: Low - """ - kwargs = {'content_view': content_view, 'name': gen_string('alpha')} - target_sat.api.RPMContentViewFilter(**kwargs).create() - with pytest.raises(HTTPError): - target_sat.api.RPMContentViewFilter(**kwargs).create() - @pytest.mark.tier2 def test_negative_create_without_cv(self, target_sat): """Try to create content view filter without providing content @@ -536,24 +437,6 @@ def test_positive_update_repo_with_docker( for repo in cvf.repository: assert repo.id in (sync_repo.id, docker_repository.id) - @pytest.mark.tier2 - @pytest.mark.parametrize('name', **parametrized(invalid_names_list())) - def test_negative_update_name(self, name, content_view, target_sat): - """Try to update content view filter using invalid names only - - :id: 9799648a-3900-4186-8271-6b2dedb547ab - - :parametrized: yes - - :expectedresults: Content view filter was not updated - - :CaseImportance: Low - """ - cvf = target_sat.api.RPMContentViewFilter(content_view=content_view).create() - cvf.name = name - with pytest.raises(HTTPError): - cvf.update(['name']) - @pytest.mark.tier2 def test_negative_update_same_name(self, content_view, target_sat): """Try to update content view filter's name to already used one diff --git a/tests/foreman/api/test_contentviewversion.py b/tests/foreman/api/test_contentviewversion.py index 5f3414456e3..074cd42f27d 100644 --- a/tests/foreman/api/test_contentviewversion.py +++ b/tests/foreman/api/test_contentviewversion.py @@ -11,15 +11,12 @@ :CaseImportance: High """ -from fauxfactory import gen_string import pytest from requests.exceptions import HTTPError from robottelo.config import settings from robottelo.constants import ( - CONTAINER_REGISTRY_HUB, DEFAULT_CV, - ENVIRONMENT, DataFile, ) @@ -36,82 +33,6 @@ def module_lce_cv(module_org, module_target_sat): return lce1, lce2, default_cvv -# Tests for content view version creation. - - -@pytest.mark.tier2 -def test_positive_create(module_cv): - """Create a content view version. - - :id: 627c84b3-e3f1-416c-a09b-5d2200d6429f - - :expectedresults: Content View Version is created. - - :CaseImportance: Critical - """ - # Fetch content view for latest information - cv = module_cv.read() - # No versions should be available yet - assert len(cv.version) == 0 - - # Publish existing content view - cv.publish() - # Fetch it again - cv = cv.read() - assert len(cv.version) > 0 - - -@pytest.mark.tier2 -def test_negative_create(module_org, module_target_sat): - """Attempt to create content view version using the 'Default Content View'. - - :id: 0afd49c6-f3a4-403e-9929-849f51ffa922 - - :expectedresults: Content View Version is not created - - :CaseImportance: Critical - """ - # The default content view cannot be published - cv = module_target_sat.api.ContentView(organization=module_org.id, name=DEFAULT_CV).search() - # There should be only 1 record returned - assert len(cv) == 1 - with pytest.raises(HTTPError): - cv[0].publish() - - -# Tests for content view version promotion. - - -@pytest.mark.tier2 -def test_positive_promote_valid_environment(module_lce_cv, module_org, module_target_sat): - """Promote a content view version to next in sequence lifecycle environment. - - :id: f205ca06-8ab5-4546-83bd-deac4363d487 - - :expectedresults: Promotion succeeds. - - :CaseImportance: Critical - """ - # Create a new content view... - cv = module_target_sat.api.ContentView(organization=module_org).create() - # ... and promote it. - cv.publish() - # Refresh the entity - cv = cv.read() - # Check that we have a new version - assert len(cv.version) == 1 - version = cv.version[0].read() - # Assert that content view version is found in 1 lifecycle - # environments (i.e. 'Library') - assert len(version.environment) == 1 - # Promote it to the next 'in sequence' lifecycle environment - version.promote(data={'environment_ids': module_lce_cv[0].id, 'force': False}) - # Assert that content view version is found in 2 lifecycle - # environments. - version = version.read() - assert len(version.environment) == 2 - - @pytest.mark.tier2 def test_positive_promote_out_of_sequence_environment(module_org, module_lce_cv, module_target_sat): """Promote a content view version to a lifecycle environment @@ -297,434 +218,6 @@ def test_positive_delete_composite_version(module_org, module_target_sat): assert len(composite_cv.read().version) == 0 -@pytest.mark.tier2 -def test_negative_delete(module_org, module_target_sat): - """Create content view and publish it. Try to delete content - view version while content view is still associated with lifecycle - environment - - :id: 21c35aae-2f9c-4679-b3ba-7cd9182bd880 - - :expectedresults: Content view version is not deleted - - :CaseImportance: Critical - """ - content_view = module_target_sat.api.ContentView(organization=module_org).create() - # Publish content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - with pytest.raises(HTTPError): - content_view.version[0].delete() - # Make sure that content view version is still present - assert len(content_view.read().version) == 1 - - -@pytest.mark.tier2 -@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_remove_renamed_cv_version_from_default_env(module_org, module_target_sat): - """Remove version of renamed content view from Library environment - - :id: 7d5961d0-6a9a-4610-979e-cbc4ddbc50ca - - :steps: - - 1. Create a content view - 2. Add a yum repo to the content view - 3. Publish the content view - 4. Rename the content view - 5. remove the published version from Library environment - - :expectedresults: content view version is removed from Library - environment - """ - new_name = gen_string('alpha') - # create yum product and repo - product = module_target_sat.api.Product(organization=module_org).create() - yum_repo = module_target_sat.api.Repository( - url=settings.repos.yum_1.url, product=product - ).create() - yum_repo.sync() - # create a content view and add the yum repo to it - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [yum_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - # ensure that the content view version is promoted to the Library - # lifecycle environment - assert lce_library.name == ENVIRONMENT - # rename the content view - content_view.name = new_name - content_view.update(['name']) - assert content_view.name == new_name - # delete the content view version from Library environment - content_view.delete_from_environment(lce_library.id) - # assert that the content view version does not exist in Library - # environment - assert len(content_view_version.read().environment) == 0 - - -@pytest.mark.tier2 -def test_positive_remove_qe_promoted_cv_version_from_default_env(module_org, module_target_sat): - """Remove QE promoted content view version from Library environment - - :id: c7795762-93bd-419c-ac49-d10dc26b842b - - :steps: - - 1. Create a content view - 2. Add docker repo(s) to it - 3. Publish content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE - 5. remove the content view version from Library environment - - :expectedresults: Content view version exist only in DEV, QE and not in - Library - """ - lce_dev = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce_qe = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_dev - ).create() - product = module_target_sat.api.Product(organization=module_org).create() - docker_repo = module_target_sat.api.Repository( - content_type='docker', - docker_upstream_name='busybox', - product=product, - url=CONTAINER_REGISTRY_HUB, - ).create() - docker_repo.sync() - # create a content view and add to it the docker repo - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [docker_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - assert lce_library.name == ENVIRONMENT - # promote content view version to DEV and QE lifecycle environments - for lce in [lce_dev, lce_qe]: - content_view_version.promote(data={'environment_ids': lce.id, 'force': False}) - assert {lce_library.id, lce_dev.id, lce_qe.id} == { - lce.id for lce in content_view_version.read().environment - } - # remove the content view version from Library environment - content_view.delete_from_environment(lce_library.id) - # assert that the content view version does not exist in Library - # environment - assert {lce_dev.id, lce_qe.id} == {lce.id for lce in content_view_version.read().environment} - - -@pytest.mark.tier2 -@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_remove_prod_promoted_cv_version_from_default_env(module_org, module_target_sat): - """Remove PROD promoted content view version from Library environment - - :id: 24911876-7c2a-4a12-a3aa-98051dfda29d - - :steps: - - 1. Create a content view - 2. Add yum repositories and docker repositories to CV - 3. Publish content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE -> PROD - 5. remove the content view version from Library environment - - :expectedresults: Content view version exist only in DEV, QE, PROD and - not in Library - """ - lce_dev = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce_qe = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_dev - ).create() - lce_prod = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_qe - ).create() - product = module_target_sat.api.Product(organization=module_org).create() - yum_repo = module_target_sat.api.Repository( - url=settings.repos.yum_1.url, product=product - ).create() - yum_repo.sync() - docker_repo = module_target_sat.api.Repository( - content_type='docker', - docker_upstream_name='busybox', - product=product, - url=CONTAINER_REGISTRY_HUB, - ).create() - docker_repo.sync() - # create a content view and add to it the yum and docker repos - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [yum_repo, docker_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - assert lce_library.name == ENVIRONMENT - # promote content view version to DEV QE PROD lifecycle environments - for lce in [lce_dev, lce_qe, lce_prod]: - content_view_version.promote(data={'environment_ids': lce.id, 'force': False}) - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_prod.id} == { - lce.id for lce in content_view_version.read().environment - } - # remove the content view version from Library environment - content_view.delete_from_environment(lce_library.id) - # assert that the content view version exists only in DEV QE PROD and - # not in Library environment - assert {lce_dev.id, lce_qe.id, lce_prod.id} == { - lce.id for lce in content_view_version.read().environment - } - - -@pytest.mark.tier2 -@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_remove_cv_version_from_env(module_org, module_target_sat): - """Remove promoted content view version from environment - - :id: 17cf18bf-09d5-4641-b0e0-c50e628fa6c8 - - :steps: - - 1. Create a content view - 2. Add a yum repo and a docker repo to the content view - 3. Publish the content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE -> STAGE -> PROD - 5. remove the content view version from PROD environment - 6. Assert: content view version exists only in Library, DEV, QE, - STAGE and not in PROD - 7. Promote again from STAGE -> PROD - - :expectedresults: Content view version exist in Library, DEV, QE, - STAGE, PROD - """ - lce_dev = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce_qe = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_dev - ).create() - lce_stage = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_qe - ).create() - lce_prod = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_stage - ).create() - product = module_target_sat.api.Product(organization=module_org).create() - yum_repo = module_target_sat.api.Repository( - url=settings.repos.yum_1.url, product=product - ).create() - yum_repo.sync() - # docker repo - docker_repo = module_target_sat.api.Repository( - content_type='docker', - docker_upstream_name='busybox', - product=product, - url=CONTAINER_REGISTRY_HUB, - ).create() - docker_repo.sync() - # create a content view and add the yum and docker repo to it - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [yum_repo, docker_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - assert lce_library.name == ENVIRONMENT - # promote content view version to DEV QE STAGE PROD lifecycle - # environments - for lce in [lce_dev, lce_qe, lce_stage, lce_prod]: - content_view_version.promote(data={'environment_ids': lce.id, 'force': False}) - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_stage.id, lce_prod.id} == { - lce.id for lce in content_view_version.read().environment - } - # remove the content view version from Library environment - content_view.delete_from_environment(lce_prod.id) - # assert that the content view version exists only in Library DEV QE - # STAGE and not in PROD environment - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_stage.id} == { - lce.id for lce in content_view_version.read().environment - } - # promote content view version to PROD environment again - content_view_version.promote(data={'environment_ids': lce_prod.id, 'force': False}) - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_stage.id, lce_prod.id} == { - lce.id for lce in content_view_version.read().environment - } - - -@pytest.mark.tier2 -@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_remove_cv_version_from_multi_env(module_org, module_target_sat): - """Remove promoted content view version from multiple environments - - :id: 18b86a68-8e6a-43ea-b95e-188fba125a26 - - :steps: - - 1. Create a content view - 2. Add a yum repo and a docker repo to the content view - 3. Publish the content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE -> STAGE -> PROD - 5. Remove content view version from QE, STAGE and PROD - - :expectedresults: Content view version exists only in Library, DEV - - :CaseImportance: Low - """ - lce_dev = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce_qe = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_dev - ).create() - lce_stage = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_qe - ).create() - lce_prod = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_stage - ).create() - product = module_target_sat.api.Product(organization=module_org).create() - yum_repo = module_target_sat.api.Repository( - url=settings.repos.yum_1.url, product=product - ).create() - yum_repo.sync() - docker_repo = module_target_sat.api.Repository( - content_type='docker', - docker_upstream_name='busybox', - product=product, - url=CONTAINER_REGISTRY_HUB, - ).create() - docker_repo.sync() - # create a content view and add the yum repo to it - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [yum_repo, docker_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - assert lce_library.name == ENVIRONMENT - # promote content view version to DEV QE STAGE PROD lifecycle - # environments - for lce in [lce_dev, lce_qe, lce_stage, lce_prod]: - content_view_version.promote(data={'environment_ids': lce.id, 'force': False}) - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_stage.id, lce_prod.id} == { - lce.id for lce in content_view_version.read().environment - } - # remove the content view version from QE STAGE and PROD environments - for lce in [lce_qe, lce_stage, lce_prod]: - content_view.delete_from_environment(lce.id) - # assert that the content view version exists only in Library and DEV - # environments - assert {lce_library.id, lce_dev.id} == { - lce.id for lce in content_view_version.read().environment - } - - -@pytest.mark.upgrade -@pytest.mark.tier2 -@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_delete_cv_promoted_to_multi_env(module_org, module_target_sat): - """Delete published content view with version promoted to multiple - environments - - :id: c164bd97-e710-4a5a-9c9f-657e6bed804b - - :steps: - - 1. Create a content view - 2. Add a yum repo and a docker repo to the content view - 3. Publish the content view - 4. Promote the content view to multiple environment - Library -> DEV -> QE -> STAGE -> PROD - 5. Delete the content view, this should delete the content with all - it's published/promoted versions from all environments - - :expectedresults: The content view doesn't exist - - :CaseImportance: Critical - """ - lce_dev = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce_qe = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_dev - ).create() - lce_stage = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_qe - ).create() - lce_prod = module_target_sat.api.LifecycleEnvironment( - organization=module_org, prior=lce_stage - ).create() - product = module_target_sat.api.Product(organization=module_org).create() - yum_repo = module_target_sat.api.Repository( - url=settings.repos.yum_1.url, product=product - ).create() - yum_repo.sync() - docker_repo = module_target_sat.api.Repository( - content_type='docker', - docker_upstream_name='busybox', - product=product, - url=CONTAINER_REGISTRY_HUB, - ).create() - docker_repo.sync() - # create a content view and add the yum repo to it - content_view = module_target_sat.api.ContentView(organization=module_org).create() - content_view.repository = [yum_repo, docker_repo] - content_view = content_view.update(['repository']) - # publish the content view - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - content_view_version = content_view.version[0].read() - assert len(content_view_version.environment) == 1 - lce_library = module_target_sat.api.LifecycleEnvironment( - id=content_view_version.environment[0].id - ).read() - assert lce_library.name == ENVIRONMENT - # promote content view version to DEV QE STAGE PROD lifecycle - # environments - for lce in [lce_dev, lce_qe, lce_stage, lce_prod]: - content_view_version.promote(data={'environment_ids': lce.id, 'force': False}) - content_view_version = content_view_version.read() - assert {lce_library.id, lce_dev.id, lce_qe.id, lce_stage.id, lce_prod.id} == { - lce.id for lce in content_view_version.environment - } - # remove content view version from all lifecycle environments - for lce in content_view_version.environment: - content_view.delete_from_environment(lce.id) - # delete the content view - content_view.delete() - with pytest.raises(HTTPError): - content_view.read() - - @pytest.mark.stubbed @pytest.mark.tier3 def test_positive_remove_cv_version_from_env_with_host_registered(): diff --git a/tests/foreman/api/test_docker.py b/tests/foreman/api/test_docker.py index eab9d213db5..c475259825d 100644 --- a/tests/foreman/api/test_docker.py +++ b/tests/foreman/api/test_docker.py @@ -9,7 +9,7 @@ """ from random import choice, randint, shuffle -from fauxfactory import gen_string, gen_url +from fauxfactory import gen_url import pytest from requests.exceptions import HTTPError @@ -305,48 +305,6 @@ class TestDockerContentView: :team: Phoenix-content """ - @pytest.mark.tier2 - def test_positive_add_docker_repo(self, repo, content_view): - """Add one Docker-type repository to a non-composite content view - - :id: a065822f-bb41-4fc9-bf5c-65814ca11b2d - - :expectedresults: A repository is created with a Docker repository and - the product is added to a non-composite content view - """ - # Associate docker repo with the content view - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert repo.id in [repo_.id for repo_ in content_view.repository] - - @pytest.mark.tier2 - def test_positive_add_docker_repos(self, module_target_sat, module_product, content_view): - """Add multiple Docker-type repositories to a - non-composite content view. - - :id: 08eed081-2003-4475-95ac-553a56b83997 - - :expectedresults: Repositories are created with Docker upstream repos - and the product is added to a non-composite content view. - """ - repos = [ - _create_repository(module_target_sat, module_product, name=gen_string('alpha')) - for _ in range(randint(2, 5)) - ] - repo_ids = {r.id for r in repos} - assert repo_ids.issubset({r.id for r in module_product.read().repository}) - - content_view.repository = repos - content_view = content_view.update(['repository']) - - assert len(repos) == len(content_view.repository) - - for repo in content_view.repository: - r = repo.read() - assert r.id in repo_ids - assert r.content_type == 'docker' - assert r.docker_upstream_name == CONTAINER_UPSTREAM_NAME - @pytest.mark.tier2 def test_positive_add_synced_docker_repo(self, module_org, module_product, module_target_sat): """Create and sync a Docker-type repository @@ -369,43 +327,6 @@ def test_positive_add_synced_docker_repo(self, module_org, module_product, modul content_view = content_view.update(['repository']) assert repo.id in [repo_.id for repo_ in content_view.repository] - @pytest.mark.tier2 - def test_positive_add_docker_repo_to_ccv(self, module_org, module_target_sat): - """Add one Docker-type repository to a composite content view - - :id: fe278275-2bb2-4d68-8624-f0cfd63ecb57 - - :expectedresults: A repository is created with a Docker repository and - the product is added to a content view which is then added to a - composite content view. - """ - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - - # Create content view and associate docker repo - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert repo.id in [repo_.id for repo_ in content_view.repository] - - # Publish it and grab its version ID (there should only be one version) - content_view.publish() - content_view = content_view.read() - assert len(content_view.version) == 1 - - # Create composite content view and associate content view to it - comp_content_view = module_target_sat.api.ContentView( - composite=True, organization=module_org - ).create() - comp_content_view.component = content_view.version - comp_content_view = comp_content_view.update(['component']) - assert content_view.version[0].id in [ - component.id for component in comp_content_view.component - ] - @pytest.mark.tier2 def test_positive_add_docker_repos_to_ccv(self, module_org, module_target_sat): """Add multiple Docker-type repositories to a composite @@ -443,38 +364,6 @@ def test_positive_add_docker_repos_to_ccv(self, module_org, module_target_sat): comp_content_view = comp_content_view.update(['component']) assert cv_version.id in [component.id for component in comp_content_view.component] - @pytest.mark.tier2 - def test_positive_publish_with_docker_repo(self, module_org, module_target_sat): - """Add Docker-type repository to content view and publish it once. - - :id: 86a73e96-ead6-41fb-8095-154a0b83e344 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - published only once. - """ - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert repo.id in [repo_.id for repo_ in content_view.repository] - - # Not published yet? - content_view = content_view.read() - assert content_view.last_published is None - assert float(content_view.next_version) == 1.0 - - # Publish it and check that it was indeed published. - content_view.publish() - content_view = content_view.read() - assert content_view.last_published is not None - assert float(content_view.next_version) > 1.0 - @pytest.mark.tier2 def test_positive_publish_with_docker_repo_composite(self, module_org, module_target_sat): """Add Docker-type repository to composite content view and @@ -526,109 +415,6 @@ def test_positive_publish_with_docker_repo_composite(self, module_org, module_ta assert comp_content_view.last_published is not None assert float(comp_content_view.next_version) > 1.0 - @pytest.mark.tier2 - def test_positive_publish_multiple_with_docker_repo(self, module_org, module_target_sat): - """Add Docker-type repository to content view and publish it - multiple times. - - :id: e2caad64-e9f4-422d-a1ab-f64c286d82ff - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - published multiple times. - """ - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert [repo.id] == [repo_.id for repo_ in content_view.repository] - assert content_view.read().last_published is None - - publish_amount = randint(2, 5) - for _ in range(publish_amount): - content_view.publish() - content_view = content_view.read() - assert content_view.last_published is not None - assert len(content_view.version) == publish_amount - - @pytest.mark.tier2 - def test_positive_publish_multiple_with_docker_repo_composite( - self, module_org, module_target_sat - ): - """Add Docker-type repository to content view and publish it - multiple times. - - :id: 77a5957a-7415-41c3-be68-fa706fee7c98 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - added to a composite content view which is then published multiple - times. - """ - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert [repo.id] == [repo_.id for repo_ in content_view.repository] - assert content_view.read().last_published is None - - content_view.publish() - content_view = content_view.read() - assert content_view.last_published is not None - - comp_content_view = module_target_sat.api.ContentView( - composite=True, organization=module_org - ).create() - comp_content_view.component = [content_view.version[0]] - comp_content_view = comp_content_view.update(['component']) - assert [content_view.version[0].id] == [comp.id for comp in comp_content_view.component] - assert comp_content_view.last_published is None - - publish_amount = randint(2, 5) - for _ in range(publish_amount): - comp_content_view.publish() - comp_content_view = comp_content_view.read() - assert comp_content_view.last_published is not None - assert len(comp_content_view.version) == publish_amount - - @pytest.mark.tier2 - def test_positive_promote_with_docker_repo(self, module_org, module_target_sat): - """Add Docker-type repository to content view and publish it. - Then promote it to the next available lifecycle-environment. - - :id: 5ab7d7f1-fb13-4b83-b228-a6293be36195 - - :expectedresults: Docker-type repository is promoted to content view - found in the specific lifecycle-environment. - """ - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert [repo.id] == [repo_.id for repo_ in content_view.repository] - - content_view.publish() - content_view = content_view.read() - cvv = content_view.version[0].read() - assert len(cvv.environment) == 1 - - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - assert len(cvv.read().environment) == 2 - @pytest.mark.tier2 def test_positive_promote_multiple_with_docker_repo(self, module_org, module_target_sat): """Add Docker-type repository to content view and publish it. @@ -659,45 +445,6 @@ def test_positive_promote_multiple_with_docker_repo(self, module_org, module_tar cvv.promote(data={'environment_ids': lce.id, 'force': False}) assert len(cvv.read().environment) == i + 1 - @pytest.mark.tier2 - def test_positive_promote_with_docker_repo_composite(self, module_org, module_target_sat): - """Add Docker-type repository to content view and publish it. - Then add that content view to composite one. Publish and promote that - composite content view to the next available lifecycle-environment. - - :id: e903c7b2-7722-4a9e-bb69-99bbd3c23946 - - :expectedresults: Docker-type repository is promoted to content view - found in the specific lifecycle-environment. - """ - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - repo = _create_repository( - module_target_sat, module_target_sat.api.Product(organization=module_org).create() - ) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - assert [repo.id] == [repo_.id for repo_ in content_view.repository] - - content_view.publish() - cvv = content_view.read().version[0].read() - - comp_content_view = module_target_sat.api.ContentView( - composite=True, organization=module_org - ).create() - comp_content_view.component = [cvv] - comp_content_view = comp_content_view.update(['component']) - assert cvv.id == comp_content_view.component[0].id - - comp_content_view.publish() - comp_cvv = comp_content_view.read().version[0] - assert len(comp_cvv.read().environment) == 1 - - comp_cvv.promote(data={'environment_ids': lce.id, 'force': False}) - assert len(comp_cvv.read().environment) == 2 - @pytest.mark.upgrade @pytest.mark.tier2 def test_positive_promote_multiple_with_docker_repo_composite( @@ -741,216 +488,6 @@ def test_positive_promote_multiple_with_docker_repo_composite( comp_cvv.promote(data={'environment_ids': lce.id, 'force': False}) assert len(comp_cvv.read().environment) == i + 1 - @pytest.mark.tier2 - @pytest.mark.upgrade - def test_positive_name_pattern_change(self, module_org, module_target_sat): - """Promote content view with Docker repository to lifecycle environment. - Change registry name pattern for that environment. Verify that repository - name on product changed according to new pattern. - - :id: cc78d82d-027b-4cb7-92c5-dcccf9b592ea - - :expectedresults: Container repository name is changed - according to new pattern. - """ - pattern_prefix = gen_string('alpha', 5) - docker_upstream_name = 'hello-world' - new_pattern = ( - f'{pattern_prefix}-<%= organization.label %>/<%= repository.docker_upstream_name %>' - ) - - repo = _create_repository( - module_target_sat, - module_target_sat.api.Product(organization=module_org).create(), - upstream_name=docker_upstream_name, - ) - repo.sync(timeout=600) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - content_view.publish() - cvv = content_view.read().version[0] - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - lce.registry_name_pattern = new_pattern - lce = lce.update(['registry_name_pattern']) - repos = module_target_sat.api.Repository(organization=module_org).search( - query={'environment_id': lce.id} - ) - - expected_pattern = f'{pattern_prefix}-{module_org.label}/{docker_upstream_name}'.lower() - assert lce.registry_name_pattern == new_pattern - assert repos[0].container_repository_name == expected_pattern - - @pytest.mark.tier2 - def test_positive_product_name_change_after_promotion(self, module_org, module_target_sat): - """Promote content view with Docker repository to lifecycle environment. - Change product name. Verify that repository name on product changed - according to new pattern. - - :id: 4ff21344-9ee6-4e17-9a88-0230e7cdd586 - - :expectedresults: Container repository name is changed - according to new pattern. - """ - old_prod_name = gen_string('alpha', 5) - new_prod_name = gen_string('alpha', 5) - docker_upstream_name = 'hello-world' - new_pattern = "<%= organization.label %>/<%= product.name %>" - - prod = module_target_sat.api.Product(organization=module_org, name=old_prod_name).create() - repo = _create_repository(module_target_sat, prod, upstream_name=docker_upstream_name) - repo.sync(timeout=600) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - content_view.publish() - cvv = content_view.read().version[0] - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce.registry_name_pattern = new_pattern - lce = lce.update(['registry_name_pattern']) - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - prod.name = new_prod_name - prod.update(['name']) - repos = module_target_sat.api.Repository(organization=module_org).search( - query={'environment_id': lce.id} - ) - - expected_pattern = f"{module_org.label}/{old_prod_name}".lower() - assert repos[0].container_repository_name == expected_pattern - - content_view.publish() - cvv = content_view.read().version[-1] - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - repos = module_target_sat.api.Repository(organization=module_org).search( - query={'environment_id': lce.id} - ) - - expected_pattern = f"{module_org.label}/{new_prod_name}".lower() - assert repos[0].container_repository_name == expected_pattern - - @pytest.mark.tier2 - def test_positive_repo_name_change_after_promotion(self, module_org, module_target_sat): - """Promote content view with Docker repository to lifecycle environment. - Change repository name. Verify that Docker repository name on product - changed according to new pattern. - - :id: 304ae909-dc67-4a7e-80e1-96b45354e5a6 - - :expectedresults: Container repository name is changed - according to new pattern. - """ - old_repo_name = gen_string('alpha', 5) - new_repo_name = gen_string('alpha', 5) - docker_upstream_name = 'hello-world' - new_pattern = "<%= organization.label %>/<%= repository.name %>" - - repo = _create_repository( - module_target_sat, - module_target_sat.api.Product(organization=module_org).create(), - name=old_repo_name, - upstream_name=docker_upstream_name, - ) - repo.sync(timeout=600) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = [repo] - content_view = content_view.update(['repository']) - content_view.publish() - cvv = content_view.read().version[0] - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce.registry_name_pattern = new_pattern - lce = lce.update(['registry_name_pattern']) - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - repo.name = new_repo_name - repo.update(['name']) - repos = module_target_sat.api.Repository(organization=module_org).search( - query={'environment_id': lce.id} - ) - - expected_pattern = f"{module_org.label}/{old_repo_name}".lower() - assert repos[0].container_repository_name == expected_pattern - - content_view.publish() - cvv = content_view.read().version[-1] - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - repos = module_target_sat.api.Repository(organization=module_org).search( - query={'environment_id': lce.id} - ) - - expected_pattern = f"{module_org.label}/{new_repo_name}".lower() - assert repos[0].container_repository_name == expected_pattern - - @pytest.mark.tier2 - def test_negative_set_non_unique_name_pattern_and_promote(self, module_org, module_target_sat): - """Set registry name pattern to one that does not guarantee uniqueness. - Try to promote content view with multiple Docker repositories to - lifecycle environment. Verify that content has not been promoted. - - :id: baae1ec2-35e8-4122-8fac-135c987139d3 - - :expectedresults: Content view is not promoted - """ - docker_upstream_names = ['hello-world', 'alpine'] - new_pattern = "<%= organization.label %>" - - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - lce.registry_name_pattern = new_pattern - lce = lce.update(['registry_name_pattern']) - prod = module_target_sat.api.Product(organization=module_org).create() - repos = [] - for docker_name in docker_upstream_names: - repo = _create_repository(module_target_sat, prod, upstream_name=docker_name) - repo.sync(timeout=600) - repos.append(repo) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = repos - content_view = content_view.update(['repository']) - content_view.publish() - cvv = content_view.read().version[0] - with pytest.raises(HTTPError): - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - - @pytest.mark.tier2 - def test_negative_promote_and_set_non_unique_name_pattern(self, module_org, module_target_sat): - """Promote content view with multiple Docker repositories to - lifecycle environment. Set registry name pattern to one that - does not guarantee uniqueness. Verify that pattern has not been - changed. - - :id: 945b3301-c523-4026-9753-df3577888319 - - :expectedresults: Registry name pattern is not changed - """ - docker_upstream_names = ['hello-world', 'alpine'] - new_pattern = "<%= organization.label %>" - - prod = module_target_sat.api.Product(organization=module_org).create() - repos = [] - for docker_name in docker_upstream_names: - repo = _create_repository(module_target_sat, prod, upstream_name=docker_name) - repo.sync(timeout=600) - repos.append(repo) - content_view = module_target_sat.api.ContentView( - composite=False, organization=module_org - ).create() - content_view.repository = repos - content_view = content_view.update(['repository']) - content_view.publish() - cvv = content_view.read().version[0] - lce = module_target_sat.api.LifecycleEnvironment(organization=module_org).create() - cvv.promote(data={'environment_ids': lce.id, 'force': False}) - lce.registry_name_pattern = new_pattern - with pytest.raises(HTTPError): - lce.update(['registry_name_pattern']) - class TestDockerActivationKey: """Tests specific to adding ``Docker`` repositories to Activation Keys. diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 82f12ca1faa..4bd2aa3f59e 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -379,24 +379,6 @@ def test_negative_delete_version_by_id(self, module_org, module_target_sat): content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) assert len(content_view['versions']) == 1 - @pytest.mark.tier1 - def test_positive_remove_lce_by_id(self, module_org, module_target_sat): - """Remove content view from lifecycle environment - - :id: 1bf8a647-d82e-4145-b13b-f92bf6642532 - - :expectedresults: Content view removed from environment successfully - - :CaseImportance: Critical - """ - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - env = new_cv['lifecycle-environments'][0] - module_target_sat.cli.ContentView.remove({'id': new_cv['id'], 'environment-ids': env['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - assert len(new_cv['lifecycle-environments']) == 0 - @pytest.mark.tier3 def test_positive_remove_lce_by_id_and_reassign_ak(self, module_org, module_target_sat): """Remove content view environment and re-assign activation key to @@ -647,98 +629,6 @@ def test_positive_remove_repository_by_name( new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) assert len(new_cv['yum-repositories']) == 0 - @pytest.mark.tier2 - def test_positive_create_composite(self, module_org, module_target_sat): - """create a composite content view - - :id: bded6acd-8da3-45ea-9e39-19bdc6c06341 - - :setup: sync multiple content source/types (RH, custom, etc.) - - :expectedresults: Composite content views are created - - :CaseImportance: High - """ - # Create REPO - new_product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': new_product['id']} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a new version of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - # Let us now store the version1 id - version1_id = new_cv['versions'][0]['id'] - # Create CV - con_view = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - # Associate version to composite CV - module_target_sat.cli.ContentView.add_version( - {'content-view-version-id': version1_id, 'id': con_view['id']} - ) - # Assert whether version was associated to composite CV - con_view = module_target_sat.cli.ContentView.info({'id': con_view['id']}) - assert con_view['components'][0]['id'] == version1_id - - @pytest.mark.tier2 - def test_positive_create_composite_by_name(self, module_org, module_target_sat): - """Create a composite content view and add non-composite content - view by its name - - :id: c91271d8-efb8-487e-ab11-2e9e87660d3c - - :expectedresults: Composite content view is created and has another - view associated to it - - :BZ: 1416857 - - :CaseImportance: High - """ - new_product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) - # Create REPO - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': new_product['id']} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a new version of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - cvv = new_cv['versions'][0] - # Create CV - cv = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - assert len(cv['components']) == 0 - # Associate version to composite CV - module_target_sat.cli.ContentView.add_version( - { - 'content-view-version': cvv['version'], - 'content-view': new_cv['name'], - 'name': cv['name'], - 'organization-id': module_org.id, - } - ) - # Assert whether version was associated to composite CV - cv = module_target_sat.cli.ContentView.info({'id': cv['id']}) - assert len(cv['components']) == 1 - assert cv['components'][0]['id'] == cvv['id'] - @pytest.mark.tier2 def test_positive_remove_version_by_id_from_composite( self, module_org, module_product, module_target_sat @@ -911,67 +801,36 @@ def test_negative_create_composite_with_component_ids(self, module_org, module_t ) assert 'Failed to create ContentView with data:' in str(context) - @pytest.mark.tier3 - def test_positive_update_composite_with_component_ids(module_org, module_target_sat): - """Update a composite content view with a component_ids option - - :id: e6106ff6-c526-40f2-bdc0-ae291f7b267e - - :expectedresults: Composite content view component ids are similar to - the nested content view versions ids - - :CaseImportance: Low - """ - # Create a CV to add to the composite one - cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Publish a new version of the CV - module_target_sat.cli.ContentView.publish({'id': cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': cv['id']}) - # Let us now store the version ids - component_ids = new_cv['versions'][0]['id'] - # Create a composite CV - comp_cv = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - # Update a composite content view with a component id version - module_target_sat.cli.ContentView.update( - {'id': comp_cv['id'], 'component-ids': component_ids} - ) - # Assert whether the composite content view components IDs are equal - # to the component_ids input values - comp_cv = module_target_sat.cli.ContentView.info({'id': comp_cv['id']}) - assert comp_cv['components'][0]['id'] == component_ids - - @pytest.mark.run_in_one_thread - @pytest.mark.tier1 - def test_positive_add_rh_repo_by_id( - self, module_entitlement_manifest_org, module_rhel_content, module_target_sat - ): - """Associate Red Hat content to a content view - - :id: b31a85c3-aa56-461b-9e3a-f7754c742573 + @pytest.mark.tier3 + def test_positive_update_composite_with_component_ids(module_org, module_target_sat): + """Update a composite content view with a component_ids option - :setup: Sync RH content + :id: e6106ff6-c526-40f2-bdc0-ae291f7b267e - :expectedresults: RH Content can be seen in the content view + :expectedresults: Composite content view component ids are similar to + the nested content view versions ids - :CaseImportance: Critical + :CaseImportance: Low """ - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_entitlement_manifest_org.id} + # Create a CV to add to the composite one + cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) + # Publish a new version of the CV + module_target_sat.cli.ContentView.publish({'id': cv['id']}) + new_cv = module_target_sat.cli.ContentView.info({'id': cv['id']}) + # Let us now store the version ids + component_ids = new_cv['versions'][0]['id'] + # Create a composite CV + comp_cv = module_target_sat.cli_factory.make_content_view( + {'composite': True, 'organization-id': module_org.id} ) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - { - 'id': new_cv['id'], - 'organization-id': module_entitlement_manifest_org.id, - 'repository-id': module_rhel_content['id'], - } + # Update a composite content view with a component id version + module_target_sat.cli.ContentView.update( + {'id': comp_cv['id'], 'component-ids': component_ids} ) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - - assert new_cv['yum-repositories'][0]['name'] == module_rhel_content['name'] + # Assert whether the composite content view components IDs are equal + # to the component_ids input values + comp_cv = module_target_sat.cli.ContentView.info({'id': comp_cv['id']}) + assert comp_cv['components'][0]['id'] == component_ids @pytest.mark.run_in_one_thread @pytest.mark.tier3 @@ -1070,33 +929,6 @@ def test_positive_add_module_stream_filter_rule(self, module_org, target_sat): ) assert filter_info['rules'][0]['id'] == content_view_filter_rule['rule-id'] - @pytest.mark.tier2 - def test_positive_add_custom_repo_by_id(self, module_org, module_product, module_target_sat): - """Associate custom content to a Content view - - :id: b813b222-b984-47e0-8d9b-2daa43f9a221 - - :setup: Sync custom content - - :expectedresults: Custom content can be seen in a view - - :CaseImportance: High - - """ - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': module_product.id} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - assert new_cv['yum-repositories'][0]['name'] == new_repo['name'] - @pytest.mark.tier1 def test_positive_add_custom_repo_by_name(self, module_org, module_product, module_target_sat): """Associate custom content to a content view with name @@ -1128,44 +960,6 @@ def test_positive_add_custom_repo_by_name(self, module_org, module_product, modu new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) assert new_cv['yum-repositories'][0]['name'] == new_repo['name'] - @pytest.mark.tier2 - def test_negative_add_component_in_non_composite_cv( - self, module_org, module_product, module_target_sat - ): - """attempt to associate components in a non-composite content - view - - :id: 2a6f150d-e012-47c1-9423-d73f5d620dc9 - - :expectedresults: User cannot add components to the view - - :CaseImportance: Low - - """ - # Create REPO - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': module_product.id} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create component CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a new version of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - # Fetch version id - cv_version = module_target_sat.cli.ContentView.version_list( - {'content-view-id': new_cv['id']} - ) - # Create non-composite CV - with pytest.raises(CLIFactoryError): - module_target_sat.cli_factory.make_content_view( - {'component-ids': cv_version[0]['id'], 'organization-id': module_org.id} - ) - @pytest.mark.tier2 def test_negative_add_same_yum_repo_twice(self, module_org, module_product, module_target_sat): """attempt to associate the same repo multiple times within a @@ -1473,37 +1267,6 @@ def test_negative_promote_with_invalid_lce(self, module_org, module_product, mod # Content Views: publish # katello content definition publish --label=MyView - @pytest.mark.run_in_one_thread - @pytest.mark.tier2 - def test_positive_publish_rh_content( - self, module_entitlement_manifest_org, module_rhel_content, module_target_sat - ): - """attempt to publish a content view containing RH content - - :id: d4323759-d869-4d62-ab2e-f1ea3dbb38ba - - :setup: Multiple environments for an org; RH content synced - - :expectedresults: Content view can be published - - :CaseImportance: Critical - - """ - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_entitlement_manifest_org.id} - ) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': module_rhel_content['id']} - ) - # Publish a new version of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - assert new_cv['yum-repositories'][0]['name'] == module_rhel_content['name'] - - assert new_cv['versions'][0]['version'] == '1.0' - @pytest.mark.run_in_one_thread @pytest.mark.pit_server @pytest.mark.tier3 @@ -1562,36 +1325,6 @@ def test_positive_publish_rh_and_custom_content( ) assert new_cv['versions'][0]['version'] == '1.0' - @pytest.mark.tier2 - def test_positive_publish_custom_content(self, module_org, module_product, module_target_sat): - """attempt to publish a content view containing custom content - - :id: 84158023-3980-45c6-87d8-faacea3c942f - - :setup: Multiple environments for an org; custom content synced - - :expectedresults: Content view can be published - - :CaseImportance: Critical - - """ - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': module_product.id} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a new version of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - assert new_cv['yum-repositories'][0]['name'] == new_repo['name'] - assert new_cv['versions'][0]['version'] == '1.0' - @pytest.mark.tier2 def test_positive_publish_custom_major_minor_cv_version(self, module_target_sat): """CV can published with custom major and minor versions @@ -1862,194 +1595,33 @@ def test_positive_publish_ccv(self, module_org, module_product, module_target_sa assert composite_cv['versions'][0]['version'] == '1.0' @pytest.mark.tier2 - @pytest.mark.upgrade - def test_positive_update_version_once(self, module_org, module_product, module_target_sat): - # Dev notes: - # If Dev has version x, then when I promote version y into - # Dev, version x goes away (ie when I promote version 1 to Dev, - # version 3 goes away) - """when publishing new version to environment, version - gets updated + def test_positive_auto_update_composite_to_latest_cv_version( + self, module_org, module_target_sat + ): + """Ensure that composite content view component is auto updated to the + latest content view version. - :id: cef62d34-c006-4bd0-950e-29e732388c00 + :id: c0726d16-1802-4b56-a850-d66948ab70e2 - :setup: Multiple environments for an org; multiple versions of a - content view created/published + :customerscenario: true :steps: - 1. publish a view to an environment noting the CV version - 2. edit and republish a new version of a CV + 1. Create a non composite content view and publish it + 2. Create a composite content view + 3. Add the non composite content view to composite one components + with latest option + 4. Ensure that the published non composite content view version 1 + is in composite content view components + 5. Publish a second time the non composite content view - :expectedresults: Content view version is updated in target - environment. + :expectedresults: The composite content view component was updated + to version 2 of the non composite one + :BZ: 1177766 - :CaseImportance: Critical + :CaseImportance: High """ - # Create REPO - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': module_product.id} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create lce - environment = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a version1 of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - # Only after we publish version1 the info is populated. - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - # Let us now store the version1 id - version1_id = new_cv['versions'][0]['id'] - # Actual assert for this test happens HERE - # Test whether the version1 now belongs to Library - version1 = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert constants.ENVIRONMENT in [env['label'] for env in version1['lifecycle-environments']] - # Promotion of version1 to Dev env - module_target_sat.cli.ContentView.version_promote( - {'id': version1_id, 'to-lifecycle-environment-id': environment['id']} - ) - # The only way to validate whether env has the version is to - # validate that version has the env. - version1 = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert environment['id'] in [env['id'] for env in version1['lifecycle-environments']] - # Now Publish version2 of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - # Only after we publish version2 the info is populated. - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - new_cv['versions'].sort(key=lambda version: version['id']) - # Let us now store the version2 id - version2_id = new_cv['versions'][1]['id'] - # Test whether the version2 now belongs to Library - version2 = module_target_sat.cli.ContentView.version_info({'id': version2_id}) - assert constants.ENVIRONMENT in [env['label'] for env in version2['lifecycle-environments']] - # Promotion of version2 to Dev env - module_target_sat.cli.ContentView.version_promote( - {'id': version2_id, 'to-lifecycle-environment-id': environment['id']} - ) - # Actual assert for this test happens here. - # Test whether the version2 now belongs to next env - version2 = module_target_sat.cli.ContentView.version_info({'id': version2_id}) - assert environment['id'] in [env['id'] for env in version2['lifecycle-environments']] - - @pytest.mark.tier2 - def test_positive_update_version_multiple(self, module_org, module_product, module_target_sat): - # Dev notes: - # Similarly when I publish version y, version x goes away from - # Library (ie when I publish version 2, version 1 disappears) - """when publishing new version to environment, version - gets updated - - :id: e5704b86-9919-471b-8362-1831d1983e70 - - :setup: Multiple environments for an org; multiple versions of a - content view created/published - - :steps: - 1. publish a view to an environment - 2. edit and republish a new version of a CV - - :expectedresults: Content view version is updated in source - environment. - - :CaseImportance: Low - - """ - # Create REPO - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': module_product.id} - ) - # Sync REPO - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - # Create lce - environment = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - # Create CV - new_cv = module_target_sat.cli_factory.make_content_view({'organization-id': module_org.id}) - # Associate repo to CV - module_target_sat.cli.ContentView.add_repository( - {'id': new_cv['id'], 'repository-id': new_repo['id']} - ) - # Publish a version1 of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - # Only after we publish version1 the info is populated. - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - # Let us now store the version1 id - version1_id = new_cv['versions'][0]['id'] - # Test whether the version1 now belongs to Library - version = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert constants.ENVIRONMENT in [env['label'] for env in version['lifecycle-environments']] - # Promotion of version1 to Dev env - module_target_sat.cli.ContentView.version_promote( - {'id': version1_id, 'to-lifecycle-environment-id': environment['id']} - ) - # The only way to validate whether env has the version is to - # validate that version has the env. - # Test whether the version1 now belongs to next env - version1 = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert environment['id'] in [env['id'] for env in version1['lifecycle-environments']] - # Now Publish version2 of CV - module_target_sat.cli.ContentView.publish({'id': new_cv['id']}) - # As per Dev Notes: - # Similarly when I publish version y, version x goes away from Library. - # Actual assert for this test happens here. - # Test that version1 does not exist in Library after publishing v2 - version1 = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert len(version1['lifecycle-environments']) == 1 - assert constants.ENVIRONMENT not in [ - env['label'] for env in version1['lifecycle-environments'] - ] - # Only after we publish version2 the info is populated. - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - new_cv['versions'].sort(key=lambda version: version['id']) - # Let us now store the version2 id - version2_id = new_cv['versions'][1]['id'] - # Promotion of version2 to next env - module_target_sat.cli.ContentView.version_promote( - {'id': version2_id, 'to-lifecycle-environment-id': environment['id']} - ) - # Actual assert for this test happens here. - # Test that version1 does not exist in any/next env after, - # promoting version2 to next env - version1 = module_target_sat.cli.ContentView.version_info({'id': version1_id}) - assert len(version1['lifecycle-environments']) == 0 - - @pytest.mark.tier2 - def test_positive_auto_update_composite_to_latest_cv_version( - self, module_org, module_target_sat - ): - """Ensure that composite content view component is auto updated to the - latest content view version. - - :id: c0726d16-1802-4b56-a850-d66948ab70e2 - - :customerscenario: true - - :steps: - 1. Create a non composite content view and publish it - 2. Create a composite content view - 3. Add the non composite content view to composite one components - with latest option - 4. Ensure that the published non composite content view version 1 - is in composite content view components - 5. Publish a second time the non composite content view - - :expectedresults: The composite content view component was updated - to version 2 of the non composite one - - :BZ: 1177766 - - :CaseImportance: High - """ - content_view = module_target_sat.cli_factory.make_content_view( + content_view = module_target_sat.cli_factory.make_content_view( {'organization-id': module_org.id} ) module_target_sat.cli.ContentView.publish({'id': content_view['id']}) @@ -2092,42 +1664,6 @@ def test_positive_auto_update_composite_to_latest_cv_version( assert components[0]['version-id'] == f'{version_2_id} (Latest)' assert components[0]['current-version'] == '2.0' - @pytest.mark.tier3 - def test_positive_subscribe_chost_by_id(self, module_org, module_target_sat): - """Attempt to subscribe content host to content view - - :id: db0bfd9d-3150-427e-9683-a68af33813e7 - - :expectedresults: Content host can be subscribed to content view - - :CaseImportance: High - - """ - env = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - cvv = content_view['versions'][0] - module_target_sat.cli.ContentView.version_promote( - {'id': cvv['id'], 'to-lifecycle-environment-id': env['id']} - ) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert content_view['content-host-count'] == '0' - module_target_sat.cli_factory.make_fake_host( - { - 'content-view-id': content_view['id'], - 'lifecycle-environment-id': env['id'], - 'name': gen_alphanumeric(), - 'organization-id': module_org.id, - } - ) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert content_view['content-host-count'] == '1' - @pytest.mark.run_in_one_thread @pytest.mark.tier3 def test_positive_subscribe_chost_by_id_using_rh_content( @@ -2250,60 +1786,6 @@ def test_positive_subscribe_chost_by_id_using_rh_content_and_filters( content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) assert content_view['content-host-count'] == '1' - @pytest.mark.tier3 - def test_positive_subscribe_chost_by_id_using_custom_content( - self, module_org, module_target_sat - ): - """Attempt to subscribe content host to content view that has - custom repository assigned to it - - :id: 9758756a-2536-4777-a6a9-ed618453ebe7 - - :expectedresults: Content Host can be subscribed to content view with - custom repository - - :CaseImportance: High - """ - new_product = module_target_sat.cli_factory.make_product({'organization-id': module_org.id}) - new_repo = module_target_sat.cli_factory.make_repository( - {'content-type': 'yum', 'product-id': new_product['id']} - ) - env = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - module_target_sat.cli.Repository.synchronize({'id': new_repo['id']}) - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.add_repository( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'repository-id': new_repo['id'], - } - ) - - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - cvv = content_view['versions'][0] - module_target_sat.cli.ContentView.version_promote( - {'id': cvv['id'], 'to-lifecycle-environment-id': env['id']} - ) - - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert content_view['content-host-count'] == '0' - - module_target_sat.cli_factory.make_fake_host( - { - 'content-view-id': content_view['id'], - 'lifecycle-environment-id': env['id'], - 'name': gen_alphanumeric(), - 'organization-id': module_org.id, - } - ) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert content_view['content-host-count'] == '1' - @pytest.mark.tier3 def test_positive_subscribe_chost_by_id_using_ccv(self, module_org, module_target_sat): """Attempt to subscribe content host to composite content view @@ -2658,26 +2140,6 @@ def test_positive_sub_host_with_restricted_user_perm_at_default_loc( assert len(org_hosts) == 1 assert org_hosts[0]['name'] == rhel7_contenthost.hostname - @pytest.mark.tier1 - def test_positive_clone_by_id(self, module_org, module_target_sat): - """Clone existing content view by id - - :id: e3b63e6e-0964-45fb-a765-e1885c0ecbdd - - :expectedresults: Content view is cloned successfully - - :CaseImportance: Critical - """ - cloned_cv_name = gen_string('alpha') - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - new_cv = module_target_sat.cli.ContentView.copy( - {'id': content_view['id'], 'new-name': cloned_cv_name} - )[0] - new_cv = module_target_sat.cli.ContentView.info({'id': new_cv['id']}) - assert new_cv['name'] == cloned_cv_name - @pytest.mark.tier1 def test_positive_clone_by_name(self, module_org, module_target_sat): """Clone existing content view by name @@ -2983,198 +2445,6 @@ def test_positive_remove_promoted_cv_version_from_default_env( } assert {lce_dev['name']} == content_view_version_lce_names - @pytest.mark.tier2 - def test_positive_remove_qe_promoted_cv_version_from_default_env( - self, module_org, module_target_sat - ): - """Remove QE promoted content view version from Library environment - - :id: e286697f-4113-40a3-b8e8-9ca50647e6d5 - - :steps: - - 1. Create a content view - 2. Add docker repo(s) to it - 3. Publish content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE - 5. remove the content view version from Library environment - - :expectedresults: Content view version exist only in DEV, QE and not in - Library - - :CaseImportance: High - """ - lce_dev = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - lce_qe = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_dev['name']} - ) - docker_product = module_target_sat.cli_factory.make_product( - {'organization-id': module_org.id} - ) - docker_repository = module_target_sat.cli_factory.make_repository( - { - 'content-type': 'docker', - 'docker-upstream-name': constants.CONTAINER_UPSTREAM_NAME, - 'name': gen_string('alpha', 20), - 'product-id': docker_product['id'], - 'url': constants.CONTAINER_REGISTRY_HUB, - } - ) - module_target_sat.cli.Repository.synchronize({'id': docker_repository['id']}) - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.add_repository( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'repository-id': docker_repository['id'], - } - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view_versions = module_target_sat.cli.ContentView.info({'id': content_view['id']})[ - 'versions' - ] - assert len(content_view_versions) > 0 - content_view_version = content_view_versions[-1] - for lce in [lce_dev, lce_qe]: - module_target_sat.cli.ContentView.version_promote( - {'id': content_view_version['id'], 'to-lifecycle-environment-id': lce['id']} - ) - # ensure that the published content version is in Library, DEV and QE - # environments - assert { - constants.ENVIRONMENT, - lce_dev['name'], - lce_qe['name'], - } == _get_content_view_version_lce_names_set( - content_view['id'], content_view_version['id'], sat=module_target_sat - ) - # remove content view version from Library lifecycle environment - module_target_sat.cli.ContentView.remove_from_environment( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'lifecycle-environment': constants.ENVIRONMENT, - } - ) - # ensure content view version is not in Library and only in DEV and QE - # environments - assert {lce_dev['name'], lce_qe['name']} == _get_content_view_version_lce_names_set( - content_view['id'], content_view_version['id'], sat=module_target_sat - ) - - @pytest.mark.tier2 - @pytest.mark.skipif( - (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' - ) - def test_positive_remove_prod_promoted_cv_version_from_default_env( - self, module_org, module_target_sat - ): - """Remove PROD promoted content view version from Library environment - - :id: ffe3d64e-c3d2-4889-9454-ccc6b10f4db7 - - :steps: - - 1. Create a content view - 2. Add yum repositories and docker repositories to CV - 3. Publish content view - 4. Promote the content view version to multiple environments - Library -> DEV -> QE -> PROD - 5. remove the content view version from Library environment - - :expectedresults: Content view version exist only in DEV, QE, PROD and - not in Library - - :CaseImportance: High - - """ - lce_dev = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - lce_qe = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_dev['name']} - ) - lce_prod = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_qe['name']} - ) - custom_yum_product = module_target_sat.cli_factory.make_product( - {'organization-id': module_org.id} - ) - custom_yum_repo = module_target_sat.cli_factory.make_repository( - { - 'content-type': 'yum', - 'product-id': custom_yum_product['id'], - 'url': settings.repos.yum_1.url, - } - ) - module_target_sat.cli.Repository.synchronize({'id': custom_yum_repo['id']}) - docker_product = module_target_sat.cli_factory.make_product( - {'organization-id': module_org.id} - ) - docker_repository = module_target_sat.cli_factory.make_repository( - { - 'content-type': 'docker', - 'docker-upstream-name': constants.CONTAINER_UPSTREAM_NAME, - 'name': gen_string('alpha', 20), - 'product-id': docker_product['id'], - 'url': constants.CONTAINER_REGISTRY_HUB, - } - ) - module_target_sat.cli.Repository.synchronize({'id': docker_repository['id']}) - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - for repo in [custom_yum_repo, docker_repository]: - module_target_sat.cli.ContentView.add_repository( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'repository-id': repo['id'], - } - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view_versions = module_target_sat.cli.ContentView.info({'id': content_view['id']})[ - 'versions' - ] - assert len(content_view_versions) > 0 - content_view_version = content_view_versions[-1] - for lce in [lce_dev, lce_qe, lce_prod]: - module_target_sat.cli.ContentView.version_promote( - {'id': content_view_version['id'], 'to-lifecycle-environment-id': lce['id']} - ) - # ensure that the published content version is in Library, DEV, QE and - # PROD environments - assert { - constants.ENVIRONMENT, - lce_dev['name'], - lce_qe['name'], - lce_prod['name'], - } == _get_content_view_version_lce_names_set( - content_view['id'], content_view_version['id'], sat=module_target_sat - ) - # remove content view version from Library lifecycle environment - module_target_sat.cli.ContentView.remove_from_environment( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'lifecycle-environment': constants.ENVIRONMENT, - } - ) - # ensure content view version is not in Library and only in DEV, QE - # and PROD environments - assert { - lce_dev['name'], - lce_qe['name'], - lce_prod['name'], - } == _get_content_view_version_lce_names_set( - content_view['id'], content_view_version['id'], sat=module_target_sat - ) - @pytest.mark.tier2 @pytest.mark.skipif( (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' @@ -3407,114 +2677,6 @@ def test_positive_remove_cv_version_from_multi_env(self, module_org, module_targ content_view['id'], content_view_version['id'], sat=module_target_sat ) - @pytest.mark.tier3 - def test_positive_delete_cv_promoted_to_multi_env(self, module_org, module_target_sat): - """Delete published content view with version promoted to multiple - environments - - :id: 93dd7518-5901-4a71-a4c3-0f1215238b26 - - :steps: - - 1. Create a content view - 2. Add a yum repo and a docker to the content view - 3. Publish the content view - 4. Promote the content view to multiple environment Library -> DEV - -> QE -> STAGE -> PROD - 5. Delete the content view (may delete the published versions - environments prior this step) - - :expectedresults: The content view doesn't exists - - :CaseImportance: High - """ - lce_dev = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - lce_qe = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_dev['name']} - ) - lce_stage = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_qe['name']} - ) - lce_prod = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id, 'prior': lce_stage['name']} - ) - custom_yum_product = module_target_sat.cli_factory.make_product( - {'organization-id': module_org.id} - ) - custom_yum_repo = module_target_sat.cli_factory.make_repository( - { - 'content-type': 'yum', - 'product-id': custom_yum_product['id'], - 'url': settings.repos.yum_1.url, - } - ) - module_target_sat.cli.Repository.synchronize({'id': custom_yum_repo['id']}) - docker_product = module_target_sat.cli_factory.make_product( - {'organization-id': module_org.id} - ) - docker_repository = module_target_sat.cli_factory.make_repository( - { - 'content-type': 'docker', - 'docker-upstream-name': constants.CONTAINER_UPSTREAM_NAME, - 'name': gen_string('alpha', 20), - 'product-id': docker_product['id'], - 'url': constants.CONTAINER_REGISTRY_HUB, - } - ) - module_target_sat.cli.Repository.synchronize({'id': docker_repository['id']}) - content_view = module_target_sat.cli_factory.make_content_view( - {'organization-id': module_org.id} - ) - for repo in [custom_yum_repo, docker_repository]: - module_target_sat.cli.ContentView.add_repository( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'repository-id': repo['id'], - } - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view_versions = module_target_sat.cli.ContentView.info({'id': content_view['id']})[ - 'versions' - ] - assert len(content_view_versions) > 0 - content_view_version = content_view_versions[-1] - for lce in [lce_dev, lce_qe, lce_stage, lce_prod]: - module_target_sat.cli.ContentView.version_promote( - {'id': content_view_version['id'], 'to-lifecycle-environment-id': lce['id']} - ) - # ensure that the published content version is in Library, DEV, QE, - # STAGE and PROD environments - promoted_lce_names_set = _get_content_view_version_lce_names_set( - content_view['id'], content_view_version['id'], sat=module_target_sat - ) - assert { - constants.ENVIRONMENT, - lce_dev['name'], - lce_qe['name'], - lce_stage['name'], - lce_prod['name'], - } == promoted_lce_names_set - # remove from all promoted lifecycle environments - for lce_name in promoted_lce_names_set: - module_target_sat.cli.ContentView.remove_from_environment( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'lifecycle-environment': lce_name, - } - ) - # ensure content view in content views list - content_views = module_target_sat.cli.ContentView.list({'organization-id': module_org.id}) - assert content_view['name'] in [cv['name'] for cv in content_views] - # delete the content view - module_target_sat.cli.ContentView.delete({'id': content_view['id']}) - # ensure the content view is not in content views list - content_views = module_target_sat.cli.ContentView.list({'organization-id': module_org.id}) - assert content_view['name'] not in [cv['name'] for cv in content_views] - @pytest.mark.stubbed @pytest.mark.tier3 @pytest.mark.upgrade @@ -4324,26 +3486,6 @@ def test_positive_arbitrary_file_repo_promotion( assert repo['name'] in expected_repo - @pytest.mark.tier3 - def test_positive_katello_repo_rpms_max_int(self, target_sat): - """Checking that datatype for katello_repository_rpms table is a - bigint for id for a closed loop bz. - - :id: e83b3a00-c851-4970-a70d-abd26b2d3593 - - :expectedresults: id datatype is bigint - - :CaseImportance: Medium - - :customerscenario: true - - :BZ: 1793701 - """ - result = target_sat.execute( - 'sudo -u postgres psql -d foreman -c "\\d katello_repository_rpms"' - ) - assert 'id|bigint' in result.stdout.splitlines()[3].replace(' ', '') - @pytest.mark.tier3 def test_positive_inc_update_should_not_fail(self, module_org, module_target_sat): """Incremental update after removing a package should not give a 400 error code diff --git a/tests/foreman/cli/test_contentviewfilter.py b/tests/foreman/cli/test_contentviewfilter.py index 65ffeb940a5..2a945a1503c 100644 --- a/tests/foreman/cli/test_contentviewfilter.py +++ b/tests/foreman/cli/test_contentviewfilter.py @@ -788,78 +788,6 @@ def test_negative_update_with_name(self, new_name, content_view, module_target_s {'content-view-id': content_view['id'], 'name': new_name} ) - @pytest.mark.tier1 - def test_negative_update_with_same_name(self, module_org, content_view, module_target_sat): - """Try to update content view filter using name of already - existing entity - - :id: 9c1b1c75-af57-4218-9e2d-e69d74f50e04 - - :expectedresults: Content view filter is not updated - - :CaseImportance: Critical - """ - cvf_name = gen_string('utf8') - module_target_sat.cli.ContentView.filter.create( - { - 'content-view-id': content_view['id'], - 'name': cvf_name, - 'organization-id': module_org.id, - 'type': 'rpm', - }, - ) - new_name = gen_string('alpha', 100) - module_target_sat.cli.ContentView.filter.create( - { - 'content-view-id': content_view['id'], - 'name': new_name, - 'organization-id': module_org.id, - 'type': 'rpm', - }, - ) - with pytest.raises(CLIReturnCodeError): - module_target_sat.cli.ContentView.filter.update( - { - 'content-view-id': content_view['id'], - 'name': new_name, - 'new-name': cvf_name, - } - ) - - @pytest.mark.tier1 - def test_negative_update_inclusion(self, module_org, content_view, module_target_sat): - """Try to update content view filter and assign incorrect inclusion - value for it - - :id: 760400a8-49a5-4a31-924c-c232cb22ddad - - :expectedresults: Content view filter is not updated - - :CaseImportance: Critical - """ - cvf_name = gen_string('utf8') - module_target_sat.cli.ContentView.filter.create( - { - 'content-view-id': content_view['id'], - 'inclusion': 'true', - 'name': cvf_name, - 'organization-id': module_org.id, - 'type': 'rpm', - }, - ) - with pytest.raises(CLIReturnCodeError): - module_target_sat.cli.ContentView.filter.update( - { - 'content-view-id': content_view['id'], - 'inclusion': 'wrong_value', - 'name': cvf_name, - } - ) - cvf = module_target_sat.cli.ContentView.filter.info( - {'content-view-id': content_view['id'], 'name': cvf_name} - ) - assert cvf['inclusion'] == 'true' - @pytest.mark.tier1 def test_negative_update_with_non_existent_repo_id( self, sync_repo, content_view, module_target_sat diff --git a/tests/foreman/cli/test_docker.py b/tests/foreman/cli/test_docker.py index 10b1d1dd4fc..fcd2379d76e 100644 --- a/tests/foreman/cli/test_docker.py +++ b/tests/foreman/cli/test_docker.py @@ -399,24 +399,6 @@ class TestDockerContentView: :team: Phoenix-content """ - @pytest.mark.tier2 - def test_positive_add_docker_repo_by_id(self, module_org, repo, module_target_sat): - """Add one Docker-type repository to a non-composite content view - - :id: 87d6c7bb-92f8-4a32-8ad2-2a1af896500b - - :expectedresults: A repository is created with a Docker repository and - the product is added to a non-composite content view - """ - content_view = module_target_sat.cli_factory.make_content_view( - {'composite': False, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.add_repository( - {'id': content_view['id'], 'repository-id': repo['id']} - ) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert repo['id'] in [repo_['id'] for repo_ in content_view['container-image-repositories']] - @pytest.mark.tier2 def test_positive_add_docker_repos_by_id(self, module_org, module_product, module_target_sat): """Add multiple Docker-type repositories to a non-composite CV. @@ -441,115 +423,6 @@ def test_positive_add_docker_repos_by_id(self, module_org, module_product, modul repo['id'] for repo in content_view['container-image-repositories'] } - @pytest.mark.tier2 - def test_positive_add_synced_docker_repo_by_id(self, module_org, repo, module_target_sat): - """Create and sync a Docker-type repository - - :id: 6f51d268-ed23-48ab-9dea-cd3571daa647 - - :expectedresults: A repository is created with a Docker repository and - it is synchronized. - """ - module_target_sat.cli.Repository.synchronize({'id': repo['id']}) - repo = module_target_sat.cli.Repository.info({'id': repo['id']}) - assert int(repo['content-counts']['container-image-manifests']) > 0 - - content_view = module_target_sat.cli_factory.make_content_view( - {'composite': False, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.add_repository( - {'id': content_view['id'], 'repository-id': repo['id']} - ) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert repo['id'] in [repo_['id'] for repo_ in content_view['container-image-repositories']] - - @pytest.mark.tier2 - def test_positive_add_docker_repo_by_id_to_ccv( - self, module_org, content_view, module_target_sat - ): - """Add one Docker-type repository to a composite content view - - :id: 8e2ef5ba-3cdf-4ef9-a22a-f1701e20a5d5 - - :expectedresults: A repository is created with a Docker repository and - the product is added to a content view which is then added to a - composite content view. - - :BZ: 1359665 - """ - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - comp_content_view = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.update( - { - 'id': comp_content_view['id'], - 'component-ids': content_view['versions'][0]['id'], - } - ) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - assert content_view['versions'][0]['id'] in [ - component['id'] for component in comp_content_view['components'] - ] - - @pytest.mark.tier2 - def test_positive_add_docker_repos_by_id_to_ccv( - self, module_org, module_product, module_target_sat - ): - """Add multiple Docker-type repositories to a composite content view. - - :id: b79cbc97-3dba-4059-907d-19316684d569 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a random number of content - views which are then added to a composite content view. - - :BZ: 1359665 - """ - cv_versions = [] - for _ in range(randint(2, 5)): - content_view = module_target_sat.cli_factory.make_content_view( - {'composite': False, 'organization-id': module_org.id} - ) - repo = _repo(module_target_sat, module_product.id) - module_target_sat.cli.ContentView.add_repository( - {'id': content_view['id'], 'repository-id': repo['id']} - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - cv_versions.append(content_view['versions'][0]) - comp_content_view = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.update( - { - 'component-ids': [cv_version['id'] for cv_version in cv_versions], - 'id': comp_content_view['id'], - } - ) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - comp_ids = [component['id'] for component in comp_content_view['components']] - for cv_version in cv_versions: - assert cv_version['id'] in comp_ids - - @pytest.mark.tier2 - def test_positive_publish_with_docker_repo(self, content_view, module_target_sat): - """Add Docker-type repository to content view and publish it once. - - :id: 28480de3-ffb5-4b8e-8174-fffffeef6af4 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - published only once. - """ - assert len(content_view['versions']) == 0 - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - @pytest.mark.tier2 def test_positive_publish_with_docker_repo_composite( self, content_view, module_org, module_target_sat @@ -589,182 +462,6 @@ def test_positive_publish_with_docker_repo_composite( comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) assert len(comp_content_view['versions']) == 1 - @pytest.mark.tier2 - def test_positive_publish_multiple_with_docker_repo(self, content_view, module_target_sat): - """Add Docker-type repository to content view and publish it multiple - times. - - :id: 33c1b2ee-ae8a-4a7e-8254-123d97aaaa58 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - published multiple times. - """ - assert len(content_view['versions']) == 0 - - publish_amount = randint(2, 5) - for _ in range(publish_amount): - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == publish_amount - - @pytest.mark.tier2 - def test_positive_publish_multiple_with_docker_repo_composite( - self, module_org, content_view, module_target_sat - ): - """Add Docker-type repository to content view and publish it multiple - times. - - :id: 014adf90-d399-4a99-badb-76ee03a2c350 - - :expectedresults: One repository is created with a Docker upstream - repository and the product is added to a content view which is then - added to a composite content view which is then published multiple - times. - - :BZ: 1359665 - """ - assert len(content_view['versions']) == 0 - - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - - comp_content_view = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.update( - { - 'component-ids': content_view['versions'][0]['id'], - 'id': comp_content_view['id'], - } - ) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - assert content_view['versions'][0]['id'] in [ - component['id'] for component in comp_content_view['components'] - ] - - publish_amount = randint(2, 5) - for _ in range(publish_amount): - module_target_sat.cli.ContentView.publish({'id': comp_content_view['id']}) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - assert len(comp_content_view['versions']) == publish_amount - - @pytest.mark.tier2 - def test_positive_promote_with_docker_repo( - self, module_org, module_lce, content_view, module_target_sat - ): - """Add Docker-type repository to content view and publish it. - Then promote it to the next available lifecycle-environment. - - :id: a7df98f4-0ec0-40f6-8941-3dbb776d47b9 - - :expectedresults: Docker-type repository is promoted to content view - found in the specific lifecycle-environment. - """ - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - - cvv = module_target_sat.cli.ContentView.version_info( - {'id': content_view['versions'][0]['id']} - ) - assert len(cvv['lifecycle-environments']) == 1 - - module_target_sat.cli.ContentView.version_promote( - {'id': cvv['id'], 'to-lifecycle-environment-id': module_lce.id} - ) - cvv = module_target_sat.cli.ContentView.version_info( - {'id': content_view['versions'][0]['id']} - ) - assert len(cvv['lifecycle-environments']) == 2 - - @pytest.mark.tier2 - @pytest.mark.upgrade - def test_positive_promote_multiple_with_docker_repo( - self, module_org, content_view, module_target_sat - ): - """Add Docker-type repository to content view and publish it. - Then promote it to multiple available lifecycle-environments. - - :id: e9432bc4-a709-44d7-8e1d-00ca466aa32d - - :expectedresults: Docker-type repository is promoted to content view - found in the specific lifecycle-environments. - """ - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - - cvv = module_target_sat.cli.ContentView.version_info( - {'id': content_view['versions'][0]['id']} - ) - assert len(cvv['lifecycle-environments']) == 1 - - lces = [ - module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - for _ in range(1, randint(3, 6)) - ] - - for expected_lces, lce in enumerate(lces, start=2): - module_target_sat.cli.ContentView.version_promote( - {'id': cvv['id'], 'to-lifecycle-environment-id': lce['id']} - ) - cvv = module_target_sat.cli.ContentView.version_info({'id': cvv['id']}) - assert len(cvv['lifecycle-environments']) == expected_lces - - @pytest.mark.tier2 - def test_positive_promote_with_docker_repo_composite( - self, module_org, module_lce, content_view, module_target_sat - ): - """Add Docker-type repository to composite content view and publish it. - Then promote it to the next available lifecycle-environment. - - :id: fb7d132e-d7fa-4890-a0ec-746dd093513e - - :expectedresults: Docker-type repository is promoted to content view - found in the specific lifecycle-environment. - - :BZ: 1359665 - """ - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - assert len(content_view['versions']) == 1 - - comp_content_view = module_target_sat.cli_factory.make_content_view( - {'composite': True, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.update( - { - 'component-ids': content_view['versions'][0]['id'], - 'id': comp_content_view['id'], - } - ) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - assert content_view['versions'][0]['id'] in [ - component['id'] for component in comp_content_view['components'] - ] - - module_target_sat.cli.ContentView.publish({'id': comp_content_view['id']}) - comp_content_view = module_target_sat.cli.ContentView.info({'id': comp_content_view['id']}) - cvv = module_target_sat.cli.ContentView.version_info( - {'id': comp_content_view['versions'][0]['id']} - ) - assert len(cvv['lifecycle-environments']) == 1 - - module_target_sat.cli.ContentView.version_promote( - { - 'id': comp_content_view['versions'][0]['id'], - 'to-lifecycle-environment-id': module_lce.id, - } - ) - cvv = module_target_sat.cli.ContentView.version_info( - {'id': comp_content_view['versions'][0]['id']} - ) - assert len(cvv['lifecycle-environments']) == 2 - @pytest.mark.tier2 @pytest.mark.upgrade def test_positive_promote_multiple_with_docker_repo_composite( @@ -822,69 +519,6 @@ def test_positive_promote_multiple_with_docker_repo_composite( cvv = module_target_sat.cli.ContentView.version_info({'id': cvv['id']}) assert len(cvv['lifecycle-environments']) == expected_lces - @pytest.mark.tier2 - @pytest.mark.upgrade - def test_positive_name_pattern_change(self, module_org, module_target_sat): - """Promote content view with Docker repository to lifecycle environment. - Change registry name pattern for that environment. Verify that repository - name on product changed according to new pattern. - - :id: 63c99ae7-238b-40ed-8cc1-d847eb4e6d65 - - :expectedresults: Container repository name is changed - according to new pattern. - """ - lce = module_target_sat.cli_factory.make_lifecycle_environment( - {'organization-id': module_org.id} - ) - pattern_prefix = gen_string('alpha', 5) - docker_upstream_name = 'hello-world' - new_pattern = ( - f'{pattern_prefix}-<%= content_view.label %>/<%= repository.docker_upstream_name %>' - ) - - repo = _repo( - module_target_sat, - module_target_sat.cli_factory.make_product_wait({'organization-id': module_org.id})[ - 'id' - ], - name=gen_string('alpha', 5), - upstream_name=docker_upstream_name, - ) - module_target_sat.cli.Repository.synchronize({'id': repo['id']}) - content_view = module_target_sat.cli_factory.make_content_view( - {'composite': False, 'organization-id': module_org.id} - ) - module_target_sat.cli.ContentView.add_repository( - {'id': content_view['id'], 'repository-id': repo['id']} - ) - module_target_sat.cli.ContentView.publish({'id': content_view['id']}) - content_view = module_target_sat.cli.ContentView.info({'id': content_view['id']}) - - module_target_sat.cli.ContentView.version_promote( - {'id': content_view['versions'][0]['id'], 'to-lifecycle-environment-id': lce['id']} - ) - module_target_sat.cli.LifecycleEnvironment.update( - { - 'registry-name-pattern': new_pattern, - 'id': lce['id'], - 'organization-id': module_org.id, - } - ) - lce = module_target_sat.cli.LifecycleEnvironment.info( - {'id': lce['id'], 'organization-id': module_org.id} - ) - assert lce['registry-name-pattern'] == new_pattern - - repo = module_target_sat.cli.Repository.list( - {'name': repo['name'], 'environment-id': lce['id'], 'organization-id': module_org.id} - )[0] - expected_name = f'{pattern_prefix}-{content_view["label"]}/{docker_upstream_name}'.lower() - assert ( - module_target_sat.cli.Repository.info({'id': repo['id']})['container-repository-name'] - == expected_name - ) - @pytest.mark.tier2 def test_positive_product_name_change_after_promotion(self, module_org, module_target_sat): """Promote content view with Docker repository to lifecycle environment.