How to use show_quota_set method in tempest

Best Python code snippet using tempest_python

test_volume_quotas.py

Source:test_volume_quotas.py Github

copy

Full Screen

...27 cls.demo_tenant_id = cls.os.credentials.tenant_id28 cls.alt_client = cls.os_alt.volumes_client29 @test.idempotent_id('59eada70-403c-4cef-a2a3-a8ce2f1b07a0')30 def test_list_quotas(self):31 quotas = (self.admin_quotas_client.show_quota_set(self.demo_tenant_id)32 ['quota_set'])33 for key in QUOTA_KEYS:34 self.assertIn(key, quotas)35 @test.idempotent_id('2be020a2-5fdd-423d-8d35-a7ffbc36e9f7')36 def test_list_default_quotas(self):37 quotas = self.admin_quotas_client.show_default_quota_set(38 self.demo_tenant_id)['quota_set']39 for key in QUOTA_KEYS:40 self.assertIn(key, quotas)41 @test.idempotent_id('3d45c99e-cc42-4424-a56e-5cbd212b63a6')42 def test_update_all_quota_resources_for_tenant(self):43 # Admin can update all the resource quota limits for a tenant44 default_quota_set = self.admin_quotas_client.show_default_quota_set(45 self.demo_tenant_id)['quota_set']46 new_quota_set = {'gigabytes': 1009,47 'volumes': 11,48 'snapshots': 11}49 # Update limits for all quota resources50 quota_set = self.admin_quotas_client.update_quota_set(51 self.demo_tenant_id,52 **new_quota_set)['quota_set']53 cleanup_quota_set = dict(54 (k, v) for k, v in six.iteritems(default_quota_set)55 if k in QUOTA_KEYS)56 self.addCleanup(self.admin_quotas_client.update_quota_set,57 self.demo_tenant_id, **cleanup_quota_set)58 # test that the specific values we set are actually in59 # the final result. There is nothing here that ensures there60 # would be no other values in there.61 self.assertDictContainsSubset(new_quota_set, quota_set)62 @test.idempotent_id('18c51ae9-cb03-48fc-b234-14a19374dbed')63 def test_show_quota_usage(self):64 quota_usage = self.admin_quotas_client.show_quota_set(65 self.os_adm.credentials.tenant_id,66 params={'usage': True})['quota_set']67 for key in QUOTA_KEYS:68 self.assertIn(key, quota_usage)69 for usage_key in QUOTA_USAGE_KEYS:70 self.assertIn(usage_key, quota_usage[key])71 @test.idempotent_id('ae8b6091-48ad-4bfa-a188-bbf5cc02115f')72 def test_quota_usage(self):73 quota_usage = self.admin_quotas_client.show_quota_set(74 self.demo_tenant_id, params={'usage': True})['quota_set']75 volume = self.create_volume()76 self.addCleanup(self.delete_volume,77 self.admin_volume_client, volume['id'])78 new_quota_usage = self.admin_quotas_client.show_quota_set(79 self.demo_tenant_id, params={'usage': True})['quota_set']80 self.assertEqual(quota_usage['volumes']['in_use'] + 1,81 new_quota_usage['volumes']['in_use'])82 self.assertEqual(quota_usage['gigabytes']['in_use'] +83 volume["size"],84 new_quota_usage['gigabytes']['in_use'])85 @test.idempotent_id('874b35a9-51f1-4258-bec5-cd561b6690d3')86 def test_delete_quota(self):87 # Admin can delete the resource quota set for a project88 project_name = data_utils.rand_name('quota_tenant')89 description = data_utils.rand_name('desc_')90 project = self.identity_utils.create_project(project_name,91 description=description)92 project_id = project['id']93 self.addCleanup(self.identity_utils.delete_project, project_id)94 quota_set_default = self.admin_quotas_client.show_default_quota_set(95 project_id)['quota_set']96 volume_default = quota_set_default['volumes']97 self.admin_quotas_client.update_quota_set(98 project_id, volumes=(int(volume_default) + 5))99 self.admin_quotas_client.delete_quota_set(project_id)100 quota_set_new = (self.admin_quotas_client.show_quota_set(project_id)101 ['quota_set'])102 self.assertEqual(volume_default, quota_set_new['volumes'])103 @test.idempotent_id('8911036f-9d54-4720-80cc-a1c9796a8805')104 def test_quota_usage_after_volume_transfer(self):105 # Create a volume for transfer106 volume = self.create_volume()107 self.addCleanup(self.delete_volume,108 self.admin_volume_client, volume['id'])109 # List of tenants quota usage pre-transfer110 primary_quota = self.admin_quotas_client.show_quota_set(111 self.demo_tenant_id, params={'usage': True})['quota_set']112 alt_quota = self.admin_quotas_client.show_quota_set(113 self.alt_client.tenant_id, params={'usage': True})['quota_set']114 # Creates a volume transfer115 transfer = self.volumes_client.create_volume_transfer(116 volume_id=volume['id'])['transfer']117 transfer_id = transfer['id']118 auth_key = transfer['auth_key']119 # Accepts a volume transfer120 self.alt_client.accept_volume_transfer(121 transfer_id, auth_key=auth_key)['transfer']122 # Verify volume transferred is available123 waiters.wait_for_volume_status(124 self.alt_client, volume['id'], 'available')125 # List of tenants quota usage post transfer126 new_primary_quota = self.admin_quotas_client.show_quota_set(127 self.demo_tenant_id, params={'usage': True})['quota_set']128 new_alt_quota = self.admin_quotas_client.show_quota_set(129 self.alt_client.tenant_id, params={'usage': True})['quota_set']130 # Verify tenants quota usage was updated131 self.assertEqual(primary_quota['volumes']['in_use'] -132 new_primary_quota['volumes']['in_use'],133 new_alt_quota['volumes']['in_use'] -134 alt_quota['volumes']['in_use'])135 self.assertEqual(alt_quota['gigabytes']['in_use'] +136 volume['size'],137 new_alt_quota['gigabytes']['in_use'])138 self.assertEqual(primary_quota['gigabytes']['in_use'] -139 volume['size'],140 new_primary_quota['gigabytes']['in_use'])141class VolumeQuotasAdminV1TestJSON(BaseVolumeQuotasAdminV2TestJSON):142 _api_version = 1

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful