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
diff --git a/neutron_tempest_plugin/api/admin/test_quotas.py b/neutron_tempest_plugin/api/admin/test_quotas.py
index 0cf474e..eb47fa5 100644
--- a/neutron_tempest_plugin/api/admin/test_quotas.py
+++ b/neutron_tempest_plugin/api/admin/test_quotas.py
@@ -87,7 +87,7 @@
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 @@
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")
diff --git a/neutron_tempest_plugin/api/test_security_groups.py b/neutron_tempest_plugin/api/test_security_groups.py
index 4f39cc6..c3b5f11 100644
--- a/neutron_tempest_plugin/api/test_security_groups.py
+++ b/neutron_tempest_plugin/api/test_security_groups.py
@@ -284,9 +284,10 @@
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
@@ -386,7 +387,8 @@
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):
@@ -438,7 +440,8 @@
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)