Add test for extension "quota-check-limit-default"
This new test is checking that, by default, the quota engine will check the resource usage before setting the quota. If the new quota is below the resource usage, an exception is returned. This patch is also adding the flag "force=True" in other tests setting quotas for resources; these tests do not need the quota engine to verify the current resource usage. Related-Bug: #1953170 Change-Id: Ia193cd5a2aacc4243b5807eb7757b32e66f12365
This commit is contained in:
parent
0cb985055b
commit
4f3dbe4fea
@ -87,7 +87,7 @@ class QuotasTest(QuotasTestBase):
|
||||
new_quotas = {'network': 0, 'security_group': 0}
|
||||
|
||||
# Change quotas for tenant
|
||||
quota_set = self._setup_quotas(tenant_id, **new_quotas)
|
||||
quota_set = self._setup_quotas(tenant_id, force=True, **new_quotas)
|
||||
for key, value in new_quotas.items():
|
||||
self.assertEqual(value, quota_set[key])
|
||||
|
||||
@ -112,6 +112,23 @@ class QuotasTest(QuotasTestBase):
|
||||
for q in non_default_quotas['quotas']:
|
||||
self.assertNotEqual(tenant_id, q['tenant_id'])
|
||||
|
||||
@decorators.idempotent_id('43d01327-d8be-4773-a8f0-1d2e9664fda2')
|
||||
@decorators.attr(type='gate')
|
||||
@utils.requires_ext(extension='quota-check-limit-default',
|
||||
service='network')
|
||||
def test_quotas_force_false(self):
|
||||
project_id = self.create_project()['id']
|
||||
self._create_network(project_id)
|
||||
|
||||
new_quotas = {'network': 0}
|
||||
# force=false (by default)
|
||||
self.assertRaises(lib_exc.BadRequest, self.admin_client.update_quotas,
|
||||
project_id, **new_quotas)
|
||||
|
||||
new_quotas['network'] = 100
|
||||
quota_set = self._setup_quotas(project_id, **new_quotas)
|
||||
self.assertEqual(new_quotas['network'], quota_set['network'])
|
||||
|
||||
@decorators.idempotent_id('e974b5ba-090a-452c-a578-f9710151d9fc')
|
||||
@decorators.attr(type='gate')
|
||||
@utils.requires_ext(extension="quota_details", service="network")
|
||||
|
@ -281,9 +281,10 @@ class BaseSecGroupQuota(base.BaseAdminNetworkTest):
|
||||
def _set_quota(self, val, resource):
|
||||
res_quota = self._get_quota(resource)
|
||||
project_id = self.client.project_id
|
||||
self.admin_client.update_quotas(project_id, **{resource: val})
|
||||
self.admin_client.update_quotas(project_id, **{resource: val,
|
||||
'force': True})
|
||||
self.addCleanup(self.admin_client.update_quotas,
|
||||
project_id, **{resource: res_quota})
|
||||
project_id, **{resource: res_quota, 'force': True})
|
||||
|
||||
def _get_quota(self, resource):
|
||||
project_id = self.client.project_id
|
||||
@ -383,7 +384,8 @@ class BaseSecGroupRulesQuota(base.BaseAdminNetworkTest):
|
||||
def _set_sg_rules_quota(self, val):
|
||||
project_id = self.client.project_id
|
||||
self.admin_client.update_quotas(project_id,
|
||||
**{'security_group_rule': val})
|
||||
**{'security_group_rule': val,
|
||||
'force': True})
|
||||
LOG.info('Trying to update security group rule quota {} '.format(val))
|
||||
|
||||
def _get_sg_rules_quota(self):
|
||||
@ -435,7 +437,8 @@ class SecGroupRulesQuotaTest(BaseSecGroupRulesQuota):
|
||||
sg_rules_quota = self._get_sg_rules_quota()
|
||||
project_id = self.client.project_id
|
||||
self.addCleanup(self.admin_client.update_quotas,
|
||||
project_id, **{'security_group_rule': sg_rules_quota})
|
||||
project_id, **{'security_group_rule': sg_rules_quota,
|
||||
'force': True})
|
||||
values = [-1, 0, 10, 2147483647]
|
||||
for value in values:
|
||||
self._set_sg_rules_quota(value)
|
||||
|
Loading…
Reference in New Issue
Block a user