def test_positive_enable_by_name(self): """Enable repo from reposet by names of reposet, org and product :id: a78537bd-b88d-4f00-8901-e7944e5de729 :expectedresults: Repository was enabled :CaseImportance: Critical """ org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization': org['name'], u'product': PRDS['rhel'], u'releasever': '6Server', }) result = RepositorySet.available_repositories({ u'name': REPOSET['rhva6'], u'organization': org['name'], u'product': PRDS['rhel'], }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'true')
def test_positive_enable_manifest_reposet(self): """enable repository set @Feature: Subscriptions/Repository Sets @Assert: you are able to enable and synchronize repository contained in a manifest """ self._upload_manifest(self.org['id']) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) RepositorySet.enable({ 'basearch': 'x86_64', 'name': REPOSET['rhva6'], 'organization-id': self.org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', }) Repository.synchronize({ 'name': REPOS['rhva6']['name'], 'organization-id': self.org['id'], 'product': PRDS['rhel'], })
def test_positive_synchronize_rh_product_future_sync_date(self): """Create a sync plan with sync date in a future and sync one RH product with it automatically. :id: 6ce2f777-f230-4bb8-9822-2cf3580c21aa :expectedresults: Product is synchronized successfully. :CaseLevel: System """ delay = 10 * 60 # delay for sync date in seconds org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'], }) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'organization-id': org['id'], 'sync-date': (datetime.utcnow() + timedelta(seconds=delay)).strftime("%Y-%m-%d %H:%M:%S"), }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'], }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'], }) # Verify product is not synced and doesn't have any content self.validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Wait half of expected time sleep(delay / 2) # Verify product has not been synced yet self.validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time sleep(delay / 2) # Verify product was synced successfully self.validate_repo_content(repo, ['errata', 'packages'])
def test_enable_manifest_reposet(self): """@Test: enable repository set (positive) @Feature: Subscriptions/Repository Sets @Assert: you are able to enable and synchronize repository contained in a manifest """ self._upload_manifest(self.manifest, self.org['id']) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) RepositorySet.enable({ 'basearch': 'x86_64', 'name': ( 'Red Hat Enterprise Virtualization Agents ' 'for RHEL 6 Workstation (RPMs)' ), 'organization-id': self.org['id'], 'product': 'Red Hat Enterprise Linux Workstation', 'releasever': '6Workstation', }) Repository.synchronize({ 'name': ( 'Red Hat Enterprise Virtualization Agents ' 'for RHEL 6 Workstation ' 'RPMs x86_64 6Workstation' ), 'organization-id': self.org['id'], 'product': 'Red Hat Enterprise Linux Workstation', })
def test_positive_export_rh_product(self): """Export a repository from the Red Hat product @Feature: Repository - Export @Assert: Repository was successfully exported, rpm files are present on satellite machine """ # Enable RH repository with manifests.clone() as manifest: ssh.upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': self.org['id'], }) RepositorySet.enable({ 'basearch': 'x86_64', 'name': REPOSET['rhva6'], 'organization-id': self.org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'organization-id': self.org['id'], 'product': PRDS['rhel'], }) repo_export_dir = ( '/mnt/{0}/{1}-{2}-{3}/{1}/{4}/content/dist/rhel/server/6/6Server/' 'x86_64/rhev-agent/3/os'.format( self.export_dir, self.org['label'], PRDS['rhel'].replace(' ', '_'), repo['label'], ENVIRONMENT, )) # Update the download policy to 'immediate' Repository.update({ 'download-policy': 'immediate', 'id': repo['id'], }) # Export the repository Repository.export({'id': repo['id']}) # Verify export directory is empty result = ssh.command('ls -l {0} | grep .rpm'.format(repo_export_dir)) self.assertEqual(len(result.stdout), 0) # Synchronize the repository Repository.synchronize({'id': repo['id']}) # Export the repository once again Repository.export({'id': repo['id']}) # Verify RPMs were successfully exported result = ssh.command('ls -l {0} | grep .rpm'.format(repo_export_dir)) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
def test_positive_enable_manifest_reposet(self): """enable repository set :id: cc0f8f40-5ea6-4fa7-8154-acdc2cb56b45 :expectedresults: you are able to enable and synchronize repository contained in a manifest :CaseLevel: Integration """ self._upload_manifest(self.org['id']) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) RepositorySet.enable({ 'basearch': 'x86_64', 'name': REPOSET['rhva6'], 'organization-id': self.org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', }) Repository.synchronize({ 'name': REPOS['rhva6']['name'], 'organization-id': self.org['id'], 'product': PRDS['rhel'], })
def test_positive_enable_manifest_reposet(self): """enable repository set :id: cc0f8f40-5ea6-4fa7-8154-acdc2cb56b45 :expectedresults: you are able to enable and synchronize repository contained in a manifest :CaseLevel: Integration :CaseImportance: Critical """ self._upload_manifest(self.org['id']) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) RepositorySet.enable({ 'basearch': 'x86_64', 'name': REPOSET['rhva6'], 'organization-id': self.org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', }) Repository.synchronize({ 'name': REPOS['rhva6']['name'], 'organization-id': self.org['id'], 'product': PRDS['rhel'], })
def create(self, organization_id, product_id=None, download_policy=DOWNLOAD_POLICY_ON_DEMAND, synchronize=True): # type: (int, Optional[int], Optional[str], Optional[bool]) -> Dict """Create an RH repository""" if not self.cdn and not self.url: raise ValueError('Can not handle Custom repository with url not supplied') if self.cdn: data = self.data RepositorySet.enable({ 'organization-id': organization_id, 'product': data['product'], 'name': data['repository-set'], 'basearch': data.get('arch', DEFAULT_ARCHITECTURE), 'releasever': data.get('releasever'), }) repo_info = Repository.info({ 'organization-id': organization_id, 'name': data['repository'], 'product': data['product'], }) if download_policy: # Set download policy Repository.update({ 'download-policy': download_policy, 'id': repo_info['id'], }) self._repo_info = repo_info if synchronize: self.synchronize() else: repo_info = super(GenericRHRepository, self).create( organization_id, product_id, download_policy=download_policy) return repo_info
def test_positive_enable_by_name(self): """Enable repo from reposet by names of reposet, org and product @Feature: Repository-set @Assert: Repository was enabled """ org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization': org['name'], u'product': PRDS['rhel'], u'releasever': '6Server', }) result = RepositorySet.available_repositories({ u'name': REPOSET['rhva6'], u'organization': org['name'], u'product': PRDS['rhel'], }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'true')
def test_positive_enable_by_name(self): """Enable repo from reposet by names of reposet, org and product @id: a78537bd-b88d-4f00-8901-e7944e5de729 @Assert: Repository was enabled """ org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization': org['name'], u'product': PRDS['rhel'], u'releasever': '6Server', }) result = RepositorySet.available_repositories({ u'name': REPOSET['rhva6'], u'organization': org['name'], u'product': PRDS['rhel'], }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'true')
def test_positive_enable_by_label(self): """Enable repo from reposet by org label, reposet and product names @id: 5230c1cd-fed7-40ac-8445-bac4f9c5ee68 @Assert: Repository was enabled """ org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization-label': org['label'], u'product': PRDS['rhel'], u'releasever': '6Server', }) result = RepositorySet.available_repositories({ u'name': REPOSET['rhva6'], u'organization-label': org['label'], u'product': PRDS['rhel'], }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'true')
def _enable_repositories(self): """Utility function to retrieve enabled repositories""" for i, repo in enumerate(self.repository_list): repo_id = repo[0] basearch = repo[1] releasever = repo[2] self.logger.info( 'Enabling product {0}: repository id {1} ' 'with baserach {2} and release {3}' .format(i, repo_id, basearch, releasever)) # Enable repos from Repository Set RepositorySet.enable({ 'basearch': basearch, 'id': repo_id, 'product-id': self.pid, 'releasever': releasever, }) # verify enabled repository list result = Repository.list( {'organization-id': self.org_id}, per_page=False ) # repo_list_ids would contain all repositories in the hammer repo list repo_list_ids = [repo['id'] for repo in result] self.logger.debug(repo_list_ids)
def test_positive_enable_manifest_reposet(function_org, manifest_clone_upload): """enable repository set :id: cc0f8f40-5ea6-4fa7-8154-acdc2cb56b45 :expectedresults: you are able to enable and synchronize repository contained in a manifest :CaseLevel: Integration :CaseImportance: Critical """ Subscription.list({'organization-id': function_org.id}, per_page=False) RepositorySet.enable( { 'basearch': 'x86_64', 'name': REPOSET['rhva6'], 'organization-id': function_org.id, 'product': PRDS['rhel'], 'releasever': '6Server', } ) Repository.synchronize( { 'name': REPOS['rhva6']['name'], 'organization-id': function_org.id, 'product': PRDS['rhel'], } )
def test_repositoryset_enable_by_label(self): """@Test: Enable repo from reposet by org label, reposet and product names @Feature: Repository-set @Assert: Repository was enabled """ org = make_org() manifest = manifests.clone() upload_file(manifest, remote_file=manifest) Subscription.upload({ u'file': manifest, u'organization-id': org['id'], }) RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization-label': org['label'], u'product': PRDS['rhel'], u'releasever': '6Server', }) result = RepositorySet.available_repositories({ u'name': REPOSET['rhva6'], u'organization-label': org['label'], u'product': PRDS['rhel'], }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'true')
def _enable_repositories(self): """Utility function to retrieve enabled repositories""" for i, repo in enumerate(self.repository_list): repo_id = repo[0] basearch = repo[1] releasever = repo[2] self.logger.info('Enabling product {0}: repository id {1} ' 'with baserach {2} and release {3}'.format( i, repo_id, basearch, releasever)) # Enable repos from Repository Set RepositorySet.enable({ 'basearch': basearch, 'id': repo_id, 'product-id': self.pid, 'releasever': releasever, }) # verify enabled repository list result = Repository.list({'organization-id': self.org_id}, per_page=False) # repo_list_ids would contain all repositories in the hammer repo list repo_list_ids = [repo['id'] for repo in result] self.logger.debug(repo_list_ids)
def test_positive_synchronize_rh_product_past_sync_date(self): """Create a sync plan with past datetime as a sync date, add a RH product and verify the product gets synchronized on the next sync occurrence :id: 47280ef4-3936-4dbc-8ed0-1076aa8d40df :expectedresults: Product is synchronized successfully. :BZ: 1279539 :CaseLevel: System """ interval = 60 * 60 # 'hourly' sync interval in seconds delay = 80 org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'], }) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'interval': 'hourly', 'organization-id': org['id'], 'sync-date': ( datetime.utcnow() - timedelta(interval - delay/2) ).strftime("%Y-%m-%d %H:%M:%S"), }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'], }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'], }) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Verify product has not been synced yet sleep(delay/4) self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time sleep(delay) # Verify product was synced successfully self.validate_repo_content(repo, ['errata', 'packages'])
def test_positive_synchronize_rh_product_current_sync_date(self): """Create a sync plan with current datetime as a sync date, add a RH product and verify the product gets synchronized on the next sync occurrence @Assert: Product is synchronized successfully. @Feature: SyncPlan @BZ: 1279539 """ interval = 60 * 60 # 'hourly' sync interval in seconds org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'], }) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'interval': 'hourly', 'organization-id': org['id'], 'sync-date': datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"), }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'], }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'], }) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Wait half of expected time sleep(interval / 2) # Verify product has not been synced yet self.validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time sleep(interval / 2) # Verify product was synced successfully self.validate_repo_content(repo, ['errata', 'packages'])
def test_positive_synchronize_rh_product_future_sync_date(self): """Create a sync plan with sync date in a future and sync one RH product with it automatically. :id: 6ce2f777-f230-4bb8-9822-2cf3580c21aa :expectedresults: Product is synchronized successfully. :CaseLevel: System """ delay = 10 * 60 # delay for sync date in seconds org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'], }) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'organization-id': org['id'], 'sync-date': (datetime.utcnow() + timedelta(seconds=delay)) .strftime("%Y-%m-%d %H:%M:%S"), }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'], }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'], }) # Verify product is not synced and doesn't have any content self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Wait half of expected time sleep(delay/2) # Verify product has not been synced yet self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time sleep(delay/2) # Verify product was synced successfully self.validate_repo_content(repo, ['errata', 'packages'])
def test_positive_synchronize_rh_product_current_sync_date(self): """Create a sync plan with current datetime as a sync date, add a RH product and verify the product gets synchronized on the next sync occurrence @Assert: Product is synchronized successfully. @Feature: SyncPlan @BZ: 1279539 """ interval = 60 * 60 # 'hourly' sync interval in seconds org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'], }) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'interval': 'hourly', 'organization-id': org['id'], 'sync-date': datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"), }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'], }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'], }) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Wait half of expected time sleep(interval / 2) # Verify product has not been synced yet self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time sleep(interval / 2) # Verify product was synced successfully self.validate_repo_content(repo, ['errata', 'packages'])
def test_repositoryset_disable_by_id(self): """@Test: Disable repo from reposet by IDs of reposet, org and product @Feature: Repository-set @Assert: Repository was disabled """ org = make_org() manifest = manifests.clone() upload_file(manifest, remote_file=manifest) result = Subscription.upload({ u'file': manifest, u'organization-id': org['id'], }) self.assertEqual(result.return_code, 0) product_id = Product.info({ u'name': PRDS['rhel'], u'organization-id': org['id'], }).stdout['id'] reposet_id = RepositorySet.info({ u'name': REPOSET['rhva6'], u'organization-id': org['id'], u'product-id': product_id, }).stdout['id'] result = RepositorySet.enable({ u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, u'releasever': '6Server', u'basearch': 'x86_64', }) self.assertEqual(result.return_code, 0) result = RepositorySet.disable({ u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, u'releasever': '6Server', u'basearch': 'x86_64', }) self.assertEqual(result.return_code, 0) result = RepositorySet.available_repositories({ u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, }) self.assertEqual(result.return_code, 0) enabled = [ repo['enabled'] for repo in result.stdout if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'false')
def test_positive_enable_by_id(params): """Enable repo from reposet by IDs of reposet, org and product :id: f7c88534-1d45-45d9-9b87-c50c4e268e8d :expectedresults: Repository was enabled :CaseImportance: Critical """ RepositorySet.enable(params['enable']['ids']) result = RepositorySet.available_repositories(params['avail']['ids']) assert len(match_repos(result, params['match']['enabled_arch_rel'])) == 1
def test_positive_enable_by_name(params): """Enable repo from reposet by names of reposet, org and product :id: a78537bd-b88d-4f00-8901-e7944e5de729 :expectedresults: Repository was enabled :CaseImportance: Critical """ RepositorySet.enable(params['enable']['name']) result = RepositorySet.available_repositories(params['avail']['name']) assert len(match_repos(result, params['match']['enabled_arch_rel'])) == 1
def test_positive_enable_by_label(params): """Enable repo from reposet by org label, reposet and product names :id: 5230c1cd-fed7-40ac-8445-bac4f9c5ee68 :expectedresults: Repository was enabled :CaseImportance: Critical """ RepositorySet.enable(params['enable']['label']) result = RepositorySet.available_repositories(params['avail']['label']) assert len(match_repos(result, params['match']['enabled_arch_rel'])) == 1
def test_positive_disable_by_id(params): """Disable repo from reposet by IDs of reposet, org and product :id: 0d6102ba-3fb9-4eb8-972e-d537e252a8e6 :expectedresults: Repository was disabled :CaseImportance: Critical """ RepositorySet.enable(params['enable']['ids']) RepositorySet.disable(params['enable']['ids']) result = RepositorySet.available_repositories(params['avail']['ids']) assert len(match_repos(result, params['match']['enabled'])) == 0
def test_positive_install_ansible_collection(self, fixture_sca_vmsetup, module_gt_manifest_org): """Test whether Ansible collection can be installed via REX :Steps: 1. Upload a manifest. 2. Enable and sync Ansible repository. 3. Register content host to Satellite. 4. Enable Ansible repo on content host. 5. Install ansible package. 6. Run REX job to install Ansible collection on content host. :id: ad25aee5-4ea3-4743-a301-1c6271856f79 :CaseComponent: Ansible :Assignee: dsynk """ # Configure repository to prepare for installing ansible on host RepositorySet.enable({ 'basearch': 'x86_64', 'name': REPOSET['rhae2'], 'organization-id': module_gt_manifest_org.id, 'product': PRDS['rhae'], 'releasever': '7Server', }) Repository.synchronize({ 'name': REPOS['rhae2']['name'], 'organization-id': module_gt_manifest_org.id, 'product': PRDS['rhae'], }) client = fixture_sca_vmsetup client.execute( f'subscription-manager repos --enable {REPOS["rhae2"]["id"]}') client.execute('yum -y install ansible') collection_job = make_job_invocation({ 'job-template': 'Ansible Collection - Install from Galaxy', 'inputs': 'ansible_collections_list="oasis_roles.system"', 'search-query': f'name ~ {client.hostname}', }) result = JobInvocation.info({'id': collection_job['id']}) assert result['success'] == '1' collection_path = str( client.execute('ls /etc/ansible/collections/ansible_collections')) assert 'oasis' in collection_path
def create( self, organization_id, product_id=None, download_policy=DOWNLOAD_POLICY_ON_DEMAND, synchronize=True, ): # type: (int, Optional[int], Optional[str], Optional[bool]) -> Dict """Create an RH repository""" if not self.cdn and not self.url: raise ValueError( 'Can not handle Custom repository with url not supplied') if self.cdn: data = self.data if not Repository.list({ 'organization-id': organization_id, 'name': data['repository'], 'product': data['product'], }): RepositorySet.enable({ 'organization-id': organization_id, 'product': data['product'], 'name': data['repository-set'], 'basearch': data.get('arch', constants.DEFAULT_ARCHITECTURE), 'releasever': data.get('releasever'), }) repo_info = Repository.info({ 'organization-id': organization_id, 'name': data['repository'], 'product': data['product'], }) if download_policy: # Set download policy Repository.update({ 'download-policy': download_policy, 'id': repo_info['id'] }) self._repo_info = repo_info if synchronize: self.synchronize() else: repo_info = super().create(organization_id, product_id, download_policy=download_policy) return repo_info
def test_positive_disable_by_label(params): """Disable repo from reposet by org label, reposet and product names :id: a87a5df6-f8ab-469e-94e5-ca79378f8dbe :expectedresults: Repository was disabled :CaseImportance: Critical """ RepositorySet.enable(params['enable']['label']) RepositorySet.disable(params['enable']['label']) result = RepositorySet.available_repositories(params['avail']['label']) assert len(match_repos(result, params['match']['enabled'])) == 0
def test_positive_disable_by_name(params): """Disable repo from reposet by names of reposet, org and product :id: 1690a701-ae41-4724-bbc6-b0adba5a5319 :expectedresults: Repository was disabled :CaseImportance: Critical """ RepositorySet.enable(params['enable']['name']) RepositorySet.disable(params['enable']['name']) result = RepositorySet.available_repositories(params['avail']['name']) assert len(match_repos(result, params['match']['enabled'])) == 0
def test_positive_enable_by_id(self): """Enable repo from reposet by IDs of reposet, org and product :id: f7c88534-1d45-45d9-9b87-c50c4e268e8d :expectedresults: Repository was enabled :CaseImportance: Critical """ org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) product_id = Product.info({ u'name': PRDS['rhel'], u'organization-id': org['id'], })['id'] reposet_id = RepositorySet.info({ u'name': REPOSET['rhva6'], u'organization-id': org['id'], u'product-id': product_id, })['id'] RepositorySet.enable({ u'basearch': 'x86_64', u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, u'releasever': '6Server', }) result = RepositorySet.available_repositories({ u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'true')
def test_positive_disable_by_name(self): """Disable repo from reposet by names of reposet, org and product :id: 1690a701-ae41-4724-bbc6-b0adba5a5319 :expectedresults: Repository was disabled :CaseImportance: Critical """ org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization': org['name'], u'product': PRDS['rhel'], u'releasever': '6Server', }) RepositorySet.disable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization': org['name'], u'product': PRDS['rhel'], u'releasever': '6Server', }) result = RepositorySet.available_repositories({ u'name': REPOSET['rhva6'], u'organization': org['name'], u'product': PRDS['rhel'], }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'false')
def test_positive_disable_by_label(self): """Disable repo from reposet by org label, reposet and product names :id: a87a5df6-f8ab-469e-94e5-ca79378f8dbe :expectedresults: Repository was disabled :CaseImportance: Critical """ org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization-label': org['label'], u'product': PRDS['rhel'], u'releasever': '6Server', }) RepositorySet.disable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization-label': org['label'], u'product': PRDS['rhel'], u'releasever': '6Server', }) result = RepositorySet.available_repositories({ u'name': REPOSET['rhva6'], u'organization-label': org['label'], u'product': PRDS['rhel'], }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'false')
def test_enable_manifest_repository_set(self): """@Test: enable repository set (positive) @Feature: Subscriptions/Repository Sets @Assert: you are able to enable and synchronize repository contained in a manifest """ upload_file(self.manifest, remote_file=self.manifest) result = Subscription.upload({ 'file': self.manifest, 'organization-id': self.org['id'], }) self.assertEqual(result.return_code, 0, "Failed to upload manifest") self.assertEqual( len(result.stderr), 0, "There should not be an exception while uploading manifest.") result = Subscription.list( {'organization-id': self.org['id']}, per_page=False) self.assertEqual( len(result.stderr), 0, "There should not be an exception while listing the manifest.") result = RepositorySet.enable({ 'name': ( 'Red Hat Enterprise Virtualization Agents ' 'for RHEL 6 Workstation (RPMs)' ), 'organization-id': self.org['id'], 'product': 'Red Hat Enterprise Linux Workstation', 'releasever': '6Workstation', 'basearch': 'x86_64', }) self.assertEqual(result.return_code, 0, "Repo was not enabled") self.assertEqual(len(result.stderr), 0, "No error was expected") result = Repository.synchronize({ 'name': ( 'Red Hat Enterprise Virtualization Agents ' 'for RHEL 6 Workstation ' 'RPMs x86_64 6Workstation' ), 'organization-id': self.org['id'], 'product': 'Red Hat Enterprise Linux Workstation', }) self.assertEqual(result.return_code, 0, "Repo was not synchronized") self.assertEqual(len(result.stderr), 0, "No error was expected")
def test_positive_list_filter_by_cve(module_org, rh_repo): """Filter errata by CVE :id: 7791137c-95a7-4518-a56b-766a5680c5fb :Setup: Errata synced on satellite server. :Steps: erratum list --cve <cve_id> :expectedresults: Errata is filtered by CVE. """ RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': module_org.id, 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) Repository.synchronize({ 'name': REPOS['rhva6']['name'], 'organization-id': module_org.id, 'product': PRDS['rhel'], }) repository_info = Repository.info({ 'name': REPOS['rhva6']['name'], 'organization-id': module_org.id, 'product': PRDS['rhel'], }) assert REAL_4_ERRATA_ID in { errata['errata-id'] for errata in Erratum.list({'repository-id': repository_info['id']}) } for errata_cve in REAL_4_ERRATA_CVES: assert REAL_4_ERRATA_ID in { errata['errata-id'] for errata in Erratum.list({'cve': errata_cve}) }
def test_positive_disable_by_id(self): """Disable repo from reposet by IDs of reposet, org and product :id: 0d6102ba-3fb9-4eb8-972e-d537e252a8e6 :expectedresults: Repository was disabled :CaseImportance: Critical """ org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'] }) product_id = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'] })['id'] reposet_id = RepositorySet.info({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product-id': product_id })['id'] RepositorySet.enable({ 'basearch': 'x86_64', 'id': reposet_id, 'organization-id': org['id'], 'product-id': product_id, 'releasever': '6Server', }) RepositorySet.disable({ 'basearch': 'x86_64', 'id': reposet_id, 'organization-id': org['id'], 'product-id': product_id, 'releasever': '6Server', }) result = RepositorySet.available_repositories({ 'id': reposet_id, 'organization-id': org['id'], 'product-id': product_id }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'false')
def test_positive_disable_by_id(self): """Disable repo from reposet by IDs of reposet, org and product @Feature: Repository-set @Assert: Repository was disabled """ org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) product_id = Product.info({ u'name': PRDS['rhel'], u'organization-id': org['id'], })['id'] reposet_id = RepositorySet.info({ u'name': REPOSET['rhva6'], u'organization-id': org['id'], u'product-id': product_id, })['id'] RepositorySet.enable({ u'basearch': 'x86_64', u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, u'releasever': '6Server', }) RepositorySet.disable({ u'basearch': 'x86_64', u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, u'releasever': '6Server', }) result = RepositorySet.available_repositories({ u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'false')
def test_positive_disable_by_id(self): """Disable repo from reposet by IDs of reposet, org and product @id: 0d6102ba-3fb9-4eb8-972e-d537e252a8e6 @Assert: Repository was disabled """ org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) product_id = Product.info({ u'name': PRDS['rhel'], u'organization-id': org['id'], })['id'] reposet_id = RepositorySet.info({ u'name': REPOSET['rhva6'], u'organization-id': org['id'], u'product-id': product_id, })['id'] RepositorySet.enable({ u'basearch': 'x86_64', u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, u'releasever': '6Server', }) RepositorySet.disable({ u'basearch': 'x86_64', u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, u'releasever': '6Server', }) result = RepositorySet.available_repositories({ u'id': reposet_id, u'organization-id': org['id'], u'product-id': product_id, }) enabled = [ repo['enabled'] for repo in result if repo['arch'] == 'x86_64' and repo['release'] == '6Server' ][0] self.assertEqual(enabled, 'false')
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 test_positive_synchronize_rh_product_future_sync_date(module_org): """Create a sync plan with sync date in a future and sync one RH product with it automatically. :id: 6ce2f777-f230-4bb8-9822-2cf3580c21aa :expectedresults: Product is synchronized successfully. :CaseLevel: System :BZ: 1655595 """ delay = 2 * 60 # delay for sync date in seconds org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'] }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'] }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'] }) sync_plan = make_sync_plan({ 'enabled': 'true', 'organization-id': module_org.id, 'sync-date': (datetime.utcnow().replace(second=0) + timedelta(seconds=delay)).strftime(SYNC_DATE_FMT), 'cron-expression': ["*/4 * * * *"], }) # Verify product is not synced and doesn't have any content with pytest.raises(AssertionError): validate_task_status(repo['id'], max_tries=1) validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'] }) # Wait quarter of expected time logger.info('Waiting {} seconds to check product {}' ' was not synced'.format(delay / 4, product['name'])) sleep(delay / 4) # Verify product has not been synced yet with pytest.raises(AssertionError): validate_task_status(repo['id'], max_tries=1) validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time logger.info('Waiting {} seconds to check product {}' ' was synced'.format((delay * 3 / 4), product['name'])) sleep(delay * 3 / 4) # Verify product was synced successfully validate_task_status(repo['id'], repo_name=repo['name']) validate_repo_content(repo, ['errata', 'packages'])
def test_positive_synchronize_rh_product_past_sync_date(module_org): """Create a sync plan with past datetime as a sync date, add a RH product and verify the product gets synchronized on the next sync occurrence :id: 47280ef4-3936-4dbc-8ed0-1076aa8d40df :expectedresults: Product is synchronized successfully. :BZ: 1279539 :CaseLevel: System """ interval = 60 * 60 # 'hourly' sync interval in seconds delay = 2 * 60 org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'] }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'] }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'] }) sync_plan = make_sync_plan({ 'enabled': 'true', 'interval': 'hourly', 'organization-id': module_org.id, 'sync-date': (datetime.utcnow() - timedelta(seconds=interval - delay)).strftime(SYNC_DATE_FMT), }) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'] }) # Wait quarter of expected time logger.info('Waiting {} seconds to check product {}' ' was not synced'.format(delay / 4, product['name'])) sleep(delay / 4) # Verify product has not been synced yet with pytest.raises(AssertionError): validate_task_status(repo['id'], max_tries=1) validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time logger.info('Waiting {} seconds to check product {}' ' was synced'.format((delay * 3 / 4), product['name'])) sleep(delay * 3 / 4) # Verify product was synced successfully validate_task_status(repo['id'], repo_name=repo['name']) validate_repo_content(repo, ['errata', 'packages'])
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_synchronize_rh_product_past_sync_date(self): """Create a sync plan with past datetime as a sync date, add a RH product and verify the product gets synchronized on the next sync occurrence :id: 47280ef4-3936-4dbc-8ed0-1076aa8d40df :expectedresults: Product is synchronized successfully. :BZ: 1279539 :CaseLevel: System """ interval = 60 * 60 # 'hourly' sync interval in seconds delay = 3 * 60 org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'], }) sync_plan = self._make_sync_plan({ 'enabled': 'true', 'interval': 'hourly', 'organization-id': org['id'], 'sync-date': ( datetime.utcnow() - timedelta(seconds=interval - delay) ).strftime("%Y-%m-%d %H:%M:%S"), }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'], }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'], }) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'], }) # Verify product has not been synced yet self.logger.info('Waiting {0} seconds to check product {1}' ' was not synced'.format(delay/4, product['name'])) sleep(delay/4) with self.assertRaises(AssertionError): self.validate_task_status(repo['id'], max_tries=2) self.validate_repo_content( repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time self.logger.info('Waiting {0} seconds to check product {1}' ' was synced'.format(delay, product['name'])) sleep(delay * 3/4) # Re-calculate and Update with the current UTC time SyncPlan.update({ u'id': sync_plan['id'], u'sync-date': ( datetime.utcnow() - timedelta(seconds=interval - delay) ).strftime("%Y-%m-%d %H:%M:%S"), }) # Verify product was synced successfully self.validate_task_status(repo['id'], repo_name=repo['name']) self.validate_repo_content(repo, ['errata', 'packages'])
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='rhel65') 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) ) # 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])
[166, 'x86_64', '6Server'], [2463,'x86_64', '7Server'], [167, 'x86_64', '6Server'], [2464,'x86_64', '7Server'] ] for i, repo in enumerate(repository_list): repo_id = repo[0] basearch = repo[1] releasever = repo[2] print "Disabling product: {0} with basearch {1} and release {2}".format(repo_id, basearch, releasever) # Enable repo from Repository Set result = RepositorySet.disable({ 'product-id':pid, 'basearch':basearch, 'releasever':releasever, 'id':repo_id }) #repository_list.append([168, 'x86_64', '6Server']) #repository_list.append([2456,'x86_64','7Server']) #repository_list.append([]) ''' # Enable repo from Repository Set result = RepositorySet.enable({ 'product-id':pid, 'basearch':basearch, 'releasever':releasever, 'id':repo_id })
def test_positive_list_available_repositories(self): """List available repositories for repository-set :id: 987d6b08-acb0-4264-a459-9cef0d2c6f3f :expectedresults: List of available repositories is displayed, with valid amount of enabled repositories :CaseImportance: Critical """ rhel_product_name = PRDS['rhel'] rhel_repo_set = REPOSET['rhva6'] # Clone manifest and upload it org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) # No repos should be enabled by default result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, }) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result), 0 ) # Enable repo from Repository Set RepositorySet.enable({ u'basearch': 'x86_64', u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', }) # Only 1 repo should be enabled result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization': org['name'], u'product': rhel_product_name, }) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result), 1 ) # Enable one more repo RepositorySet.enable({ u'basearch': 'i386', u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', }) # 2 repos should be enabled result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-label': org['label'], u'product': rhel_product_name, }) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result), 2 ) # Disable one repo RepositorySet.disable({ u'basearch': 'i386', u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', }) # There should remain only 1 enabled repo result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, }) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result), 1 ) # Disable the last enabled repo RepositorySet.disable({ u'basearch': 'x86_64', u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', }) # There should be no enabled repos result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, }) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result), 0 )
def test_positive_export_rh_product(self): """Export a repository from the Red Hat product :id: e17898db-ca92-4121-a723-0d4b3cf120eb :expectedresults: Repository was successfully exported, rpm files are present on satellite machine :CaseLevel: System """ # Enable RH repository with manifests.clone() as manifest: ssh.upload_file(manifest.content, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': self.org['id'], }) RepositorySet.enable({ 'basearch': 'x86_64', 'name': REPOSET['rhva6'], 'organization-id': self.org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'organization-id': self.org['id'], 'product': PRDS['rhel'], }) repo_export_dir = ( '/mnt/{0}/{1}-{2}-{3}/{1}/{4}/content/dist/rhel/server/6/6Server/' 'x86_64/rhev-agent/3/os' .format( self.export_dir, self.org['label'], PRDS['rhel'].replace(' ', '_'), repo['label'], ENVIRONMENT, ) ) # Update the download policy to 'immediate' Repository.update({ 'download-policy': 'immediate', 'id': repo['id'], }) # Export the repository Repository.export({'id': repo['id']}) # Verify export directory is empty result = ssh.command('ls -l {0} | grep .rpm'.format(repo_export_dir)) self.assertEqual(len(result.stdout), 0) # Synchronize the repository Repository.synchronize({'id': repo['id']}) # Export the repository once again Repository.export({'id': repo['id']}) # Verify RPMs were successfully exported result = ssh.command('ls -l {0} | grep .rpm'.format(repo_export_dir)) self.assertEqual(result.return_code, 0) self.assertGreaterEqual(len(result.stdout), 1)
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 = 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_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() ssh.upload_file(manifest, remote_file=manifest) result = Subscription.upload({u"file": manifest, u"organization-id": new_org["id"]}) self.assertEqual(result.return_code, 0) # 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) # 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) # 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) # Publish a version1 of CV result = ContentView.publish({u"id": new_cv["id"]}) self.assertEqual(result.return_code, 0) # Get the CV info result = ContentView.info({u"id": new_cv["id"]}) self.assertEqual(result.return_code, 0) # 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) # 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) # Get the subscription ID from subscriptions list for subscription in result.stdout: 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 result = ActivationKey.add_subscription( {u"id": activation_key["id"], u"subscription-id": subscription_id, u"quantity": 1} ) self.assertEqual(result.return_code, 0) # Enable product content ActivationKey.content_override( { u"id": activation_key["id"], u"organization-id": new_org["id"], u"content-label": "rhel-6-server-rhev-agent-rpms", 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: 1. Go to Hosts -> Content Hosts. @Assert: 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='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) 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_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 test_positive_list_available_repositories(self): """List available repositories for repository-set :id: 987d6b08-acb0-4264-a459-9cef0d2c6f3f :expectedresults: List of available repositories is displayed, with valid amount of enabled repositories :CaseImportance: Critical """ rhel_product_name = PRDS['rhel'] rhel_repo_set = REPOSET['rhva6'] # Clone manifest and upload it org = make_org() with manifests.clone() as manifest: upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) # No repos should be enabled by default result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, }) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result), 0) # Enable repo from Repository Set RepositorySet.enable({ u'basearch': 'x86_64', u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', }) # Only 1 repo should be enabled result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization': org['name'], u'product': rhel_product_name, }) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result), 1) # Enable one more repo RepositorySet.enable({ u'basearch': 'i386', u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', }) # 2 repos should be enabled result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-label': org['label'], u'product': rhel_product_name, }) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result), 2) # Disable one repo RepositorySet.disable({ u'basearch': 'i386', u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', }) # There should remain only 1 enabled repo result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, }) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result), 1) # Disable the last enabled repo RepositorySet.disable({ u'basearch': 'x86_64', u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', }) # There should be no enabled repos result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, }) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result), 0)
def test_repositoryset_available_repositories(self): """@Test: List available repositories for repository-set @Feature: Repository-set @Assert: List of available repositories is displayed, with valid amount of enabled repositories """ rhel_product_name = 'Red Hat Enterprise Linux Server' rhel_repo_set = ( 'Red Hat Enterprise Virtualization Agents ' 'for RHEL 6 Server (RPMs)' ) # Clone manifest and upload it org = make_org() manifest = manifests.clone() upload_file(manifest, remote_file=manifest) result = Subscription.upload({ u'file': manifest, u'organization-id': org['id'], }) self.assertEqual(result.return_code, 0) # No repos should be enabled by default result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, }) self.assertEqual(result.return_code, 0) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result.stdout), 0 ) # Enable repo from Repository Set result = RepositorySet.enable({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', u'basearch': 'x86_64', }) self.assertEqual(result.return_code, 0) # Only 1 repo should be enabled result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization': org['name'], u'product': rhel_product_name, }) self.assertEqual(result.return_code, 0) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result.stdout), 1 ) # Enable one more repo result = RepositorySet.enable({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', u'basearch': 'i386', }) self.assertEqual(result.return_code, 0) # 2 repos should be enabled result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-label': org['label'], u'product': rhel_product_name, }) self.assertEqual(result.return_code, 0) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result.stdout), 2 ) # Disable one repo result = RepositorySet.disable({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', u'basearch': 'i386', }) self.assertEqual(result.return_code, 0) # There should remain only 1 enabled repo result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, }) self.assertEqual(result.return_code, 0) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result.stdout), 1 ) # Disable the last enabled repo result = RepositorySet.disable({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, u'releasever': '6Server', u'basearch': 'x86_64', }) self.assertEqual(result.return_code, 0) # There should be no enabled repos result = RepositorySet.available_repositories({ u'name': rhel_repo_set, u'organization-id': org['id'], u'product': rhel_product_name, }) self.assertEqual(result.return_code, 0) self.assertEqual( sum(int(repo['enabled'] == u'true') for repo in result.stdout), 0 )
def test_positive_synchronize_rh_product_future_sync_date(target_sat): """Create a sync plan with sync date in a future and sync one RH product with it automatically. :id: 6ce2f777-f230-4bb8-9822-2cf3580c21aa :expectedresults: Product is synchronized successfully. :CaseLevel: System :BZ: 1655595 """ cron_multiple = 5 # sync event is on every multiple of this value, starting from 00 mins delay = (cron_multiple) * 60 # delay for sync date in seconds guardtime = 180 # do not start test less than 2 mins before the next sync event org = make_org() with manifests.clone() as manifest: target_sat.put(manifest, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'] }) RepositorySet.enable({ 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', 'basearch': 'x86_64', }) product = Product.info({ 'name': PRDS['rhel'], 'organization-id': org['id'] }) repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'product': product['name'], 'organization-id': org['id'] }) # if < 3 mins before the target event rather wait 3 mins for the next test window if int(datetime.utcnow().strftime('%M')) % (cron_multiple) > int( guardtime / 60): sleep(guardtime) sync_plan = make_sync_plan({ 'enabled': 'true', 'organization-id': org['id'], 'sync-date': (datetime.utcnow().replace(second=0) + timedelta(seconds=delay)).strftime(SYNC_DATE_FMT), 'cron-expression': [f'*/{cron_multiple} * * * *'], }) # Verify product is not synced and doesn't have any content with pytest.raises(AssertionError): validate_task_status(repo['id'], org['id'], max_tries=1) validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Associate sync plan with product Product.set_sync_plan({ 'id': product['id'], 'sync-plan-id': sync_plan['id'] }) # Wait fifth of expected time logger.info( f"Waiting {(delay / 5)} seconds to check product {product['name']}" f" was not synced by {sync_plan['name']}") sleep(delay / 5) # Verify product has not been synced yet with pytest.raises(AssertionError): validate_task_status(repo['id'], org['id'], max_tries=1) validate_repo_content(repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time logger.info( f"Waiting {(delay * 4 / 5)} seconds to check product {product['name']}" f" was synced by {sync_plan['name']}") sleep(delay * 4 / 5) # Verify product was synced successfully validate_task_status(repo['id'], org['id']) validate_repo_content(repo, ['errata', 'packages'])