Fix test_basic_metadata_definition_namespaces
Current test case delete and update the namespace twice
The _cleanup_namespace was called after we delete namespace
without any waiter. cleanup code depends on the timing of
delete namespace but the same done inside the cleanup
Change-Id: Idfa444ecc8bc56a13caac2c1c3661df780f625e5
diff --git a/tempest/api/image/v2/admin/test_images_metadefs_namespaces.py b/tempest/api/image/v2/admin/test_images_metadefs_namespaces.py
index 0fe49f9..c411aa9 100644
--- a/tempest/api/image/v2/admin/test_images_metadefs_namespaces.py
+++ b/tempest/api/image/v2/admin/test_images_metadefs_namespaces.py
@@ -64,6 +64,7 @@
self.assertEqual(False, body['protected'])
# now able to delete the non-protected namespace
self.namespaces_client.delete_namespace(namespace_name)
+ self.namespaces_client.wait_for_resource_deletion(namespace_name)
def _cleanup_namespace(self, namespace_name):
body = self.namespaces_client.show_namespace(namespace_name)
diff --git a/tempest/lib/services/image/v2/namespaces_client.py b/tempest/lib/services/image/v2/namespaces_client.py
index c0fa74a..886ef00 100644
--- a/tempest/lib/services/image/v2/namespaces_client.py
+++ b/tempest/lib/services/image/v2/namespaces_client.py
@@ -16,6 +16,7 @@
from oslo_serialization import jsonutils as json
from tempest.lib.common import rest_client
+from tempest.lib import exceptions as lib_exc
class NamespacesClient(rest_client.RestClient):
@@ -60,6 +61,13 @@
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
+ def is_resource_deleted(self, id):
+ try:
+ self.show_namespace(id)
+ except lib_exc.NotFound:
+ return True
+ return False
+
def update_namespace(self, namespace, **kwargs):
"""Update a namespace.