Introduce new helper: call_and_ignore_notfound_exc()
This new function calls a function passed as parameter and ignore
the NotFound exception if it raised.
This removes some code duplication.
Also a new `test_utils` module is introduced to tempest.lib and the
`find_test_caller` function is moved into that new module. Backward
compatibility and deprecation path are ensured and documented.
Note for the future: having a module called "misc" is not optimal because
the name is not super descriptive. (it's a detail though, but worth
mentioning imo).
Change-Id: I5a4523c20c19957bfccf2aa95157baf106b3d364
diff --git a/tempest/api/data_processing/base.py b/tempest/api/data_processing/base.py
index 164caaf..decccf3 100644
--- a/tempest/api/data_processing/base.py
+++ b/tempest/api/data_processing/base.py
@@ -19,7 +19,7 @@
from tempest import config
from tempest import exceptions
-from tempest.lib import exceptions as lib_exc
+from tempest.lib.common.utils import test_utils
import tempest.test
@@ -238,11 +238,7 @@
@staticmethod
def cleanup_resources(resource_id_list, method):
for resource_id in resource_id_list:
- try:
- method(resource_id)
- except lib_exc.NotFound:
- # ignore errors while auto removing created resource
- pass
+ test_utils.call_and_ignore_notfound_exc(method, resource_id)
@classmethod
def create_node_group_template(cls, name, plugin_name, hadoop_version,