Add call_and_ignore_notfound_exc to Keystone base
Keystone base class methods don't include
call_and_ignore_notfound_exc during cleanup. If a test
deletes something, cleanup causes a failure.
Change-Id: Ic36237f28188188eb1de8ce1e5c80c3b4a618ca0
Closes-Bug: #1665475
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 80e7936..344779c 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -15,6 +15,7 @@
from tempest.common.utils import data_utils
from tempest import config
+from tempest.lib.common.utils import test_utils
import tempest.test
CONF = config.CONF
@@ -72,7 +73,9 @@
kwargs['password'] = user_password
user = self.users_client.create_user(**kwargs)['user']
# Delete the user at the end of the test
- self.addCleanup(self.users_client.delete_user, user['id'])
+ self.addCleanup(
+ test_utils.call_and_ignore_notfound_exc,
+ self.users_client.delete_user, user['id'])
return user
def setup_test_role(self, domain_id=None):
@@ -83,7 +86,9 @@
role = self.roles_client.create_role(**params)['role']
# Delete the role at the end of the test
- self.addCleanup(self.roles_client.delete_role, role['id'])
+ self.addCleanup(
+ test_utils.call_and_ignore_notfound_exc,
+ self.roles_client.delete_role, role['id'])
return role
@@ -152,7 +157,9 @@
name=data_utils.rand_name('test_tenant'),
description=data_utils.rand_name('desc'))['tenant']
# Delete the tenant at the end of the test
- self.addCleanup(self.tenants_client.delete_tenant, tenant['id'])
+ self.addCleanup(
+ test_utils.call_and_ignore_notfound_exc,
+ self.tenants_client.delete_tenant, tenant['id'])
return tenant
@@ -246,12 +253,16 @@
name=data_utils.rand_name('test_project'),
description=data_utils.rand_name('desc'))['project']
# Delete the project at the end of the test
- self.addCleanup(self.projects_client.delete_project, project['id'])
+ self.addCleanup(
+ test_utils.call_and_ignore_notfound_exc,
+ self.projects_client.delete_project, project['id'])
return project
def setup_test_domain(self):
"""Set up a test domain."""
domain = self.create_domain()
# Delete the domain at the end of the test
- self.addCleanup(self.delete_domain, domain['id'])
+ self.addCleanup(
+ test_utils.call_and_ignore_notfound_exc,
+ self.delete_domain, domain['id'])
return domain