def test_positive_manifest_delete(function_org, manifest_clone_upload): """Delete uploaded manifest :id: 01539c07-00d5-47e2-95eb-c0fd4f39090f :expectedresults: Manifest are deleted properly :CaseImportance: Critical """ Subscription.list({'organization-id': function_org.id}, per_page=False) Subscription.delete_manifest({'organization-id': function_org.id}) Subscription.list({'organization-id': function_org.id}, per_page=False)
def test_positive_manifest_delete(self): """Delete uploaded manifest :id: 01539c07-00d5-47e2-95eb-c0fd4f39090f :expectedresults: Manifest are deleted properly :CaseImportance: Critical """ self._upload_manifest(self.org['id']) Subscription.list({'organization-id': self.org['id']}, per_page=False) Subscription.delete_manifest({'organization-id': self.org['id']}) Subscription.list({'organization-id': self.org['id']}, per_page=False)
def test_positive_manifest_refresh(self): """upload manifest and refresh :id: 579bbbf7-11cf-4d78-a3b1-16d73bd4ca57 :expectedresults: Manifests can be refreshed :CaseImportance: Critical """ self._upload_manifest(self.org['id'], manifests.original_manifest()) Subscription.list({'organization-id': self.org['id']}, per_page=False) Subscription.refresh_manifest({'organization-id': self.org['id']}) Subscription.delete_manifest({'organization-id': self.org['id']})
def test_positive_manifest_refresh(function_org): """upload manifest and refresh :id: 579bbbf7-11cf-4d78-a3b1-16d73bd4ca57 :expectedresults: Manifests can be refreshed :CaseImportance: Critical """ upload_manifest(function_org.id, manifests.original_manifest().content) Subscription.list({'organization-id': function_org.id}, per_page=False) Subscription.refresh_manifest({'organization-id': function_org.id}) Subscription.delete_manifest({'organization-id': function_org.id})
def test_manifest_delete(self): """@Test: Delete uploaded manifest (positive) @Feature: Subscriptions/Manifest Delete @Assert: Manifest are deleted properly @BZ: 1207501 """ self._upload_manifest(self.manifest, self.org['id']) result = Subscription.list( {'organization-id': self.org['id']}, per_page=False ) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) result = Subscription.delete_manifest({ 'organization-id': self.org['id'], }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) result = Subscription.list( {'organization-id': self.org['id']}, per_page=False ) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stdout), 0)
def test_manifest_refresh(self): """@Test: upload manifest (positive) and refresh @Feature: Subscriptions/Manifest refresh @Assert: Manifests can be refreshed """ self._upload_manifest( manifests.download_manifest_template(), self.org['id']) result = Subscription.list( {'organization-id': self.org['id']}, per_page=False ) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) result = Subscription.refresh_manifest({ 'organization-id': self.org['id'], }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) result = Subscription.delete_manifest({ 'organization-id': self.org['id'], }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0)
def test_positive_manifest_refresh(self): """upload manifest and refresh @Feature: Subscriptions/Manifest refresh @Assert: Manifests can be refreshed """ self._upload_manifest(self.org['id'], manifests.original_manifest()) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) Subscription.refresh_manifest({ 'organization-id': self.org['id'], }) Subscription.delete_manifest({ 'organization-id': self.org['id'], })
def test_manifest_refresh(self): """@Test: upload manifest (positive) and refresh @Feature: Subscriptions/Manifest refresh @Assert: Manifests can be refreshed """ self._upload_manifest( manifests.download_manifest_template(), self.org['id']) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) Subscription.refresh_manifest({ 'organization-id': self.org['id'], }) Subscription.delete_manifest({ 'organization-id': self.org['id'], })
def test_positive_manifest_delete(self): """Delete uploaded manifest @id: 01539c07-00d5-47e2-95eb-c0fd4f39090f @Assert: Manifest are deleted properly """ self._upload_manifest(self.org['id']) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) Subscription.delete_manifest({ 'organization-id': self.org['id'], }) Subscription.list( {'organization-id': self.org['id']}, per_page=False, )
def test_positive_manifest_delete(self): """Delete uploaded manifest @Feature: Subscriptions/Manifest Delete @Assert: Manifest are deleted properly """ self._upload_manifest(self.org['id']) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) Subscription.delete_manifest({ 'organization-id': self.org['id'], }) Subscription.list( {'organization-id': self.org['id']}, per_page=False, )
def test_positive_manifest_refresh(self): """upload manifest and refresh @id: 579bbbf7-11cf-4d78-a3b1-16d73bd4ca57 @Assert: Manifests can be refreshed """ self._upload_manifest( self.org['id'], manifests.original_manifest()) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) Subscription.refresh_manifest({ 'organization-id': self.org['id'], }) Subscription.delete_manifest({ 'organization-id': self.org['id'], })
def test_positive_manifest_refresh(self): """upload manifest and refresh @Feature: Subscriptions/Manifest refresh @Assert: Manifests can be refreshed """ self._upload_manifest( self.org['id'], manifests.original_manifest()) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) Subscription.refresh_manifest({ 'organization-id': self.org['id'], }) Subscription.delete_manifest({ 'organization-id': self.org['id'], })
def test_positive_manifest_delete(self): """Delete uploaded manifest :id: 01539c07-00d5-47e2-95eb-c0fd4f39090f :expectedresults: Manifest are deleted properly :CaseImportance: Critical """ self._upload_manifest(self.org['id']) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) Subscription.delete_manifest({ 'organization-id': self.org['id'], }) Subscription.list( {'organization-id': self.org['id']}, per_page=False, )
def test_positive_manifest_refresh(self): """upload manifest and refresh :id: 579bbbf7-11cf-4d78-a3b1-16d73bd4ca57 :expectedresults: Manifests can be refreshed :CaseImportance: Critical """ self._upload_manifest( self.org['id'], manifests.original_manifest()) Subscription.list( {'organization-id': self.org['id']}, per_page=False, ) Subscription.refresh_manifest({ 'organization-id': self.org['id'], }) Subscription.delete_manifest({ 'organization-id': self.org['id'], })
def test_manifest_delete(self): """@Test: Delete uploaded manifest (positive) @Feature: Subscriptions/Manifest Delete @Assert: Manifest are deleted properly @BZ: 1207501 """ 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(result.return_code, 0, "Failed to list manifests in this org.") self.assertEqual( len(result.stderr), 0, "There should not be an exception while listing the manifest.") result = Subscription.delete_manifest({ 'organization-id': self.org['id'], }) self.assertEqual(result.return_code, 0, "Failed to delete manifest") self.assertEqual( len(result.stderr), 0, "There should not be an exception while deleting manifest.") result = Subscription.list( {'organization-id': self.org['id']}, per_page=False) self.assertEqual(result.return_code, 0, "Failed to list manifests in this org.") self.assertEqual( len(result.stdout), 0, "There should not be any subscriptions in this org.")
def test_manifest_delete(self): """@Test: Delete uploaded manifest (positive) @Feature: Subscriptions/Manifest Delete @Assert: Manifest are deleted properly """ 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(result.return_code, 0, "Failed to list manifests in this org.") self.assertEqual( len(result.stderr), 0, "There should not be an exception while listing the manifest.") result = Subscription.delete_manifest({ 'organization-id': self.org['id'], }) self.assertEqual(result.return_code, 0, "Failed to delete manifest") self.assertEqual( len(result.stderr), 0, "There should not be an exception while deleting manifest.") result = Subscription.list( {'organization-id': self.org['id']}, per_page=False) self.assertEqual(result.return_code, 0, "Failed to list manifests in this org.") self.assertEqual( len(result.stdout), 0, "There should not be any subscriptions in this org.")
def test_manifest_delete(self): """ @test: Delete uploaded manifest (positive) @feature: Subscriptions/Manifest Delete @assert: Manifest are deleted properly """ mdetails = manifest.fetch_manifest() try: upload_file(mdetails['path'], remote_file=mdetails['path']) result = Subscription.upload({ 'file': mdetails['path'], '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(result.return_code, 0, "Failed to list manifests in this org.") self.assertEqual( len(result.stdout), 8, "There should not be an exception while listing the manifest.") result = Subscription.delete_manifest( {'organization-id': self.org['id']}) self.assertEqual(result.return_code, 0, "Failed to delete manifest") self.assertEqual( len(result.stderr), 0, "There should not be an exception while deleting manifest.") result = Subscription.list({'organization-id': self.org['id']}, per_page=False) self.assertEqual(result.return_code, 0, "Failed to list manifests in this org.") self.assertEqual( len(result.stdout), 0, "There should not be any subscriptions in this org.") finally: manifest.delete_distributor(ds_uuid=mdetails['uuid'])
def test_manifest_delete(self): """ @test: Delete uploaded manifest (positive) @feature: Subscriptions/Manifest Delete @assert: Manifest are deleted properly """ mdetails = manifest.fetch_manifest() try: upload_file(mdetails['path'], remote_file=mdetails['path']) result = Subscription.upload( {'file': mdetails['path'], '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(result.return_code, 0, "Failed to list manifests in this org.") self.assertEqual( len(result.stdout), 8, "There should not be an exception while listing the manifest.") result = Subscription.delete_manifest( {'organization-id': self.org['id']}) self.assertEqual(result.return_code, 0, "Failed to delete manifest") self.assertEqual( len(result.stderr), 0, "There should not be an exception while deleting manifest.") result = Subscription.list({'organization-id': self.org['id']}, per_page=False) self.assertEqual(result.return_code, 0, "Failed to list manifests in this org.") self.assertEqual( len(result.stdout), 0, "There should not be any subscriptions in this org.") finally: manifest.delete_distributor(ds_uuid=mdetails['uuid'])
def test_positive_restore_ak_and_content_hosts_subscriptions(self): """Restore activation key and content hosts subscriptions :id: a44fdeda-9c8c-4316-85b4-a9b6b9f1ffdb :customerscenario: true :steps: 1. Setup activation key , lifecycle environment and content view with RH repository 2. Add RH subscription to activation key 3. Setup hosts (minimum two) and subscribe them to activation key 4. Attach RH subscription to the created content hosts 5. export the activation key and content hosts subscriptions 6. Delete the subscription manifest 7. Ensure that the activation key and content hosts subscriptions does not exist 8. Upload the subscription manifest 9. Ensure the activation key and content hosts subscriptions does not exist 10. Restore the activation key and content hosts subscriptions :expectedresults: activation key and content hosts subscriptions restored :CaseImportance: Critical """ lce = make_lifecycle_environment({'organization-id': self.org['id']}) activation_key = make_activation_key({ 'organization-id': self.org['id'], 'lifecycle-environment-id': lce['id'], }) ActivationKey.update({ 'organization-id': self.org['id'], 'id': activation_key['id'], 'auto-attach': 'false', }) setup_org_for_a_rh_repo({ 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], 'repository': REPOS['rhst7']['name'], 'organization-id': self.org['id'], 'lifecycle-environment-id': lce['id'], 'activationkey-id': activation_key['id'], }, force_use_cdn=True) org_subs = Subscription.list({u'organization-id': self.org['id']}) default_subscription_id = None for sub in org_subs: if sub['name'] == DEFAULT_SUBSCRIPTION_NAME: default_subscription_id = sub['id'] break self.assertIsNotNone( default_subscription_id, msg='Default subscription not found') ak_subs = ActivationKey.subscriptions({ 'organization-id': self.org['id'], 'id': activation_key['id'], }, output_format='json') self.assertIn( DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs]) with VirtualMachine() as client1, VirtualMachine() as client2: hosts = [] for client in [client1, client2]: client.install_katello_ca() client.register_contenthost( self.org['label'], activation_key=activation_key['name']) self.assertTrue(client.subscribed) host = Host.info({'name': client.hostname}) hosts.append(host) Host.subscription_attach({ 'host-id': host['id'], 'subscription-id': default_subscription_id, }) host_subscriptions = ActivationKey.subscriptions({ 'organization-id': self.org['id'], 'id': activation_key['id'], 'host-id': host['id'], }, output_format='json') self.assertIn( DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in host_subscriptions] ) # export the current activations and content hosts subscriptions ak_file_path = '/tmp/ak_{0}.csv'.format(self.org['label']) ch_file_path = '/tmp/content_hosts_{0}.csv'.format( self.org['label']) CSV_.activation_keys({ 'export': True, 'file': ak_file_path, 'organization': self.org['name'], 'itemized-subscriptions': True, }) CSV_.content_hosts({ 'export': True, 'file': ch_file_path, 'organization': self.org['name'], 'itemized-subscriptions': True, }) # delete the manifest Subscription.delete_manifest({'organization-id': self.org['id']}) # ensure that the subscription does not exist any more ak_subs = ActivationKey.subscriptions({ 'organization-id': self.org['id'], 'id': activation_key['id'], }, output_format='json') self.assertNotIn( DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs]) for host in hosts: host_subscriptions = ActivationKey.subscriptions({ 'organization-id': self.org['id'], 'id': activation_key['id'], 'host-id': host['id'], }, output_format='json') self.assertNotIn( DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in host_subscriptions] ) # upload the manifest again self._upload_manifest(self.org['id']) # ensure that the subscription was not auto attached ak_subs = ActivationKey.subscriptions({ 'organization-id': self.org['id'], 'id': activation_key['id'], }, output_format='json') self.assertNotIn( DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs]) for host in hosts: host_subscriptions = ActivationKey.subscriptions({ 'organization-id': self.org['id'], 'id': activation_key['id'], 'host-id': host['id'], }, output_format='json') self.assertNotIn( DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in host_subscriptions] ) # restore from the saved activation key and content hosts # subscriptions CSV_.activation_keys({ 'file': ak_file_path, 'organization': self.org['name'], 'itemized-subscriptions': True, }) CSV_.content_hosts({ 'file': ch_file_path, 'organization': self.org['name'], 'itemized-subscriptions': True, }) # ensure that the subscriptions has been restored ak_subs = ActivationKey.subscriptions({ 'organization-id': self.org['id'], 'id': activation_key['id'], }, output_format='json') self.assertIn( DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs]) for host in hosts: host_subscriptions = ActivationKey.subscriptions({ 'organization-id': self.org['id'], 'id': activation_key['id'], 'host-id': host['id'], }, output_format='json') self.assertIn( DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in host_subscriptions] )
def test_positive_restore_ak_and_content_hosts_subscriptions(self): """Restore activation key and content hosts subscriptions :id: a44fdeda-9c8c-4316-85b4-a9b6b9f1ffdb :customerscenario: true :steps: 1. Setup activation key , lifecycle environment and content view with RH repository 2. Add RH subscription to activation key 3. Setup hosts (minimum two) and subscribe them to activation key 4. Attach RH subscription to the created content hosts 5. export the activation key and content hosts subscriptions 6. Delete the subscription manifest 7. Ensure that the activation key and content hosts subscriptions does not exist 8. Upload the subscription manifest 9. Ensure the activation key and content hosts subscriptions does not exist 10. Restore the activation key and content hosts subscriptions :expectedresults: activation key and content hosts subscriptions restored :CaseImportance: Critical """ lce = make_lifecycle_environment({'organization-id': self.org['id']}) activation_key = make_activation_key({ 'organization-id': self.org['id'], 'lifecycle-environment-id': lce['id'], }) ActivationKey.update({ 'organization-id': self.org['id'], 'id': activation_key['id'], 'auto-attach': 'false', }) setup_org_for_a_rh_repo( { 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], 'repository': REPOS['rhst7']['name'], 'organization-id': self.org['id'], 'lifecycle-environment-id': lce['id'], 'activationkey-id': activation_key['id'], }, force_use_cdn=True) org_subs = Subscription.list({u'organization-id': self.org['id']}) default_subscription_id = None for sub in org_subs: if sub['name'] == DEFAULT_SUBSCRIPTION_NAME: default_subscription_id = sub['id'] break self.assertIsNotNone(default_subscription_id, msg='Default subscription not found') ak_subs = ActivationKey.subscriptions( { 'organization-id': self.org['id'], 'id': activation_key['id'], }, output_format='json') self.assertIn(DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs]) with VirtualMachine() as client1, VirtualMachine() as client2: hosts = [] for client in [client1, client2]: client.install_katello_ca() client.register_contenthost( self.org['label'], activation_key=activation_key['name']) self.assertTrue(client.subscribed) host = Host.info({'name': client.hostname}) hosts.append(host) Host.subscription_attach({ 'host-id': host['id'], 'subscription-id': default_subscription_id, }) host_subscriptions = ActivationKey.subscriptions( { 'organization-id': self.org['id'], 'id': activation_key['id'], 'host-id': host['id'], }, output_format='json') self.assertIn(DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in host_subscriptions]) # export the current activations and content hosts subscriptions ak_file_path = '/tmp/ak_{0}.csv'.format(self.org['label']) ch_file_path = '/tmp/content_hosts_{0}.csv'.format( self.org['label']) CSV_.activation_keys({ 'export': True, 'file': ak_file_path, 'organization': self.org['name'], 'itemized-subscriptions': True, }) CSV_.content_hosts({ 'export': True, 'file': ch_file_path, 'organization': self.org['name'], 'itemized-subscriptions': True, }) # delete the manifest Subscription.delete_manifest({'organization-id': self.org['id']}) # ensure that the subscription does not exist any more ak_subs = ActivationKey.subscriptions( { 'organization-id': self.org['id'], 'id': activation_key['id'], }, output_format='json') self.assertNotIn(DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs]) for host in hosts: host_subscriptions = ActivationKey.subscriptions( { 'organization-id': self.org['id'], 'id': activation_key['id'], 'host-id': host['id'], }, output_format='json') self.assertNotIn(DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in host_subscriptions]) # upload the manifest again self._upload_manifest(self.org['id']) # ensure that the subscription was not auto attached ak_subs = ActivationKey.subscriptions( { 'organization-id': self.org['id'], 'id': activation_key['id'], }, output_format='json') self.assertNotIn(DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs]) for host in hosts: host_subscriptions = ActivationKey.subscriptions( { 'organization-id': self.org['id'], 'id': activation_key['id'], 'host-id': host['id'], }, output_format='json') self.assertNotIn(DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in host_subscriptions]) # restore from the saved activation key and content hosts # subscriptions CSV_.activation_keys({ 'file': ak_file_path, 'organization': self.org['name'], 'itemized-subscriptions': True, }) CSV_.content_hosts({ 'file': ch_file_path, 'organization': self.org['name'], 'itemized-subscriptions': True, }) # ensure that the subscriptions has been restored ak_subs = ActivationKey.subscriptions( { 'organization-id': self.org['id'], 'id': activation_key['id'], }, output_format='json') self.assertIn(DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in ak_subs]) for host in hosts: host_subscriptions = ActivationKey.subscriptions( { 'organization-id': self.org['id'], 'id': activation_key['id'], 'host-id': host['id'], }, output_format='json') self.assertIn(DEFAULT_SUBSCRIPTION_NAME, [sub['name'] for sub in host_subscriptions])