Fix cleanup for networking quota
With the introduction of changes in [1], the tempest tests
for "neutron quota" needs to be changed. This is because,
unlike earlier, if the a tenant does not have a user-defined
quota, calling "neutron quota-delete" on that tenant will now
return 404.
[1]:https://review.openstack.org/#/c/276096/
Needed-By: I1cd91b5e06bd17f9aac97bba71228f2e5c48879b
Change-Id: I92655bd6358aabc149c8f8d279bd0ce9bc66fe64
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index 45d35cf..8b32a94 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -18,6 +18,7 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
from tempest import test
+from tempest_lib import exceptions as lib_exc
class QuotasTest(base.BaseAdminNetworkTest):
@@ -59,7 +60,7 @@
# Change quotas for tenant
quota_set = self.admin_quotas_client.update_quotas(
project_id, **new_quotas)['quota']
- self.addCleanup(self.admin_quotas_client.reset_quotas, project_id)
+ self.addCleanup(self._cleanup_quotas, project_id)
for key, value in six.iteritems(new_quotas):
self.assertEqual(value, quota_set[key])
@@ -87,3 +88,12 @@
def test_quotas(self):
new_quotas = {'network': 0, 'security_group': 0}
self._check_quotas(new_quotas)
+
+ def _cleanup_quotas(self, project_id):
+ # try to clean up the resources.If it fails, then
+ # assume that everything was already deleted, so
+ # it is OK to continue.
+ try:
+ self.admin_quotas_client.reset_quotas(project_id)
+ except lib_exc.NotFound:
+ pass