def test_add_synced_docker_repo_to_content_view(self): """@Test: Create and sync a Docker-type repository @Assert: A repository is created with a Docker repository and it is synchronized. @Feature: Docker """ repo = _make_docker_repo( make_product({'organization-id': self.org_id})['id']) Repository.synchronize({'id': repo['id']}) repo = Repository.info({'id': repo['id']}) self.assertGreaterEqual( int(repo['content-counts']['docker-images']), 1) content_view = make_content_view({ 'composite': False, 'organization-id': self.org_id, }) ContentView.add_repository({ 'id': content_view['id'], 'repository-id': repo['id'], }) content_view = ContentView.info({'id': content_view['id']}) self.assertIn( repo['id'], [repo_['id'] for repo_ in content_view['docker-repositories']], )
def test_update_cvf_repo(self): """Test: Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and change affected repository on another one. @Feature: Content View Filter @Assert: Content view filter updated successfully and has new repository affected """ cvf_name = gen_string("utf8") ContentView.filter_create( { "content-view-id": self.content_view["id"], "name": cvf_name, "repository-ids": self.repo["id"], "type": "rpm", } ) cvf = ContentView.filter_info({u"content-view-id": self.content_view["id"], u"name": cvf_name}) self.assertEqual(len(cvf["repositories"]), 1) self.assertEqual(cvf["repositories"][0]["name"], self.repo["name"]) new_repo = make_repository({u"product-id": self.product["id"]}) ContentView.add_repository({u"id": self.content_view["id"], u"repository-id": new_repo["id"]}) ContentView.filter_update( {"content-view-id": self.content_view["id"], "name": cvf_name, "repository-ids": new_repo["id"]} ) cvf = ContentView.filter_info({u"content-view-id": self.content_view["id"], u"name": cvf_name}) self.assertEqual(len(cvf["repositories"]), 1) self.assertNotEqual(cvf["repositories"][0]["name"], self.repo["name"]) self.assertEqual(cvf["repositories"][0]["name"], new_repo["name"])
def _create_and_associate_repo_with_cv(self): """Create a Docker-based repository and content view and associate them. """ self.repo = _make_docker_repo( make_product({'organization-id': self.org_id})['id']) self.content_view = make_content_view({ 'composite': False, 'organization-id': self.org_id, }) ContentView.add_repository({ 'id': self.content_view['id'], 'repository-id': self.repo['id'], }) self.content_view = ContentView.info({ 'id': self.content_view['id'] }) self.assertIn( self.repo['id'], [ repo_['id'] for repo_ in self.content_view['docker-repositories'] ], )
def test_add_multiple_docker_repos_to_content_view(self): """@Test: Add multiple Docker-type repositories to a non-composite content view. @Assert: Repositories are created with Docker images and the product is added to a non-composite content view. @Feature: Docker """ product = make_product({'organization-id': self.org_id}) repos = [ _make_docker_repo(product['id']) for _ in range(randint(2, 5)) ] content_view = make_content_view({ 'composite': False, 'organization-id': self.org_id, }) for repo in repos: ContentView.add_repository({ 'id': content_view['id'], 'repository-id': repo['id'], }) content_view = ContentView.info({'id': content_view['id']}) self.assertEqual( set([repo['id'] for repo in repos]), set([repo['id'] for repo in content_view['docker-repositories']]), )
def test_positive_sync_publish_cv(self): """Synchronize repository with SRPMs, add repository to content view and publish content view @id: 78cd6345-9c6c-490a-a44d-2ad64b7e959b @Assert: srpms can be listed in content view """ repo = make_repository({ 'product-id': self.product['id'], 'url': FAKE_YUM_SRPM_REPO, }) Repository.synchronize({'id': repo['id']}) cv = make_content_view({'organization-id': self.org['id']}) ContentView.add_repository({ 'id': cv['id'], 'repository-id': repo['id'], }) ContentView.publish({'id': cv['id']}) result = ssh.command( 'ls /var/lib/pulp/published/yum/https/repos/{}/content_views/{}' '/1.0/custom/{}/{}/ | grep .src.rpm'.format( self.org['label'], cv['label'], self.product['label'], repo['label'], )) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
def test_positive_sync_publish_cv(self): """Synchronize repository with DRPMs, add repository to content view and publish content view @id: 014bfc80-4622-422e-a0ec-755b1d9f845e @Assert: drpms can be listed in content view """ repo = make_repository({ 'product-id': self.product['id'], 'url': FAKE_YUM_DRPM_REPO, }) Repository.synchronize({'id': repo['id']}) cv = make_content_view({'organization-id': self.org['id']}) ContentView.add_repository({ 'id': cv['id'], 'repository-id': repo['id'], }) ContentView.publish({'id': cv['id']}) result = ssh.command( 'ls /var/lib/pulp/published/yum/https/repos/{}/content_views/{}' '/1.0/custom/{}/{}/drpms/ | grep .drpm'.format( self.org['label'], cv['label'], self.product['label'], repo['label'], )) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
def setup_content(request): """Pytest fixture for setting up an organization, manifest, content-view, lifecycle environment, and activation key with subscriptions""" org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) new_product = make_product({'organization-id': org['id']}) new_repo = make_repository({'product-id': new_product['id']}) Repository.synchronize({'id': new_repo['id']}) content_view = make_content_view({'organization-id': org['id']}) ContentView.add_repository( {'id': content_view['id'], 'organization-id': org['id'], 'repository-id': new_repo['id']} ) ContentView.publish({'id': content_view['id']}) env = make_lifecycle_environment({'organization-id': org['id']}) cvv = ContentView.info({'id': content_view['id']})['versions'][0] ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env['id']}) new_ak = make_activation_key( { 'lifecycle-environment-id': env['id'], 'content-view': content_view['name'], 'organization-id': org['id'], 'auto-attach': False, } ) subs_id = Subscription.list({'organization-id': org['id']}, per_page=False) ActivationKey.add_subscription({'id': new_ak['id'], 'subscription-id': subs_id[0]['id']}) request.cls.setup_org = org request.cls.setup_new_ak = new_ak request.cls.setup_subs_id = subs_id request.cls.setup_env = env request.cls.setup_content_view = content_view
def setUpClass(cls): """Create Directory for all CV Sync Tests in /tmp""" super(ContentViewSync, cls).setUpClass() cls.exporting_org = make_org() cls.exporting_prod = gen_string('alpha') product = make_product({ 'organization-id': cls.exporting_org['id'], 'name': cls.exporting_prod }) cls.exporting_repo = gen_string('alpha') repo = make_repository({ 'name': cls.exporting_repo, 'download-policy': 'immediate', 'product-id': product['id'] }) Repository.synchronize({'id': repo['id']}) cls.exporting_cv = gen_string('alpha') content_view = make_content_view({ 'name': cls.exporting_cv, 'organization-id': cls.exporting_org['id'] }) ContentView.add_repository({ 'id': content_view['id'], 'organization-id': cls.exporting_org['id'], 'repository-id': repo['id'] }) ContentView.publish({u'id': content_view['id']}) content_view = ContentView.info({u'id': content_view['id']}) cls.exporting_cvv_id = content_view['versions'][0]['id']
def test_positive_sync_publish_promote_cv(self): """Synchronize repository with DRPMs, add repository to content view, publish and promote content view to lifecycle environment @id: a01cb12b-d388-4902-8532-714f4e28ec56 @Assert: drpms can be listed in content view in proper lifecycle environment """ lce = make_lifecycle_environment({"organization-id": self.org["id"]}) repo = make_repository({"product-id": self.product["id"], "url": FAKE_YUM_DRPM_REPO}) Repository.synchronize({"id": repo["id"]}) cv = make_content_view({"organization-id": self.org["id"]}) ContentView.add_repository({"id": cv["id"], "repository-id": repo["id"]}) ContentView.publish({"id": cv["id"]}) content_view = ContentView.info({"id": cv["id"]}) cvv = content_view["versions"][0] ContentView.version_promote({"id": cvv["id"], "to-lifecycle-environment-id": lce["id"]}) result = ssh.command( "ls /var/lib/pulp/published/yum/https/repos/{}/{}/{}/custom/{}/{}" "/drpms/ | grep .drpm".format( self.org["label"], lce["label"], cv["label"], self.product["label"], repo["label"] ) ) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
def set_importing_org(self, product, repo, cv): """Sets same CV, product and repository in importing organization as exporting organization :param str product: The product name same as exporting product :param str repo: The repo name same as exporting repo :param str cv: The cv name same as exporting cv """ self.importing_org = make_org() importing_prod = make_product({ 'organization-id': self.importing_org['id'], 'name': product }) importing_repo = make_repository({ 'name': repo, 'download-policy': 'immediate', 'product-id': importing_prod['id'] }) self.importing_cv = make_content_view({ 'name': cv, 'organization-id': self.importing_org['id'] }) ContentView.add_repository({ 'id': self.importing_cv['id'], 'organization-id': self.importing_org['id'], 'repository-id': importing_repo['id'] })
def setUpClass(cls): """Create necessary objects which can be re-used in tests.""" super(DockerActivationKeyTestCase, cls).setUpClass() cls.org = make_org() cls.lce = make_lifecycle_environment({ 'organization-id': cls.org['id'], }) cls.product = make_product({ 'organization-id': cls.org['id'], }) cls.repo = _make_docker_repo(cls.product['id']) cls.content_view = make_content_view({ 'composite': False, 'organization-id': cls.org['id'], }) ContentView.add_repository({ 'id': cls.content_view['id'], 'repository-id': cls.repo['id'], }) cls.content_view = ContentView.info({ 'id': cls.content_view['id'] }) ContentView.publish({'id': cls.content_view['id']}) cls.content_view = ContentView.info({ 'id': cls.content_view['id']}) cls.cvv = ContentView.version_info({ 'id': cls.content_view['versions'][0]['id'], }) ContentView.version_promote({ 'id': cls.content_view['versions'][0]['id'], 'lifecycle-environment-id': cls.lce['id'], }) cls.cvv = ContentView.version_info({ 'id': cls.content_view['versions'][0]['id'], })
def add_to_content_view(self, organization_id, content_view_id): # type: (int, int) -> None """Associate repository content to content-view""" ContentView.add_repository({ 'id': content_view_id, 'organization-id': organization_id, 'repository-id': self._repo_info['id'], })
def add_to_content_view(self, organization_id, content_view_id): # type: (int, int) -> None """Associate repository content to content-view""" ContentView.add_repository({ 'id': content_view_id, 'organization-id': organization_id, 'repository-id': self._repo_info['id'], })
def setUpClass(cls): """Init single organization, product and repository for all tests""" super(TestContentViewFilter, cls).setUpClass() cls.org = make_org() cls.product = make_product({u"organization-id": cls.org["id"]}) cls.repo = make_repository({u"product-id": cls.product["id"]}) Repository.synchronize({u"id": cls.repo["id"]}) cls.content_view = make_content_view({u"organization-id": cls.org["id"]}) ContentView.add_repository({u"id": cls.content_view["id"], u"repository-id": cls.repo["id"]})
def test_positive_update_repo_with_same_type(self, module_org, module_product, sync_repo, content_view): """Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and change affected repository on another one. :id: b2f444fd-e65e-41ba-9941-620d3cdb260f :expectedresults: Content view filter updated successfully and has new repository affected :CaseLevel: Integration :CaseImportance: Critical """ cvf_name = gen_string('utf8') ContentView.filter.create( { 'content-view-id': content_view['id'], 'name': cvf_name, 'repository-ids': sync_repo['id'], 'type': 'rpm', }, ) cvf = ContentView.filter.info({ 'content-view-id': content_view['id'], 'name': cvf_name }) assert len(cvf['repositories']) == 1 assert cvf['repositories'][0]['name'] == sync_repo['name'] new_repo = make_repository( { 'organization-id': module_org.id, 'product-id': module_product.id }, ) ContentView.add_repository({ 'id': content_view['id'], 'repository-id': new_repo['id'] }) ContentView.filter.update({ 'content-view-id': content_view['id'], 'name': cvf_name, 'repository-ids': new_repo['id'], }) cvf = ContentView.filter.info({ 'content-view-id': content_view['id'], 'name': cvf_name }) assert len(cvf['repositories']) == 1 assert cvf['repositories'][0]['name'] != sync_repo['name'] assert cvf['repositories'][0]['name'] == new_repo['name']
def test_positive_update_repo_with_different_type(self): """Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and change affected repository on another one. That new repository should have another type from initial one (e.g. yum->docker) @id: cf3daa0d-e918-4330-95ad-f88933579829 @Assert: Content view filter updated successfully and has new repository affected @CaseLevel: Integration """ cvf_name = gen_string('utf8') ContentView.filter_create({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': self.repo['id'], 'type': 'rpm', }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertEqual(cvf['repositories'][0]['name'], self.repo['name']) docker_repo = make_repository({ u'content-type': u'docker', u'docker-upstream-name': u'busybox', u'product-id': self.product['id'], u'url': DOCKER_REGISTRY_HUB, }) ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': docker_repo['id'], }) ContentView.filter_update({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': docker_repo['id'], }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertNotEqual(cvf['repositories'][0]['name'], self.repo['name']) self.assertEqual(cvf['repositories'][0]['name'], docker_repo['name'])
def test_positive_update_repo_with_different_type(self, module_org, module_product, sync_repo, content_view): """Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and change affected repository on another one. That new repository should have another type from initial one (e.g. yum->docker) :id: cf3daa0d-e918-4330-95ad-f88933579829 :expectedresults: Content view filter updated successfully and has new repository affected :CaseLevel: Integration """ cvf_name = gen_string('utf8') ContentView.filter.create( { 'content-view-id': content_view['id'], 'name': cvf_name, 'repository-ids': sync_repo['id'], 'type': 'rpm', }, ) cvf = ContentView.filter.info({ 'content-view-id': content_view['id'], 'name': cvf_name }) assert len(cvf['repositories']) == 1 assert cvf['repositories'][0]['name'] == sync_repo['name'] docker_repo = make_repository( { 'content-type': 'docker', 'docker-upstream-name': 'busybox', 'organization-id': module_org.id, 'product-id': module_product.id, 'url': DOCKER_REGISTRY_HUB, }, ) ContentView.add_repository({ 'id': content_view['id'], 'repository-id': docker_repo['id'] }) ContentView.filter.update({ 'content-view-id': content_view['id'], 'name': cvf_name, 'repository-ids': docker_repo['id'], }) cvf = ContentView.filter.info({ 'content-view-id': content_view['id'], 'name': cvf_name }) assert len(cvf['repositories']) == 1 assert cvf['repositories'][0]['name'] != sync_repo['name'] assert cvf['repositories'][0]['name'] == docker_repo['name']
def local_content_view(local_org): """Create content view, repository, and product""" new_product = make_product({'organization-id': local_org['id']}) new_repo = make_repository({'product-id': new_product['id']}) Repository.synchronize({'id': new_repo['id']}) content_view = make_content_view({'organization-id': local_org['id']}) ContentView.add_repository({ 'id': content_view['id'], 'organization-id': local_org['id'], 'repository-id': new_repo['id'], }) ContentView.publish({'id': content_view['id']}) return content_view
def test_positive_update_repo_with_same_type(self): """Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and change affected repository on another one. :id: b2f444fd-e65e-41ba-9941-620d3cdb260f :expectedresults: Content view filter updated successfully and has new repository affected :CaseLevel: Integration :CaseImportance: Critical """ cvf_name = gen_string('utf8') ContentView.filter.create({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': self.repo['id'], 'type': 'rpm', }) cvf = ContentView.filter.info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertEqual(cvf['repositories'][0]['name'], self.repo['name']) new_repo = make_repository({u'product-id': self.product['id']}) ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': new_repo['id'], }) ContentView.filter.update({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': new_repo['id'], }) cvf = ContentView.filter.info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertNotEqual(cvf['repositories'][0]['name'], self.repo['name']) self.assertEqual(cvf['repositories'][0]['name'], new_repo['name'])
def setUpClass(cls): """Init single organization, product and repository for all tests""" super().setUpClass() cls.org = make_org() cls.product = make_product_wait({'organization-id': cls.org['id']}) cls.content_view = make_content_view( {'organization-id': cls.org['id']}) for _ in range(2): cls.repo = make_repository({'product-id': cls.product['id']}) Repository.synchronize({'id': cls.repo['id']}) ContentView.add_repository({ 'id': cls.content_view['id'], 'repository-id': cls.repo['id'] })
def setUpClass(cls): """Init single organization, product and repository for all tests""" super(ContentViewFilterTestCase, cls).setUpClass() cls.org = make_org() cls.product = make_product({u'organization-id': cls.org['id']}) cls.repo = make_repository({u'product-id': cls.product['id']}) Repository.synchronize({u'id': cls.repo['id']}) cls.content_view = make_content_view({ u'organization-id': cls.org['id'], }) ContentView.add_repository({ u'id': cls.content_view['id'], u'repository-id': cls.repo['id'], })
def setUpClass(cls): """Init single organization, product and repository for all tests""" super(ContentViewFilterTestCase, cls).setUpClass() cls.org = make_org() cls.product = make_product({u'organization-id': cls.org['id']}) cls.repo = make_repository({u'product-id': cls.product['id']}) Repository.synchronize({u'id': cls.repo['id']}) cls.content_view = make_content_view({ u'organization-id': cls.org['id'], }) ContentView.add_repository({ u'id': cls.content_view['id'], u'repository-id': cls.repo['id'], })
def test_positive_update_repo_with_different_type(self): """Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and change affected repository on another one. That new repository should have another type from initial one (e.g. yum->docker) @id: cf3daa0d-e918-4330-95ad-f88933579829 @Assert: Content view filter updated successfully and has new repository affected @CaseLevel: Integration """ cvf_name = gen_string('utf8') ContentView.filter_create({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': self.repo['id'], 'type': 'rpm', }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertEqual(cvf['repositories'][0]['name'], self.repo['name']) docker_repo = make_repository({ u'content-type': u'docker', u'docker-upstream-name': u'busybox', u'product-id': self.product['id'], u'url': DOCKER_REGISTRY_HUB, }) ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': docker_repo['id'], }) ContentView.filter_update({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': docker_repo['id'], }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertNotEqual(cvf['repositories'][0]['name'], self.repo['name']) self.assertEqual(cvf['repositories'][0]['name'], docker_repo['name'])
def test_positive_update_repo_with_same_type(self): """Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and change affected repository on another one. @Feature: Content View Filter @Assert: Content view filter updated successfully and has new repository affected """ cvf_name = gen_string('utf8') ContentView.filter_create({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': self.repo['id'], 'type': 'rpm', }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertEqual(cvf['repositories'][0]['name'], self.repo['name']) new_repo = make_repository({u'product-id': self.product['id']}) ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': new_repo['id'], }) ContentView.filter_update({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': new_repo['id'], }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertNotEqual(cvf['repositories'][0]['name'], self.repo['name']) self.assertEqual(cvf['repositories'][0]['name'], new_repo['name'])
def test_add_docker_repo_to_content_view(self): """@Test: Add one Docker-type repository to a non-composite content view @Assert: A repository is created with a Docker repository and the product is added to a non-composite content view @Feature: Docker """ repo = _make_docker_repo( make_product({'organization-id': self.org_id})['id']) content_view = make_content_view({ 'composite': False, 'organization-id': self.org_id, }) result = ContentView.add_repository({ 'id': content_view['id'], 'repository-id': repo['id'], }) self.assertEqual(result.return_code, 0) content_view = ContentView.info({'id': content_view['id']}).stdout self.assertIn( repo['id'], [repo_['id'] for repo_ in content_view['docker-repositories']], )
def test_add_multiple_docker_repos_to_composite_content_view(self): """@Test: Add multiple Docker-type repositories to a composite content view. @Assert: One repository is created with a Docker image and the product is added to a random number of content views which are then added to a composite content view. @Feature: Docker """ cv_versions = [] product = make_product({'organization-id': self.org_id}) for _ in range(randint(2, 5)): content_view = make_content_view({ 'composite': False, 'organization-id': self.org_id, }) repo = _make_docker_repo(product['id']) ContentView.add_repository({ 'id': content_view['id'], 'repository-id': repo['id'], }) ContentView.publish({'id': content_view['id']}) content_view = ContentView.info({'id': content_view['id']}) self.assertEqual(len(content_view['versions']), 1) cv_versions.append(content_view['versions'][0]) comp_content_view = make_content_view({ 'composite': True, 'organization-id': self.org_id, }) ContentView.update({ 'component-ids': [cv_version['id'] for cv_version in cv_versions], 'id': comp_content_view['id'], }) comp_content_view = ContentView.info({ 'id': comp_content_view['id'], }) for cv_version in cv_versions: self.assertIn( cv_version['id'], [ component['id'] for component in comp_content_view['components'] ], )
def test_positive_update_repo_with_same_type(self): """Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and change affected repository on another one. @id: b2f444fd-e65e-41ba-9941-620d3cdb260f @Assert: Content view filter updated successfully and has new repository affected @CaseLevel: Integration """ cvf_name = gen_string('utf8') ContentView.filter_create({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': self.repo['id'], 'type': 'rpm', }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertEqual(cvf['repositories'][0]['name'], self.repo['name']) new_repo = make_repository({u'product-id': self.product['id']}) ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': new_repo['id'], }) ContentView.filter_update({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': new_repo['id'], }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertNotEqual(cvf['repositories'][0]['name'], self.repo['name']) self.assertEqual(cvf['repositories'][0]['name'], new_repo['name'])
def test_positive_create_with_repos_yum_and_docker(self, module_org, module_product, sync_repo, content_view): """Create new docker repository and add to content view that has yum repo already assigned to it. Create new content view filter and assign it to mentioned content view. Use these repositories id for proper filter assignment. :id: 8419a5fa-0530-42a7-964c-7c513443c5c8 :expectedresults: Content view filter created successfully and has both repositories affected (yum and docker) """ docker_repository = make_repository( { 'content-type': 'docker', 'docker-upstream-name': 'busybox', 'organization-id': module_org.id, 'product-id': module_product.id, 'url': DOCKER_REGISTRY_HUB, }, ) ContentView.add_repository({ 'id': content_view['id'], 'repository-id': docker_repository['id'] }) repos = [sync_repo['id'], docker_repository['id']] cvf_name = gen_string('utf8') ContentView.filter.create( { 'content-view-id': content_view['id'], 'inclusion': 'true', 'name': cvf_name, 'repository-ids': repos, 'organization-id': module_org.id, 'type': 'rpm', }, ) cvf = ContentView.filter.info({ 'content-view-id': content_view['id'], 'name': cvf_name }) assert len(cvf['repositories']) == 2 for repo in cvf['repositories']: assert repo['id'] in repos
def test_update_cvf_repo(self): """Test: Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and change affected repository on another one. @Feature: Content View Filter @Assert: Content view filter updated successfully and has new repository affected """ cvf_name = gen_string('utf8') ContentView.filter_create({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': self.repo['id'], 'type': 'rpm', }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertEqual(cvf['repositories'][0]['name'], self.repo['name']) new_repo = make_repository({u'product-id': self.product['id']}) ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': new_repo['id'], }) ContentView.filter_update({ 'content-view-id': self.content_view['id'], 'name': cvf_name, 'repository-ids': new_repo['id'], }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 1) self.assertNotEqual(cvf['repositories'][0]['name'], self.repo['name']) self.assertEqual(cvf['repositories'][0]['name'], new_repo['name'])
def test_positive_create_with_repos_yum_and_docker(self): """Create new docker repository and add to content view that has yum repo already assigned to it. Create new content view filter and assign it to mentioned content view. Use these repositories id for proper filter assignment. :id: 8419a5fa-0530-42a7-964c-7c513443c5c8 :expectedresults: Content view filter created successfully and has both repositories affected (yum and docker) :CaseImportance: Critical """ docker_repository = make_repository({ u'content-type': u'docker', u'docker-upstream-name': u'busybox', u'product-id': self.product['id'], u'url': DOCKER_REGISTRY_HUB, }) ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': docker_repository['id'], }) repos = [self.repo['id'], docker_repository['id']] cvf_name = gen_string('utf8') ContentView.filter.create({ 'content-view-id': self.content_view['id'], 'inclusion': 'true', 'name': cvf_name, 'repository-ids': repos, 'organization-id': self.org['id'], 'type': 'rpm', }) cvf = ContentView.filter.info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 2) for repo in cvf['repositories']: self.assertIn(repo['id'], repos)
def test_positive_create_with_repos_yum_and_docker(self): """Create new docker repository and add to content view that has yum repo already assigned to it. Create new content view filter and assign it to mentioned content view. Use these repositories id for proper filter assignment. :id: 8419a5fa-0530-42a7-964c-7c513443c5c8 :expectedresults: Content view filter created successfully and has both repositories affected (yum and docker) :CaseImportance: Critical """ docker_repository = make_repository({ u'content-type': u'docker', u'docker-upstream-name': u'busybox', u'product-id': self.product['id'], u'url': DOCKER_REGISTRY_HUB, }) ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': docker_repository['id'], }) repos = [self.repo['id'], docker_repository['id']] cvf_name = gen_string('utf8') ContentView.filter.create({ 'content-view-id': self.content_view['id'], 'inclusion': 'true', 'name': cvf_name, 'repository-ids': repos, 'organization-id': self.org['id'], 'type': 'rpm', }) cvf = ContentView.filter.info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 2) for repo in cvf['repositories']: self.assertIn(repo['id'], repos)
def test_positive_sync_publish_cv(self): """Synchronize repository with DRPMs, add repository to content view and publish content view @id: 014bfc80-4622-422e-a0ec-755b1d9f845e @Assert: drpms can be listed in content view """ repo = make_repository({"product-id": self.product["id"], "url": FAKE_YUM_DRPM_REPO}) Repository.synchronize({"id": repo["id"]}) cv = make_content_view({"organization-id": self.org["id"]}) ContentView.add_repository({"id": cv["id"], "repository-id": repo["id"]}) ContentView.publish({"id": cv["id"]}) result = ssh.command( "ls /var/lib/pulp/published/yum/https/repos/{}/content_views/{}" "/1.0/custom/{}/{}/drpms/ | grep .drpm".format( self.org["label"], cv["label"], self.product["label"], repo["label"] ) ) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
def test_positive_sync_publish_cv(self): """Synchronize repository with SRPMs, add repository to content view and publish content view @id: 78cd6345-9c6c-490a-a44d-2ad64b7e959b @Assert: srpms can be listed in content view """ repo = make_repository({"product-id": self.product["id"], "url": FAKE_YUM_SRPM_REPO}) Repository.synchronize({"id": repo["id"]}) cv = make_content_view({"organization-id": self.org["id"]}) ContentView.add_repository({"id": cv["id"], "repository-id": repo["id"]}) ContentView.publish({"id": cv["id"]}) result = ssh.command( "ls /var/lib/pulp/published/yum/https/repos/{}/content_views/{}" "/1.0/custom/{}/{}/ | grep .src.rpm".format( self.org["label"], cv["label"], self.product["label"], repo["label"] ) ) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
def test_update_cvf_repo_type(self): """Test: Create new content view filter and apply it to existing content view that has repository assigned to it. Try to update that filter and change affected repository on another one. That new repository should have another type from initial one (e.g. yum->docker) @Feature: Content View Filter @Assert: Content view filter updated successfully and has new repository affected """ cvf_name = gen_string("utf8") ContentView.filter_create( { "content-view-id": self.content_view["id"], "name": cvf_name, "repository-ids": self.repo["id"], "type": "rpm", } ) cvf = ContentView.filter_info({u"content-view-id": self.content_view["id"], u"name": cvf_name}) self.assertEqual(len(cvf["repositories"]), 1) self.assertEqual(cvf["repositories"][0]["name"], self.repo["name"]) docker_repo = make_repository( { u"content-type": u"docker", u"docker-upstream-name": u"busybox", u"product-id": self.product["id"], u"url": DOCKER_REGISTRY_HUB, } ) ContentView.add_repository({u"id": self.content_view["id"], u"repository-id": docker_repo["id"]}) ContentView.filter_update( {"content-view-id": self.content_view["id"], "name": cvf_name, "repository-ids": docker_repo["id"]} ) cvf = ContentView.filter_info({u"content-view-id": self.content_view["id"], u"name": cvf_name}) self.assertEqual(len(cvf["repositories"]), 1) self.assertNotEqual(cvf["repositories"][0]["name"], self.repo["name"]) self.assertEqual(cvf["repositories"][0]["name"], docker_repo["name"])
def test_positive_create_with_repos_yum_and_docker(self): """Create new docker repository and add to content view that has yum repo already assigned to it. Create new content view filter and assign it to mentioned content view. Use these repositories id for proper filter assignment. @Feature: Content View Filter @Assert: Content view filter created successfully and has both repositories affected (yum and docker) """ docker_repository = make_repository({ u'content-type': u'docker', u'docker-upstream-name': u'busybox', u'product-id': self.product['id'], u'url': DOCKER_REGISTRY_HUB, }) ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': docker_repository['id'], }) repos = [self.repo['id'], docker_repository['id']] cvf_name = gen_string('utf8') ContentView.filter_create({ 'content-view-id': self.content_view['id'], 'inclusion': 'true', 'name': cvf_name, 'repository-ids': repos, 'type': 'rpm', }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 2) for repo in cvf['repositories']: self.assertIn(repo['id'], repos)
def test_positive_create_with_repos_yum_and_docker(self): """Test: Create new docker repository and add to content view that has yum repo already assigned to it. Create new content view filter and assign it to mentioned content view. Use these repositories id for proper filter assignment. @Feature: Content View Filter @Assert: Content view filter created successfully and has both repositories affected (yum and docker) """ docker_repository = make_repository({ u'content-type': u'docker', u'docker-upstream-name': u'busybox', u'product-id': self.product['id'], u'url': DOCKER_REGISTRY_HUB, }) ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': docker_repository['id'], }) repos = [self.repo['id'], docker_repository['id']] cvf_name = gen_string('utf8') ContentView.filter_create({ 'content-view-id': self.content_view['id'], 'inclusion': 'true', 'name': cvf_name, 'repository-ids': repos, 'type': 'rpm', }) cvf = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': cvf_name, }) self.assertEqual(len(cvf['repositories']), 2) for repo in cvf['repositories']: self.assertIn(repo['id'], repos)
def test_positive_sync_publish_promote_cv(self): """Synchronize repository with DRPMs, add repository to content view, publish and promote content view to lifecycle environment @id: a01cb12b-d388-4902-8532-714f4e28ec56 @Assert: drpms can be listed in content view in proper lifecycle environment """ lce = make_lifecycle_environment({'organization-id': self.org['id']}) repo = make_repository({ 'product-id': self.product['id'], 'url': FAKE_YUM_DRPM_REPO, }) Repository.synchronize({'id': repo['id']}) cv = make_content_view({'organization-id': self.org['id']}) ContentView.add_repository({ 'id': cv['id'], 'repository-id': repo['id'], }) ContentView.publish({'id': cv['id']}) content_view = ContentView.info({'id': cv['id']}) cvv = content_view['versions'][0] ContentView.version_promote({ 'id': cvv['id'], 'to-lifecycle-environment-id': lce['id'], }) result = ssh.command( 'ls /var/lib/pulp/published/yum/https/repos/{}/{}/{}/custom/{}/{}' '/drpms/ | grep .drpm'.format( self.org['label'], lce['label'], cv['label'], self.product['label'], repo['label'], )) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
def test_create_cvf_repos_docker(self): """Test: Create new docker repository and add to content view that has yum repo already assigned to it. Create new content view filter and assign it to mentioned content view. Use these repositories id for proper filter assignment. @Feature: Content View Filter @Assert: Content view filter created successfully and has both repositories affected (yum and docker) """ docker_repository = make_repository( { u"content-type": u"docker", u"docker-upstream-name": u"busybox", u"product-id": self.product["id"], u"url": DOCKER_REGISTRY_HUB, } ) ContentView.add_repository({u"id": self.content_view["id"], u"repository-id": docker_repository["id"]}) repos = [self.repo["id"], docker_repository["id"]] cvf_name = gen_string("utf8") ContentView.filter_create( { "content-view-id": self.content_view["id"], "inclusion": "true", "name": cvf_name, "repository-ids": repos, "type": "rpm", } ) cvf = ContentView.filter_info({u"content-view-id": self.content_view["id"], u"name": cvf_name}) self.assertEqual(len(cvf["repositories"]), 2) for repo in cvf["repositories"]: self.assertIn(repo["id"], repos)
def test_create_cvf_with_multiple_repo_with_docker(self): """Test: Create new docker repository and add to content view that has yum repo already assigned to it. Create new content view filter and assign it to mentioned content view. Use these repositories id for proper filter assignment. @Feature: Content View Filter @Assert: Content view filter created successfully and has both repositories affected (yum and docker) """ try: docker_repository = make_repository({ u'content-type': u'docker', u'docker-upstream-name': u'busybox', u'product-id': self.product['id'], u'url': DOCKER_REGISTRY_HUB, }) except CLIFactoryError as err: self.fail(err) result = ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': docker_repository['id'], }) self.assertEqual(result.return_code, 0) repos = '{0},{1}'.format(self.repo['id'], docker_repository['id']) result = ContentView.filter_create({ 'content-view-id': self.content_view['id'], 'type': 'rpm', 'inclusion': 'true', 'name': self.cvf_name, 'repository-ids': repos, }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) result = ContentView.filter_info({ u'content-view-id': self.content_view['id'], u'name': self.cvf_name }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stdout['repositories']), 2) for i in range(2): self.assertIn(result.stdout['repositories'][i]['id'], repos)
def setUp(self): """Init content view with repo per each test""" super(TestContentViewFilter, self).setUp() self.cvf_name = gen_string('utf8') try: self.content_view = make_content_view({ u'organization-id': self.org['id'], }) except CLIFactoryError as err: self.fail(err) result = ContentView.add_repository({ u'id': self.content_view['id'], u'repository-id': self.repo['id'], }) self.assertEqual(result.return_code, 0)
def test_add_docker_repo_to_composite_content_view(self): """@Test: Add one Docker-type repository to a composite content view @Assert: 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. @Feature: Docker """ repo = _make_docker_repo( make_product({'organization-id': self.org_id})['id']) content_view = make_content_view({ 'composite': False, 'organization-id': self.org_id, }) result = ContentView.add_repository({ 'id': content_view['id'], 'repository-id': repo['id'], }) self.assertEqual(result.return_code, 0) content_view = ContentView.info({'id': content_view['id']}).stdout self.assertIn( repo['id'], [repo_['id'] for repo_ in content_view['docker-repositories']], ) result = ContentView.publish({'id': content_view['id']}) self.assertEqual(result.return_code, 0) content_view = ContentView.info({'id': content_view['id']}).stdout self.assertEqual(len(content_view['versions']), 1) comp_content_view = make_content_view({ 'composite': True, 'organization-id': self.org_id, }) result = ContentView.update({ 'id': comp_content_view['id'], 'component-ids': content_view['versions'][0]['id'], }) self.assertEqual(result.return_code, 0) comp_content_view = ContentView.info({ 'id': comp_content_view['id'], }).stdout self.assertIn( content_view['versions'][0]['id'], [component['id'] for component in comp_content_view['components']], )
def test_end_to_end(self): """@Test: Perform end to end smoke tests using RH repos. 1. Create new organization and environment 2. Upload manifest 3. Sync a RedHat repository 4. Create content-view 5. Add repository to contet-view 6. Promote/publish content-view 7. Create an activation-key 8. Add product to activation-key 9. Create new virtualmachine 10. Pull rpm from Foreman server and install on client 11. Register client with foreman server using activation-key 12. Install rpm on client @Feature: Smoke test @Assert: All tests should succeed and Content should be successfully fetched by client """ # Product, RepoSet and repository variables rhel_product_name = PRDS['rhel'] rhel_repo_set = REPOSET['rhva6'] rhel_repo_name = REPOS['rhva6']['name'] org_name = random.choice(generate_strings_list()) # Create new org and environment new_org = make_org({u'name': org_name}) new_env = make_lifecycle_environment({ u'organization-id': new_org['id'], }) # Clone manifest and upload it manifest = manifests.clone() ssh.upload_file(manifest, remote_file=manifest) Subscription.upload({ u'file': manifest, u'organization-id': new_org['id'], }) # Enable repo from Repository Set RepositorySet.enable({ u'basearch': 'x86_64', u'name': rhel_repo_set, u'organization-id': new_org['id'], u'product': rhel_product_name, u'releasever': '6Server', }) # Fetch repository info rhel_repo = Repository.info({ u'name': rhel_repo_name, u'organization-id': new_org['id'], u'product': rhel_product_name, }) # Synchronize the repository Repository.synchronize({ u'name': rhel_repo_name, u'organization-id': new_org['id'], u'product': rhel_product_name, }) # Create CV and associate repo to it new_cv = make_content_view({u'organization-id': new_org['id']}) ContentView.add_repository({ u'id': new_cv['id'], u'organization-id': new_org['id'], u'repository-id': rhel_repo['id'], }) # Publish a version1 of CV ContentView.publish({u'id': new_cv['id']}) # Get the CV info version1_id = ContentView.info({ u'id': new_cv['id']})['versions'][0]['id'] # Store the version1 id # Promotion of version1 to next env ContentView.version_promote({ u'id': version1_id, u'to-lifecycle-environment-id': new_env['id'], }) # Create activation key activation_key = make_activation_key({ u'content-view': new_cv['name'], u'lifecycle-environment-id': new_env['id'], u'organization-id': new_org['id'], }) # List the subscriptions in given org result = Subscription.list( {u'organization-id': new_org['id']}, per_page=False ) # Get the subscription ID from subscriptions list for subscription in result: if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME: subscription_id = subscription['id'] subscription_quantity = int(subscription['quantity']) self.assertGreater(int(subscription_quantity), 0) # Add the subscriptions to activation-key ActivationKey.add_subscription({ u'id': activation_key['id'], u'quantity': 1, u'subscription-id': subscription_id, }) # Enable product content ActivationKey.content_override({ u'content-label': 'rhel-6-server-rhev-agent-rpms', u'id': activation_key['id'], u'organization-id': new_org['id'], u'value': '1', }) # Create VM package_name = "python-kitchen" server_name = conf.properties['main.server.hostname'] with VirtualMachine(distro='rhel66') as vm: # Download and Install rpm result = vm.run( "wget -nd -r -l1 --no-parent -A '*.noarch.rpm' http://{0}/pub/" .format(server_name) ) self.assertEqual(result.return_code, 0) result = vm.run( 'rpm -i katello-ca-consumer*.noarch.rpm' ) self.assertEqual(result.return_code, 0) # Register client with foreman server using activation-key result = vm.run( u'subscription-manager register --activationkey {0} ' '--org {1} --force' .format(activation_key['name'], new_org['label']) ) self.assertEqual(result.return_code, 0) # Install contents from sat6 server result = vm.run('yum install -y {0}'.format(package_name)) self.assertEqual(result.return_code, 0) # Verify if package is installed by query it result = vm.run('rpm -q {0}'.format(package_name)) self.assertEqual(result.return_code, 0)
def test_positive_show_count_on_chost_page(self): """Available errata count displayed in Content hosts page :id: 8575e282-d56e-41dc-80dd-f5f6224417cb :Setup: 1. Errata synced on satellite server. 2. Some content hosts are present. :Steps: Go to Hosts -> Content Hosts. :expectedresults: 1. The available errata count is displayed. 2. Errata count is displayed with color icons. - An errata count of 0 = black - If security errata, >0 = red - If any other errata, >0 = yellow :CaseLevel: System """ org = entities.Organization().create() env = entities.LifecycleEnvironment(organization=org).create() content_view = entities.ContentView(organization=org).create() activation_key = entities.ActivationKey( environment=env, organization=org, ).create() setup_org_for_a_rh_repo({ 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst6'], 'repository': REPOS['rhst6']['name'], 'organization-id': org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }) setup_org_for_a_custom_repo({ 'url': CUSTOM_REPO_URL, 'organization-id': org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }) RepositorySet.enable({ 'basearch': DEFAULT_ARCHITECTURE, 'name': REPOSET['rhva6'], 'organization-id': org.id, 'product': PRDS['rhel'], 'releasever': DEFAULT_RELEASE_VERSION, }) rhel_repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'organization-id': org.id, 'product': PRDS['rhel'], }) Repository.synchronize({ 'name': REPOS['rhva6']['name'], 'organization-id': org.id, 'product': PRDS['rhel'], }) ContentView.add_repository({ 'id': content_view.id, 'organization-id': org.id, 'repository-id': rhel_repo['id'], }) ContentView.publish({'id': content_view.id}) cvv = ContentView.info({'id': content_view.id})['versions'][-1] ContentView.version_promote({ 'id': cvv['id'], 'organization-id': org.id, 'to-lifecycle-environment-id': env.id, }) with VirtualMachine(distro=DISTRO_RHEL6) as client: client.install_katello_ca() result = client.register_contenthost( org.label, activation_key.name, ) self.assertEqual(result.return_code, 0) client.enable_repo(REPOS['rhst6']['id']) client.enable_repo(REPOS['rhva6']['id']) client.install_katello_agent() with Session(self.browser) as session: session.nav.go_to_select_org(org.name) result = self.contenthost.fetch_errata_counts(client.hostname) for errata in ('security', 'bug_fix', 'enhancement'): self.assertEqual(result[errata]['value'], 0) self.assertEqual(result[errata]['color'], 'black') client.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE)) result = self.contenthost.fetch_errata_counts(client.hostname) self.assertEqual(result['security']['value'], 1) self.assertEqual(result['security']['color'], 'red') client.run('yum install -y {0}'.format(REAL_0_RH_PACKAGE)) result = self.contenthost.fetch_errata_counts(client.hostname) for errata in ('bug_fix', 'enhancement'): self.assertEqual(result[errata]['value'], 1) self.assertEqual(result[errata]['color'], 'yellow')
def test_cv_postupgrade_scenario(self): """This is post-upgrade scenario test to verify if we can update content-view created in pre-upgrade scenario with various repositories. :id: a4ebbfa1-106a-4962-9c7c-082833879ae8 :steps: 1. Remove yum repository which was added to content-view before upgrade. 2. Create new yum repository and add it to content-view. 3. Remove puppet module which was added to content-view before upgrade. 4. Add another puppet module to content-view 5. Publish content-view :expectedresults: content-view updated with various repositories. """ product_id = Repository.info({ 'name': self.yum_repo1_name, 'organization': self.org_name, 'product': self.product_name })['product']['id'] ContentView.remove_repository({ 'organization': self.org_name, 'name': self.cv_name, 'repository': self.yum_repo1_name }) content_view = ContentView.info({'name': self.cv_name, 'organization': self.org_name}) self.assertNotIn(self.yum_repo1_name, content_view['yum-repositories']) yum_repo2 = make_repository({ 'name': self.yum_repo2_name, 'organization': self.org_name, 'content-type': 'yum', 'product-id': product_id, 'url': FAKE_2_YUM_REPO}) Repository.synchronize({'id': yum_repo2['id'], 'organization': self.org_name}) ContentView.add_repository({ 'name': self.cv_name, 'organization': self.org_name, 'product': self.product_name, 'repository-id': yum_repo2['id']}) content_view = ContentView.info({'name': self.cv_name, 'organization': self.org_name}) self.assertEqual( content_view['yum-repositories'][0]['name'], self.yum_repo2_name, 'Repo was not associated to CV', ) ContentView.puppet_module_remove({ 'organization': self.org_name, 'content-view': self.cv_name, 'name': self.puppet_module_name, 'author': self.puppet_module_author, }) content_view = ContentView.info({'name': self.cv_name, 'organization': self.org_name}) self.assertEqual(len(content_view['puppet-modules']), 0) module = {'name': 'versioned', 'version': '2.2.2'} puppet_module = PuppetModule.list({ 'search': 'name={name} and version={version}'.format(**module)})[0] ContentView.puppet_module_add({ 'organization': self.org_name, 'content-view': self.cv_name, 'name': puppet_module['name'], 'author': puppet_module['author'], }) content_view = ContentView.info({'id': content_view['id']}) self.assertGreater(len(content_view['puppet-modules']), 0) ContentView.publish({'name': self.cv_name, 'organization': self.org_name}) content_view = ContentView.info({'name': self.cv_name, 'organization': self.org_name}) self.assertEqual(len(content_view['versions']), 2)
def test_cv_postupgrade_scenario(self): """This is post-upgrade scenario test to verify if we can update content-view created in pre-upgrade scenario with various repositories. :id: a4ebbfa1-106a-4962-9c7c-082833879ae8 :steps: 1. Remove yum repository which was added to content-view before upgrade. 2. Create new yum repository and add it to content-view. 3. Remove puppet module which was added to content-view before upgrade. 4. Add another puppet module to content-view 5. Publish content-view :expectedresults: content-view updated with various repositories. """ product_id = Repository.info({ 'name': self.yum_repo1_name, 'organization': self.org_name, 'product': self.product_name })['product']['id'] ContentView.remove_repository({ 'organization': self.org_name, 'name': self.cv_name, 'repository': self.yum_repo1_name }) content_view = ContentView.info({ 'name': self.cv_name, 'organization': self.org_name }) self.assertNotIn(self.yum_repo1_name, content_view['yum-repositories']) yum_repo2 = make_repository({ 'name': self.yum_repo2_name, 'organization': self.org_name, 'content-type': 'yum', 'product-id': product_id, 'url': FAKE_2_YUM_REPO }) Repository.synchronize({ 'id': yum_repo2['id'], 'organization': self.org_name }) ContentView.add_repository({ 'name': self.cv_name, 'organization': self.org_name, 'product': self.product_name, 'repository-id': yum_repo2['id'] }) content_view = ContentView.info({ 'name': self.cv_name, 'organization': self.org_name }) self.assertEqual( content_view['yum-repositories'][0]['name'], self.yum_repo2_name, 'Repo was not associated to CV', ) ContentView.puppet_module_remove({ 'organization': self.org_name, 'content-view': self.cv_name, 'name': self.puppet_module_name, 'author': self.puppet_module_author, }) content_view = ContentView.info({ 'name': self.cv_name, 'organization': self.org_name }) self.assertEqual(len(content_view['puppet-modules']), 0) module = {'name': 'versioned', 'version': '2.2.2'} puppet_module = PuppetModule.list( {'search': 'name={name} and version={version}'.format(**module)})[0] ContentView.puppet_module_add({ 'organization': self.org_name, 'content-view': self.cv_name, 'name': puppet_module['name'], 'author': puppet_module['author'], }) content_view = ContentView.info({'id': content_view['id']}) self.assertGreater(len(content_view['puppet-modules']), 0) ContentView.publish({ 'name': self.cv_name, 'organization': self.org_name }) content_view = ContentView.info({ 'name': self.cv_name, 'organization': self.org_name }) self.assertEqual(len(content_view['versions']), 2)
def test_positive_end_to_end(self): """Perform end to end smoke tests using RH and custom repos. 1. Create a new user with admin permissions 2. Using the new user from above 1. Create a new organization 2. Clone and upload manifest 3. Create a new lifecycle environment 4. Create a custom product 5. Create a custom YUM repository 6. Create a custom PUPPET repository 7. Enable a Red Hat repository 8. Synchronize the three repositories 9. Create a new content view 10. Associate the YUM and Red Hat repositories to new content view 11. Add a PUPPET module to new content view 12. Publish content view 13. Promote content view to the lifecycle environment 14. Create a new activation key 15. Add the products to the activation key 16. Create a new libvirt compute resource 17. Create a new subnet 18. Create a new domain 19. Create a new hostgroup and associate previous entities to it 20. Provision a client @id: 8c8b3ffa-0d54-436b-8eeb-1a3542e100a8 @Assert: All tests should succeed and Content should be successfully fetched by client. """ # step 1: Create a new user with admin permissions password = gen_alphanumeric() user = make_user({u'admin': u'true', u'password': password}) user['password'] = password # step 2.1: Create a new organization org = self._create(user, Org, {u'name': gen_alphanumeric()}) # step 2.2: Clone and upload manifest if self.fake_manifest_is_set: with manifests.clone() as manifest: ssh.upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) # step 2.3: Create a new lifecycle environment lifecycle_environment = self._create( user, LifecycleEnvironment, { u'name': gen_alphanumeric(), u'organization-id': org['id'], u'prior': u'Library', }) # step 2.4: Create a custom product product = self._create(user, Product, { u'name': gen_alphanumeric(), u'organization-id': org['id'], }) repositories = [] # step 2.5: Create custom YUM repository yum_repo = self._create( user, Repository, { u'content-type': u'yum', u'name': gen_alphanumeric(), u'product-id': product['id'], u'publish-via-http': u'true', u'url': GOOGLE_CHROME_REPO, }) repositories.append(yum_repo) # step 2.6: Create custom PUPPET repository puppet_repo = self._create( user, Repository, { u'content-type': u'puppet', u'name': gen_alphanumeric(), u'product-id': product['id'], u'publish-via-http': u'true', u'url': FAKE_0_PUPPET_REPO, }) repositories.append(puppet_repo) # step 2.7: Enable a Red Hat repository if self.fake_manifest_is_set: RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization-id': org['id'], u'product': PRDS['rhel'], u'releasever': '6Server', }) rhel_repo = Repository.info({ u'name': REPOS['rhva6']['name'], u'organization-id': org['id'], u'product': PRDS['rhel'], }) repositories.append(rhel_repo) # step 2.8: Synchronize the three repositories for repo in repositories: Repository.with_user(user['login'], user['password']).synchronize( {u'id': repo['id']}) # step 2.9: Create content view content_view = self._create(user, ContentView, { u'name': gen_alphanumeric(), u'organization-id': org['id'], }) # step 2.10: Associate the YUM and Red Hat repositories to new content # view repositories.remove(puppet_repo) for repo in repositories: ContentView.add_repository({ u'id': content_view['id'], u'organization-id': org['id'], u'repository-id': repo['id'], }) # step 2.11: Add a PUPPET module to new content view result = PuppetModule.with_user(user['login'], user['password']).list({ u'repository-id': puppet_repo['id'], u'per-page': False, }) ContentView.with_user(user['login'], user['password']).puppet_module_add({ u'content-view-id': content_view['id'], u'id': random.choice(result)['id'], }) # step 2.12: Publish content view ContentView.with_user(user['login'], user['password']).publish( {u'id': content_view['id']}) # step 2.13: Promote content view to the lifecycle environment content_view = ContentView.with_user( user['login'], user['password']).info({u'id': content_view['id']}) self.assertEqual(len(content_view['versions']), 1) cv_version = ContentView.with_user( user['login'], user['password']).version_info({ 'id': content_view['versions'][0]['id'], }) self.assertEqual(len(cv_version['lifecycle-environments']), 1) ContentView.with_user(user['login'], user['password']).version_promote({ u'id': cv_version['id'], u'to-lifecycle-environment-id': lifecycle_environment['id'], }) # check that content view exists in lifecycle content_view = ContentView.with_user( user['login'], user['password']).info({u'id': content_view['id']}) self.assertEqual(len(content_view['versions']), 1) cv_version = ContentView.with_user( user['login'], user['password']).version_info({ 'id': content_view['versions'][0]['id'], }) self.assertEqual(len(cv_version['lifecycle-environments']), 2) self.assertEqual(cv_version['lifecycle-environments'][-1]['id'], lifecycle_environment['id']) # step 2.14: Create a new activation key activation_key = self._create( user, ActivationKey, { u'content-view-id': content_view['id'], u'lifecycle-environment-id': lifecycle_environment['id'], u'name': gen_alphanumeric(), u'organization-id': org['id'], }) # step 2.15: Add the products to the activation key subscription_list = Subscription.with_user( user['login'], user['password']).list({u'organization-id': org['id']}, per_page=False) for subscription in subscription_list: if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME: ActivationKey.with_user(user['login'], user['password']).add_subscription({ u'id': activation_key['id'], u'quantity': 1, u'subscription-id': subscription['id'], }) # step 2.15.1: Enable product content if self.fake_manifest_is_set: ActivationKey.with_user(user['login'], user['password']).content_override({ u'content-label': AK_CONTENT_LABEL, u'id': activation_key['id'], u'organization-id': org['id'], u'value': '1', }) # BONUS: Create a content host and associate it with promoted # content view and last lifecycle where it exists content_host_name = gen_alphanumeric() content_host = Host.with_user(user['login'], user['password']).subscription_register({ u'content-view-id': content_view['id'], u'lifecycle-environment-id': lifecycle_environment['id'], u'name': content_host_name, u'organization-id': org['id'], }) if bz_bug_is_open(1328202): results = ContentHost.with_user(user['login'], user['password']).list( {'organization-id': org['id']}) # Content host registration converts the name to lowercase, make # sure to use the same format while matching against the result content_host_name = content_host_name.lower() for result in results: if result['name'] == content_host_name: content_host = result content_host = ContentHost.with_user( user['login'], user['password']).info({'id': content_host['id']}) # check that content view matches what we passed self.assertEqual(content_host['content-view'], content_view['name']) # check that lifecycle environment matches self.assertEqual(content_host['lifecycle-environment'], lifecycle_environment['name']) # step 2.16: Create a new libvirt compute resource self._create( user, ComputeResource, { u'name': gen_alphanumeric(), u'provider': u'Libvirt', u'url': u'qemu+ssh://root@{0}/system'.format( settings.compute_resources.libvirt_hostname), }) # step 2.17: Create a new subnet subnet = self._create( user, Subnet, { u'name': gen_alphanumeric(), u'network': gen_ipaddr(ip3=True), u'mask': u'255.255.255.0', }) # step 2.18: Create a new domain domain = self._create(user, Domain, {u'name': gen_alphanumeric()}) # step 2.19: Create a new hostgroup and associate previous entities to # it host_group = self._create( user, HostGroup, { u'domain-id': domain['id'], u'name': gen_alphanumeric(), u'subnet-id': subnet['id'], }) if not bz_bug_is_open('1326101'): Org.with_user(user['login'], user['password']).add_hostgroup({ u'hostgroup-id': host_group['id'], u'id': org['id'], }) # step 2.20: Provision a client self.client_provisioning(activation_key['name'], org['label'])
def setUpClass(cls): """Setup must ensure there is an Org with Golden Ticket enabled. Option 1) SQL:: UPDATE cp_owner SET content_access_mode = 'org_environment', content_access_mode_list='entitlement,org_environment' WHERE account='{org.label}'; Option 2) manifest:: Change manifest file as it looks like: Consumer: Name: ExampleCorp UUID: c319a1d8-4b30-44cd-b2cf-2ccba4b9a8db Content Access Mode: org_environment Type: satellite :steps: 1. Create a new organization. 2. Use either option 1 or option 2 (described above) to activate the Golden Ticket. 3. Create a Product and CV for org. 4. Add a repository pointing to a real repo which requires a RedHat subscription to access. 5. Create Content Host and assign that gated repos to it. 6. Sync the gated repository. """ super(ContentAccessTestCase, cls).setUpClass() # Create Organization cls.org = make_org() # upload organization manifest with org environment access enabled cls.manifest = manifests.clone(org_environment_access=True) manifests.upload_manifest_locked(cls.org['id'], cls.manifest, interface=manifests.INTERFACE_CLI) # Create repositories cls.repos = [ # Red Hat Enterprise Linux 7 { 'product': PRDS['rhel'], 'repository-set': REPOSET['rhel7'], 'repository': REPOS['rhel7']['name'], 'repository-id': REPOS['rhel7']['id'], 'releasever': REPOS['rhel7']['releasever'], 'arch': REPOS['rhel7']['arch'], 'cdn': True, }, # Red Hat Satellite Tools { 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], 'repository': REPOS['rhst7']['name'], 'repository-id': REPOS['rhst7']['id'], 'url': settings.sattools_repo['rhel7'], 'cdn': bool(settings.cdn or not settings.sattools_repo['rhel7']), }, ] cls.custom_product, cls.repos_info = setup_cdn_and_custom_repositories( cls.org['id'], cls.repos) # Create a content view content_view = make_content_view({u'organization-id': cls.org['id']}) # Add repositories to content view for repo_info in cls.repos_info: ContentView.add_repository({ u'id': content_view['id'], u'organization-id': cls.org['id'], u'repository-id': repo_info['id'], }) # Publish the content view ContentView.publish({u'id': content_view['id']}) cls.content_view = ContentView.info({u'id': content_view['id']})
def test_positive_show_count_on_chost_details_page(self): """Errata count on Content host Details page @id: 388229da-2b0b-41aa-a457-9b5ecbf3df4b @Setup: 1. Errata synced on satellite server. 2. Some content hosts are present. @Steps: 1. Go to Hosts -> Content Hosts -> Select Content Host -> Details page. @Assert: 1. The errata section should be displayed with Security, Bugfix, Enhancement types. 2. The number should link to the errata details page, filtered by type. @CaseLevel: System """ org = entities.Organization().create() env = entities.LifecycleEnvironment(organization=org).create() content_view = entities.ContentView(organization=org).create() activation_key = entities.ActivationKey( environment=env, organization=org, ).create() setup_org_for_a_rh_repo({ 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst6'], 'repository': REPOS['rhst6']['name'], 'organization-id': org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }) setup_org_for_a_custom_repo({ 'url': CUSTOM_REPO_URL, 'organization-id': org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }) RepositorySet.enable({ 'basearch': DEFAULT_ARCHITECTURE, 'name': REPOSET['rhva6'], 'organization-id': org.id, 'product': PRDS['rhel'], 'releasever': DEFAULT_RELEASE_VERSION, }) rhel_repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'organization-id': org.id, 'product': PRDS['rhel'], }) Repository.synchronize({ 'name': REPOS['rhva6']['name'], 'organization-id': org.id, 'product': PRDS['rhel'], }) ContentView.add_repository({ 'id': content_view.id, 'organization-id': org.id, 'repository-id': rhel_repo['id'], }) ContentView.publish({'id': content_view.id}) cvv = ContentView.info({'id': content_view.id})['versions'][-1] ContentView.version_promote({ 'id': cvv['id'], 'organization-id': org.id, 'to-lifecycle-environment-id': env.id, }) with VirtualMachine(distro='rhel67') as client: client.install_katello_ca() result = client.register_contenthost( org.label, activation_key.name, ) self.assertEqual(result.return_code, 0) client.enable_repo(REPOS['rhst6']['id']) client.enable_repo(REPOS['rhva6']['id']) client.install_katello_agent() with Session(self.browser) as session: session.nav.go_to_select_org(org.name) result = self.contenthost.fetch_errata_counts( client.hostname, details_page=True) for errata in ('security', 'bug_fix', 'enhancement'): self.assertEqual(result[errata]['value'], 0) self.assertEqual(result[errata]['color'], 'black') client.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE)) result = self.contenthost.fetch_errata_counts( client.hostname, details_page=True) self.assertEqual(result['security']['value'], 1) self.assertEqual(result['security']['color'], 'red') client.run('yum install -y {0}'.format(REAL_0_RH_PACKAGE)) result = self.contenthost.fetch_errata_counts( client.hostname, details_page=True) for errata in ('bug_fix', 'enhancement'): self.assertEqual(result[errata]['value'], 1) self.assertEqual(result[errata]['color'], 'yellow')
def test_positive_end_to_end(self): """Perform end to end smoke tests using RH and custom repos. 1. Create a new user with admin permissions 2. Using the new user from above 1. Create a new organization 2. Clone and upload manifest 3. Create a new lifecycle environment 4. Create a custom product 5. Create a custom YUM repository 6. Create a custom PUPPET repository 7. Enable a Red Hat repository 8. Synchronize the three repositories 9. Create a new content view 10. Associate the YUM and Red Hat repositories to new content view 11. Add a PUPPET module to new content view 12. Publish content view 13. Promote content view to the lifecycle environment 14. Create a new activation key 15. Add the products to the activation key 16. Create a new libvirt compute resource 17. Create a new subnet 18. Create a new domain 19. Create a new hostgroup and associate previous entities to it 20. Provision a client @id: 8c8b3ffa-0d54-436b-8eeb-1a3542e100a8 @Assert: All tests should succeed and Content should be successfully fetched by client. """ # step 1: Create a new user with admin permissions password = gen_alphanumeric() user = make_user({u'admin': u'true', u'password': password}) user['password'] = password # step 2.1: Create a new organization org = self._create(user, Org, {u'name': gen_alphanumeric()}) # step 2.2: Clone and upload manifest if self.fake_manifest_is_set: with manifests.clone() as manifest: ssh.upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) # step 2.3: Create a new lifecycle environment lifecycle_environment = self._create( user, LifecycleEnvironment, { u'name': gen_alphanumeric(), u'organization-id': org['id'], u'prior': u'Library', } ) # step 2.4: Create a custom product product = self._create( user, Product, { u'name': gen_alphanumeric(), u'organization-id': org['id'], } ) repositories = [] # step 2.5: Create custom YUM repository yum_repo = self._create( user, Repository, { u'content-type': u'yum', u'name': gen_alphanumeric(), u'product-id': product['id'], u'publish-via-http': u'true', u'url': GOOGLE_CHROME_REPO, } ) repositories.append(yum_repo) # step 2.6: Create custom PUPPET repository puppet_repo = self._create( user, Repository, { u'content-type': u'puppet', u'name': gen_alphanumeric(), u'product-id': product['id'], u'publish-via-http': u'true', u'url': FAKE_0_PUPPET_REPO, } ) repositories.append(puppet_repo) # step 2.7: Enable a Red Hat repository if self.fake_manifest_is_set: RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization-id': org['id'], u'product': PRDS['rhel'], u'releasever': '6Server', }) rhel_repo = Repository.info({ u'name': REPOS['rhva6']['name'], u'organization-id': org['id'], u'product': PRDS['rhel'], }) repositories.append(rhel_repo) # step 2.8: Synchronize the three repositories for repo in repositories: Repository.with_user( user['login'], user['password'] ).synchronize({u'id': repo['id']}) # step 2.9: Create content view content_view = self._create( user, ContentView, { u'name': gen_alphanumeric(), u'organization-id': org['id'], } ) # step 2.10: Associate the YUM and Red Hat repositories to new content # view repositories.remove(puppet_repo) for repo in repositories: ContentView.add_repository({ u'id': content_view['id'], u'organization-id': org['id'], u'repository-id': repo['id'], }) # step 2.11: Add a PUPPET module to new content view result = PuppetModule.with_user( user['login'], user['password'] ).list({ u'repository-id': puppet_repo['id'], u'per-page': False, }) ContentView.with_user( user['login'], user['password'] ).puppet_module_add({ u'content-view-id': content_view['id'], u'id': random.choice(result)['id'], }) # step 2.12: Publish content view ContentView.with_user( user['login'], user['password'] ).publish({u'id': content_view['id']}) # step 2.13: Promote content view to the lifecycle environment content_view = ContentView.with_user( user['login'], user['password'] ).info({u'id': content_view['id']}) self.assertEqual(len(content_view['versions']), 1) cv_version = ContentView.with_user( user['login'], user['password'] ).version_info({ 'id': content_view['versions'][0]['id'], }) self.assertEqual(len(cv_version['lifecycle-environments']), 1) ContentView.with_user( user['login'], user['password'] ).version_promote({ u'id': cv_version['id'], u'to-lifecycle-environment-id': lifecycle_environment['id'], }) # check that content view exists in lifecycle content_view = ContentView.with_user( user['login'], user['password'] ).info({u'id': content_view['id']}) self.assertEqual(len(content_view['versions']), 1) cv_version = ContentView.with_user( user['login'], user['password'] ).version_info({ 'id': content_view['versions'][0]['id'], }) self.assertEqual(len(cv_version['lifecycle-environments']), 2) self.assertEqual( cv_version['lifecycle-environments'][-1]['id'], lifecycle_environment['id'] ) # step 2.14: Create a new activation key activation_key = self._create( user, ActivationKey, { u'content-view-id': content_view['id'], u'lifecycle-environment-id': lifecycle_environment['id'], u'name': gen_alphanumeric(), u'organization-id': org['id'], } ) # step 2.15: Add the products to the activation key subscription_list = Subscription.with_user( user['login'], user['password'] ).list( {u'organization-id': org['id']}, per_page=False ) for subscription in subscription_list: if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME: ActivationKey.with_user( user['login'], user['password'] ).add_subscription({ u'id': activation_key['id'], u'quantity': 1, u'subscription-id': subscription['id'], }) # step 2.15.1: Enable product content if self.fake_manifest_is_set: ActivationKey.with_user( user['login'], user['password'] ).content_override({ u'content-label': AK_CONTENT_LABEL, u'id': activation_key['id'], u'organization-id': org['id'], u'value': '1', }) # BONUS: Create a content host and associate it with promoted # content view and last lifecycle where it exists content_host_name = gen_alphanumeric() content_host = Host.with_user( user['login'], user['password'] ).subscription_register({ u'content-view-id': content_view['id'], u'lifecycle-environment-id': lifecycle_environment['id'], u'name': content_host_name, u'organization-id': org['id'], }) if bz_bug_is_open(1328202): results = ContentHost.with_user( user['login'], user['password'] ).list({ 'organization-id': org['id'] }) # Content host registration converts the name to lowercase, make # sure to use the same format while matching against the result content_host_name = content_host_name.lower() for result in results: if result['name'] == content_host_name: content_host = result content_host = ContentHost.with_user( user['login'], user['password'] ).info({'id': content_host['id']}) # check that content view matches what we passed self.assertEqual( content_host['content-view'], content_view['name'] ) # check that lifecycle environment matches self.assertEqual( content_host['lifecycle-environment'], lifecycle_environment['name'] ) # step 2.16: Create a new libvirt compute resource self._create( user, ComputeResource, { u'name': gen_alphanumeric(), u'provider': u'Libvirt', u'url': u'qemu+ssh://root@{0}/system'.format( settings.compute_resources.libvirt_hostname ), } ) # step 2.17: Create a new subnet subnet = self._create( user, Subnet, { u'name': gen_alphanumeric(), u'network': gen_ipaddr(ip3=True), u'mask': u'255.255.255.0', } ) # step 2.18: Create a new domain domain = self._create(user, Domain, {u'name': gen_alphanumeric()}) # step 2.19: Create a new hostgroup and associate previous entities to # it host_group = self._create( user, HostGroup, { u'domain-id': domain['id'], u'name': gen_alphanumeric(), u'subnet-id': subnet['id'], } ) if not bz_bug_is_open('1326101'): Org.with_user( user['login'], user['password'] ).add_hostgroup({ u'hostgroup-id': host_group['id'], u'id': org['id'], }) # step 2.20: Provision a client self.client_provisioning(activation_key['name'], org['label'])
def _make_public_key(self): """Perform all the steps needed to populate an Activation Key""" if TestActivationKey.pub_key is None: TestActivationKey.pub_key = {} try: organization_id = make_org()['id'] TestActivationKey.pub_key['org_id'] = organization_id TestActivationKey.pub_key['prod_id'] = make_product({ 'organization-id': organization_id, })['id'] TestActivationKey.pub_key['manifest'] = manifests.clone() upload_file(TestActivationKey.pub_key['manifest']) Subscription.upload({ 'file': TestActivationKey.pub_key['manifest'], 'organization-id': TestActivationKey.pub_key['org_id'], }) # create content view TestActivationKey.pub_key['content_view_id'] = ( make_content_view({ u'organization-id': ( TestActivationKey.pub_key['org_id']), u'name': gen_string('alpha'), })['id'] ) TestActivationKey.pub_key['repo_id'] = make_repository({ u'product-id': TestActivationKey.pub_key['prod_id'], })['id'] Repository.synchronize({ 'id': TestActivationKey.pub_key['repo_id'], 'organization-id': TestActivationKey.pub_key['org_id'], }) ContentView.add_repository({ u'id': TestActivationKey.pub_key['content_view_id'], u'repository-id': TestActivationKey.pub_key['repo_id'], }) ContentView.publish({ u'id': TestActivationKey.pub_key['content_view_id'], }) TestActivationKey.pub_key['key_id'] = make_activation_key({ u'organization-id': TestActivationKey.pub_key['org_id'] })['id'] subscription_result = Subscription.list({ 'organization-id': TestActivationKey.pub_key['org_id'], 'order': 'id desc' }, per_page=False) ActivationKey.add_subscription({ u'id': TestActivationKey.pub_key['key_id'], u'subscription-id': subscription_result[-1]['id'], }) except CLIFactoryError as err: TestActivationKey.pub_key = None self.fail(err)
def test_positive_cli_end_to_end(fake_manifest_is_set, rhel6_contenthost, default_sat): """Perform end to end smoke tests using RH and custom repos. 1. Create a new user with admin permissions 2. Using the new user from above 1. Create a new organization 2. Clone and upload manifest 3. Create a new lifecycle environment 4. Create a custom product 5. Create a custom YUM repository 6. Enable a Red Hat repository 7. Synchronize the three repositories 8. Create a new content view 9. Associate the YUM and Red Hat repositories to new content view 10. Publish content view 11. Promote content view to the lifecycle environment 12. Create a new activation key 13. Add the products to the activation key 14. Create a new libvirt compute resource 15. Create a new subnet 16. Create a new domain 17. Create a new hostgroup and associate previous entities to it 18. Provision a client ** NOT CURRENTLY PROVISIONING :id: 8c8b3ffa-0d54-436b-8eeb-1a3542e100a8 :expectedresults: All tests should succeed and Content should be successfully fetched by client. """ # step 1: Create a new user with admin permissions password = gen_alphanumeric() user = make_user({'admin': 'true', 'password': password}) user['password'] = password # step 2.1: Create a new organization org = _create(user, Org, {'name': gen_alphanumeric()}) # step 2.2: Clone and upload manifest if fake_manifest_is_set: with manifests.clone() as manifest: default_sat.put(manifest, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'] }) # step 2.3: Create a new lifecycle environment lifecycle_environment = _create( user, LifecycleEnvironment, { 'name': gen_alphanumeric(), 'organization-id': org['id'], 'prior': 'Library' }, ) # step 2.4: Create a custom product product = _create(user, Product, { 'name': gen_alphanumeric(), 'organization-id': org['id'] }) repositories = [] # step 2.5: Create custom YUM repository yum_repo = _create( user, Repository, { 'content-type': 'yum', 'name': gen_alphanumeric(), 'product-id': product['id'], 'publish-via-http': 'true', 'url': CUSTOM_RPM_REPO, }, ) repositories.append(yum_repo) # step 2.6: Enable a Red Hat repository if fake_manifest_is_set: RepositorySet.enable({ 'basearch': 'x86_64', 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', }) rhel_repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'organization-id': org['id'], 'product': PRDS['rhel'], }) repositories.append(rhel_repo) # step 2.7: Synchronize the three repositories for repo in repositories: Repository.with_user(user['login'], user['password']).synchronize({'id': repo['id']}) # step 2.8: Create content view content_view = _create(user, ContentView, { 'name': gen_alphanumeric(), 'organization-id': org['id'] }) # step 2.9: Associate the YUM and Red Hat repositories to new content view for repo in repositories: ContentView.add_repository({ 'id': content_view['id'], 'organization-id': org['id'], 'repository-id': repo['id'], }) # step 2.10: Publish content view ContentView.with_user(user['login'], user['password']).publish({'id': content_view['id']}) # step 2.11: Promote content view to the lifecycle environment content_view = ContentView.with_user(user['login'], user['password']).info( {'id': content_view['id']}) assert len(content_view['versions']) == 1 cv_version = ContentView.with_user(user['login'], user['password']).version_info({ 'id': content_view['versions'][0]['id'] }) assert len(cv_version['lifecycle-environments']) == 1 ContentView.with_user(user['login'], user['password']).version_promote({ 'id': cv_version['id'], 'to-lifecycle-environment-id': lifecycle_environment['id'] }) # check that content view exists in lifecycle content_view = ContentView.with_user(user['login'], user['password']).info( {'id': content_view['id']}) assert len(content_view['versions']) == 1 cv_version = ContentView.with_user(user['login'], user['password']).version_info({ 'id': content_view['versions'][0]['id'] }) assert len(cv_version['lifecycle-environments']) == 2 assert cv_version['lifecycle-environments'][-1][ 'id'] == lifecycle_environment['id'] # step 2.12: Create a new activation key activation_key = _create( user, ActivationKey, { 'content-view-id': content_view['id'], 'lifecycle-environment-id': lifecycle_environment['id'], 'name': gen_alphanumeric(), 'organization-id': org['id'], }, ) # step 2.13: Add the products to the activation key subscription_list = Subscription.with_user( user['login'], user['password']).list({'organization-id': org['id']}, per_page=False) for subscription in subscription_list: if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME: ActivationKey.with_user(user['login'], user['password']).add_subscription({ 'id': activation_key['id'], 'quantity': 1, 'subscription-id': subscription['id'], }) # step 2.13.1: Enable product content if fake_manifest_is_set: ActivationKey.with_user(user['login'], user['password']).content_override({ 'content-label': AK_CONTENT_LABEL, 'id': activation_key['id'], 'organization-id': org['id'], 'value': '1', }) # BONUS: Create a content host and associate it with promoted # content view and last lifecycle where it exists content_host_name = gen_alphanumeric() content_host = Host.with_user(user['login'], user['password']).subscription_register({ 'content-view-id': content_view['id'], 'lifecycle-environment-id': lifecycle_environment['id'], 'name': content_host_name, 'organization-id': org['id'], }) content_host = Host.with_user(user['login'], user['password']).info( {'id': content_host['id']}) # check that content view matches what we passed assert content_host['content-information']['content-view'][ 'name'] == content_view['name'] # check that lifecycle environment matches assert (content_host['content-information']['lifecycle-environment'] ['name'] == lifecycle_environment['name']) # step 2.14: Create a new libvirt compute resource _create( user, ComputeResource, { 'name': gen_alphanumeric(), 'provider': 'Libvirt', 'url': f'qemu+ssh://root@{settings.libvirt.libvirt_hostname}/system', }, ) # step 2.15: Create a new subnet subnet = _create( user, Subnet, { 'name': gen_alphanumeric(), 'network': gen_ipaddr(ip3=True), 'mask': '255.255.255.0', }, ) # step 2.16: Create a new domain domain = _create(user, Domain, {'name': gen_alphanumeric()}) # step 2.17: Create a new hostgroup and associate previous entities to it host_group = _create( user, HostGroup, { 'domain-id': domain['id'], 'name': gen_alphanumeric(), 'subnet-id': subnet['id'] }, ) HostGroup.with_user(user['login'], user['password']).update({ 'id': host_group['id'], 'organization-ids': org['id'], 'content-view-id': content_view['id'], 'lifecycle-environment-id': lifecycle_environment['id'], }) # step 2.18: Provision a client # TODO this isn't provisioning through satellite as intended # Note it wasn't well before the change that added this todo rhel6_contenthost.install_katello_ca(default_sat) # Register client with foreman server using act keys rhel6_contenthost.register_contenthost(org['label'], activation_key['name']) assert rhel6_contenthost.subscribed # Install rpm on client package_name = 'python-kitchen' result = rhel6_contenthost.execute(f'yum install -y {package_name}') assert result.status == 0 # Verify that the package is installed by querying it result = rhel6_contenthost.run(f'rpm -q {package_name}') assert result.status == 0
def test_positive_end_to_end(self): """Perform end to end smoke tests using RH repos. 1. Create new organization and environment 2. Upload manifest 3. Sync a RedHat repository 4. Create content-view 5. Add repository to contet-view 6. Promote/publish content-view 7. Create an activation-key 8. Add product to activation-key 9. Create new virtualmachine 10. Pull rpm from Foreman server and install on client 11. Register client with foreman server using activation-key 12. Install rpm on client @Feature: Smoke test @Assert: All tests should succeed and Content should be successfully fetched by client """ # Product, RepoSet and repository variables rhel_product_name = PRDS['rhel'] rhel_repo_set = REPOSET['rhva6'] rhel_repo_name = REPOS['rhva6']['name'] org_name = random.choice(generate_strings_list()) # Create new org and environment new_org = make_org({u'name': org_name}) new_env = make_lifecycle_environment({ u'organization-id': new_org['id'], }) # Clone manifest and upload it with manifests.clone() as manifest: ssh.upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': new_org['id'], }) # Enable repo from Repository Set RepositorySet.enable({ u'basearch': 'x86_64', u'name': rhel_repo_set, u'organization-id': new_org['id'], u'product': rhel_product_name, u'releasever': '6Server', }) # Fetch repository info rhel_repo = Repository.info({ u'name': rhel_repo_name, u'organization-id': new_org['id'], u'product': rhel_product_name, }) # Synchronize the repository Repository.synchronize({ u'name': rhel_repo_name, u'organization-id': new_org['id'], u'product': rhel_product_name, }) # Create CV and associate repo to it new_cv = make_content_view({u'organization-id': new_org['id']}) ContentView.add_repository({ u'id': new_cv['id'], u'organization-id': new_org['id'], u'repository-id': rhel_repo['id'], }) # Publish a version1 of CV ContentView.publish({u'id': new_cv['id']}) # Get the CV info version1_id = ContentView.info({u'id': new_cv['id']})['versions'][0]['id'] # Store the version1 id # Promotion of version1 to next env ContentView.version_promote({ u'id': version1_id, u'to-lifecycle-environment-id': new_env['id'], }) # Create activation key activation_key = make_activation_key({ u'content-view': new_cv['name'], u'lifecycle-environment-id': new_env['id'], u'organization-id': new_org['id'], }) # List the subscriptions in given org result = Subscription.list({u'organization-id': new_org['id']}, per_page=False) self.assertGreater(len(result), 0) # Get the subscription ID from subscriptions list subscription_quantity = 0 for subscription in result: if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME: subscription_id = subscription['id'] subscription_quantity = int(subscription['quantity']) self.assertGreater(subscription_quantity, 0) # Add the subscriptions to activation-key ActivationKey.add_subscription({ u'id': activation_key['id'], u'quantity': 1, u'subscription-id': subscription_id, }) # Enable product content ActivationKey.content_override({ u'content-label': 'rhel-6-server-rhev-agent-rpms', u'id': activation_key['id'], u'organization-id': new_org['id'], u'value': '1', }) # Create VM package_name = "python-kitchen" server_name = settings.server.hostname with VirtualMachine(distro='rhel66') as vm: # Download and Install rpm result = vm.run( "wget -nd -r -l1 --no-parent -A '*.noarch.rpm' http://{0}/pub/" .format(server_name)) self.assertEqual(result.return_code, 0) result = vm.run('rpm -i katello-ca-consumer*.noarch.rpm') self.assertEqual(result.return_code, 0) # Register client with foreman server using activation-key result = vm.run( u'subscription-manager register --activationkey {0} ' '--org {1} --force'.format(activation_key['name'], new_org['label'])) self.assertEqual(result.return_code, 0) # Install contents from sat6 server result = vm.run('yum install -y {0}'.format(package_name)) self.assertEqual(result.return_code, 0) # Verify if package is installed by query it result = vm.run('rpm -q {0}'.format(package_name)) self.assertEqual(result.return_code, 0)
def test_positive_show_count_on_chost_details_page(self): """Errata count on Content host Details page :id: 388229da-2b0b-41aa-a457-9b5ecbf3df4b :Setup: 1. Errata synced on satellite server. 2. Some content hosts are present. :Steps: Go to Hosts -> Content Hosts -> Select Content Host -> Details page. :expectedresults: 1. The errata section should be displayed with Security, Bugfix, Enhancement types. 2. The number should link to the errata details page, filtered by type. :CaseLevel: System """ org = entities.Organization().create() env = entities.LifecycleEnvironment( organization=org).create() content_view = entities.ContentView( organization=org).create() activation_key = entities.ActivationKey( environment=env, organization=org, ).create() setup_org_for_a_rh_repo({ 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst6'], 'repository': REPOS['rhst6']['name'], 'organization-id': org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }, force_use_cdn=True) setup_org_for_a_custom_repo({ 'url': CUSTOM_REPO_URL, 'organization-id': org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }) RepositorySet.enable({ 'basearch': DEFAULT_ARCHITECTURE, 'name': REPOSET['rhva6'], 'organization-id': org.id, 'product': PRDS['rhel'], 'releasever': DEFAULT_RELEASE_VERSION, }) rhel_repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'organization-id': org.id, 'product': PRDS['rhel'], }) Repository.synchronize({ 'name': REPOS['rhva6']['name'], 'organization-id': org.id, 'product': PRDS['rhel'], }) ContentView.add_repository({ 'id': content_view.id, 'organization-id': org.id, 'repository-id': rhel_repo['id'], }) ContentView.publish({'id': content_view.id}) cvv = ContentView.info({'id': content_view.id})['versions'][-1] ContentView.version_promote({ 'id': cvv['id'], 'organization-id': org.id, 'to-lifecycle-environment-id': env.id, }) with VirtualMachine(distro=DISTRO_RHEL6) as client: client.install_katello_ca() client.register_contenthost(org.label, activation_key.name) self.assertTrue(client.subscribed) client.enable_repo(REPOS['rhst6']['id']) client.enable_repo(REPOS['rhva6']['id']) client.install_katello_agent() with Session(self) as session: session.nav.go_to_select_org(org.name) result = self.contenthost.fetch_errata_counts( client.hostname, details_page=True) for errata in ('security', 'bug_fix', 'enhancement'): self.assertEqual(result[errata]['value'], 0) if bz_bug_is_open(1484044): self.assertNotIn( result['security']['color'], ('red', 'yellow')) else: self.assertEqual(result['security']['color'], 'black') client.run( 'yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE)) result = self.contenthost.fetch_errata_counts( client.hostname, details_page=True) self.assertEqual(result['security']['value'], 1) self.assertEqual(result['security']['color'], 'red') client.run('yum install -y {0}'.format(REAL_0_RH_PACKAGE)) result = self.contenthost.fetch_errata_counts( client.hostname, details_page=True) for errata in ('bug_fix', 'enhancement'): self.assertEqual(result[errata]['value'], 1) self.assertEqual(result[errata]['color'], 'yellow')
def test_end_to_end(self): """@Test: Perform end to end smoke tests using RH repos. 1. Create new organization and environment 2. Upload manifest 3. Sync a RedHat repository 4. Create content-view 5. Add repository to contet-view 6. Promote/publish content-view 7. Create an activation-key 8. Add product to activation-key 9. Create new virtualmachine 10. Pull rpm from Foreman server and install on client 11. Register client with foreman server using activation-key 12. Install rpm on client @Feature: Smoke test @Assert: All tests should succeed and Content should be successfully fetched by client """ # Product, RepoSet and repository variables rhel_product_name = 'Red Hat Enterprise Linux Server' rhel_repo_set = ( 'Red Hat Enterprise Virtualization Agents ' 'for RHEL 6 Server (RPMs)' ) rhel_repo_name = ( 'Red Hat Enterprise Virtualization Agents ' 'for RHEL 6 Server ' 'RPMs x86_64 6Server' ) org_name = random.choice(generate_strings_list()) # Create new org and environment new_org = make_org({u'name': org_name}) new_env = make_lifecycle_environment({ u'organization-id': new_org['id'], u'name': gen_alphanumeric(), }) # Clone manifest and upload it manifest = manifests.clone() upload_file(manifest, remote_file=manifest) result = Subscription.upload({ u'file': manifest, u'organization-id': new_org['id'], }) self.assertEqual( result.return_code, 0, "Failed to upload manifest: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Enable repo from Repository Set result = RepositorySet.enable({ u'name': rhel_repo_set, u'organization-id': new_org['id'], u'product': rhel_product_name, u'releasever': '6Server', u'basearch': 'x86_64', }) self.assertEqual( result.return_code, 0, "Repo was not enabled: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Fetch repository info result = Repository.info({ u'name': rhel_repo_name, u'product': rhel_product_name, u'organization-id': new_org['id'], }) rhel_repo = result.stdout # Synchronize the repository result = Repository.synchronize({ u'name': rhel_repo_name, u'organization-id': new_org['id'], u'product': rhel_product_name, }) self.assertEqual( result.return_code, 0, "Repo was not synchronized: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Create CV and associate repo to it new_cv = make_content_view({u'organization-id': new_org['id']}) result = ContentView.add_repository({ u'id': new_cv['id'], u'repository-id': rhel_repo['id'], u'organization-id': new_org['id'], }) self.assertEqual( result.return_code, 0, "Failed repository association: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Publish a version1 of CV result = ContentView.publish({u'id': new_cv['id']}) self.assertEqual( result.return_code, 0, "Version1 publishing failed: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Get the CV info result = ContentView.info({u'id': new_cv['id']}) self.assertEqual( result.return_code, 0, "ContentView was not found: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Store the version1 id version1_id = result.stdout['versions'][0]['id'] # Promotion of version1 to next env result = ContentView.version_promote({ u'id': version1_id, u'to-lifecycle-environment-id': new_env['id'], }) self.assertEqual( result.return_code, 0, "version1 promotion failed: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Create activation key activation_key = make_activation_key({ u'name': gen_alphanumeric(), u'lifecycle-environment-id': new_env['id'], u'organization-id': new_org['id'], u'content-view': new_cv['name'], }) # List the subscriptions in given org result = Subscription.list( {u'organization-id': new_org['id']}, per_page=False ) self.assertEqual( result.return_code, 0, "Failed to list subscriptions: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Get the subscription ID from subscriptions list for subscription in result.stdout: if subscription['name'] == "Red Hat Employee Subscription": subscription_id = subscription['id'] subscription_quantity = int(subscription['quantity']) self.assertGreater( int(subscription_quantity), 0, 'Unexpected subscription quantity {0}' .format(subscription_quantity) ) # Add the subscriptions to activation-key result = ActivationKey.add_subscription({ u'id': activation_key['id'], u'subscription-id': subscription_id, u'quantity': 1, }) self.assertEqual( result.return_code, 0, "Failed to add subscription: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Create VM package_name = "python-kitchen" server_name = conf.properties['main.server.hostname'] with VirtualMachine(distro='rhel66') as vm: # Download and Install rpm result = vm.run( "wget -nd -r -l1 --no-parent -A '*.noarch.rpm' http://{0}/pub/" .format(server_name) ) self.assertEqual( result.return_code, 0, "failed to fetch katello-ca rpm: {0}, return code: {1}" .format(result.stderr, result.return_code) ) result = vm.run( 'rpm -i katello-ca-consumer*.noarch.rpm' ) self.assertEqual( result.return_code, 0, "failed to install katello-ca rpm: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Register client with foreman server using activation-key result = vm.run( u'subscription-manager register --activationkey {0} ' '--org {1} --force' .format(activation_key['name'], new_org['label']) ) self.assertEqual( result.return_code, 0, "failed to register client:: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Enable Red Hat Enterprise Virtualization Agents repo via cli # As the below repo is disabled by default under ak's prd-content result = vm.run( 'subscription-manager repos --enable ' 'rhel-6-server-rhev-agent-rpms' ) self.assertEqual( result.return_code, 0, "Enabling repo failed: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Install contents from sat6 server result = vm.run('yum install -y {0}'.format(package_name)) self.assertEqual( result.return_code, 0, "Package install failed: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Verify if package is installed by query it result = vm.run('rpm -q {0}'.format(package_name)) self.assertIn(package_name, result.stdout[0])