How to use _get_updated_quotas method in tempest

Best Python code snippet using tempest_python

test_quotas.py

Source:test_quotas.py Github

copy

Full Screen

...29 @classmethod30 def setup_clients(cls):31 super(QuotasAdminTestBase, cls).setup_clients()32 cls.adm_client = cls.os_admin.quotas_client33 def _get_updated_quotas(self):34 # Verify that GET shows the updated quota set of project35 project_name = data_utils.rand_name('cpu_quota_project')36 project_desc = project_name + '-desc'37 project = identity.identity_utils(self.os_admin).create_project(38 name=project_name, description=project_desc)39 project_id = project['id']40 self.addCleanup(identity.identity_utils(self.os_admin).delete_project,41 project_id)42 self.adm_client.update_quota_set(project_id, ram='5120')43 # Call show_quota_set with detail=true to cover the44 # get_quota_set_details response schema for microversion tests45 quota_set = self.adm_client.show_quota_set(46 project_id, detail=True)['quota_set']47 self.assertEqual(5120, quota_set['ram']['limit'])48 # Verify that GET shows the updated quota set of user49 user_name = data_utils.rand_name('cpu_quota_user')50 password = data_utils.rand_password()51 email = user_name + '@testmail.tm'52 user = identity.identity_utils(self.os_admin).create_user(53 username=user_name, password=password, project=project,54 email=email)55 user_id = user['id']56 self.addCleanup(identity.identity_utils(self.os_admin).delete_user,57 user_id)58 self.adm_client.update_quota_set(project_id,59 user_id=user_id,60 ram='2048')61 quota_set = self.adm_client.show_quota_set(62 project_id, user_id=user_id)['quota_set']63 self.assertEqual(2048, quota_set['ram'])64 @classmethod65 def resource_setup(cls):66 super(QuotasAdminTestBase, cls).resource_setup()67 # NOTE(afazekas): these test cases should always create and use a new68 # tenant most of them should be skipped if we can't do that69 cls.demo_tenant_id = cls.quotas_client.tenant_id70 cls.default_quota_set = set(('metadata_items', 'ram', 'key_pairs',71 'instances', 'cores',72 'server_group_members', 'server_groups'))73 if cls.is_requested_microversion_compatible('2.35'):74 cls.default_quota_set = \75 cls.default_quota_set | set(['fixed_ips', 'floating_ips',76 'security_group_rules',77 'security_groups'])78 if cls.is_requested_microversion_compatible('2.56'):79 cls.default_quota_set = \80 cls.default_quota_set | set(['injected_file_content_bytes',81 'injected_file_path_bytes',82 'injected_files'])83class QuotasAdminTestJSON(QuotasAdminTestBase):84 @decorators.idempotent_id('3b0a7c8f-cf58-46b8-a60c-715a32a8ba7d')85 def test_get_default_quotas(self):86 # Admin can get the default resource quota set for a tenant87 expected_quota_set = self.default_quota_set | set(['id'])88 quota_set = self.adm_client.show_default_quota_set(89 self.demo_tenant_id)['quota_set']90 self.assertEqual(quota_set['id'], self.demo_tenant_id)91 for quota in expected_quota_set:92 self.assertIn(quota, quota_set.keys())93 @decorators.idempotent_id('55fbe2bf-21a9-435b-bbd2-4162b0ed799a')94 def test_update_all_quota_resources_for_tenant(self):95 # Admin can update all the resource quota limits for a tenant96 default_quota_set = self.adm_client.show_default_quota_set(97 self.demo_tenant_id)['quota_set']98 new_quota_set = {'metadata_items': 256, 'ram': 10240,99 'key_pairs': 200, 'instances': 20,100 'server_groups': 20,101 'server_group_members': 20, 'cores': 2}102 if self.is_requested_microversion_compatible('2.35'):103 new_quota_set.update({'fixed_ips': 10, 'floating_ips': 20,104 'security_group_rules': 20,105 'security_groups': 20})106 if self.is_requested_microversion_compatible('2.56'):107 new_quota_set.update({'injected_file_content_bytes': 20480,108 'injected_file_path_bytes': 512,109 'injected_files': 10})110 # Update limits for all quota resources111 quota_set = self.adm_client.update_quota_set(112 self.demo_tenant_id,113 force=True,114 **new_quota_set)['quota_set']115 default_quota_set.pop('id')116 self.addCleanup(self.adm_client.update_quota_set,117 self.demo_tenant_id, **default_quota_set)118 for quota in new_quota_set:119 self.assertIn(quota, quota_set.keys())120 # TODO(afazekas): merge these test cases121 @decorators.idempotent_id('ce9e0815-8091-4abd-8345-7fe5b85faa1d')122 def test_get_updated_quotas(self):123 self._get_updated_quotas()124 @decorators.idempotent_id('389d04f0-3a41-405f-9317-e5f86e3c44f0')125 def test_delete_quota(self):126 # Admin can delete the resource quota set for a project127 project_name = data_utils.rand_name('ram_quota_project')128 project_desc = project_name + '-desc'129 project = identity.identity_utils(self.os_admin).create_project(130 name=project_name, description=project_desc)131 project_id = project['id']132 self.addCleanup(identity.identity_utils(self.os_admin).delete_project,133 project_id)134 quota_set_default = (self.adm_client.show_quota_set(project_id)135 ['quota_set'])136 ram_default = quota_set_default['ram']137 self.adm_client.update_quota_set(project_id, ram='5120')138 self.adm_client.delete_quota_set(project_id)139 quota_set_new = self.adm_client.show_quota_set(project_id)['quota_set']140 self.assertEqual(ram_default, quota_set_new['ram'])141class QuotasAdminTestV236(QuotasAdminTestBase):142 min_microversion = '2.36'143 # NOTE(gmann): This test tests the Quota APIs response schema144 # for 2.36 microversion. No specific assert or behaviour verification145 # is needed.146 @decorators.idempotent_id('4268b5c9-92e5-4adc-acf1-3a2798f3d803')147 def test_get_updated_quotas(self):148 # Checking Quota update, get, get details APIs response schema149 self._get_updated_quotas()150class QuotasAdminTestV257(QuotasAdminTestBase):151 min_microversion = '2.57'152 # NOTE(gmann): This test tests the Quota APIs response schema153 # for 2.57 microversion. No specific assert or behaviour verification154 # is needed.155 @decorators.idempotent_id('e641e6c6-e86c-41a4-9e5c-9493c0ae47ad')156 def test_get_updated_quotas(self):157 # Checking Quota update, get, get details APIs response schema158 self._get_updated_quotas()159class QuotaClassesAdminTestJSON(base.BaseV2ComputeAdminTest):160 """Tests the os-quota-class-sets API to update default quotas."""161 def setUp(self):162 # All test cases in this class need to externally lock on doing163 # anything with default quota values.164 self.useFixture(fixtures.LockFixture('compute_quotas'))165 super(QuotaClassesAdminTestJSON, self).setUp()166 @classmethod167 def resource_setup(cls):168 super(QuotaClassesAdminTestJSON, cls).resource_setup()169 cls.adm_client = cls.os_admin.quota_classes_client170 def _restore_default_quotas(self, original_defaults):171 LOG.debug("restoring quota class defaults")172 self.adm_client.update_quota_class_set('default', **original_defaults)...

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