From 739e7533877adee77e763f6579ce55959c81a130 Mon Sep 17 00:00:00 2001 From: Benny Kopilov Date: Tue, 15 Mar 2022 10:35:33 +0200 Subject: [PATCH] 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 --- .../api/image/v2/admin/test_images_metadefs_namespaces.py | 1 + tempest/lib/services/image/v2/namespaces_client.py | 8 ++++++++ 2 files changed, 9 insertions(+) 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 0fe49f95ee..c411aa973a 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 @@ class MetadataNamespacesTest(base.BaseV2ImageAdminTest): 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 c0fa74a368..886ef00d6b 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 @@ class NamespacesClient(rest_client.RestClient): 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.