diff --git a/ranger_tempest_plugin/tests/api/ims_base.py b/ranger_tempest_plugin/tests/api/ims_base.py index 8a3373a..8b0921f 100755 --- a/ranger_tempest_plugin/tests/api/ims_base.py +++ b/ranger_tempest_plugin/tests/api/ims_base.py @@ -14,6 +14,7 @@ # under the License. import time +import uuid from oslo_log import log as logging from ranger_tempest_plugin.tests.api import base @@ -49,6 +50,7 @@ class ImsBaseOrmTest(base.BaseOrmTest): def _get_image_params(cls, set_region=True, single_tenant=True, set_private=True, set_enabled=True): region, post_body = {}, {} + post_body["id"] = uuid.uuid4().hex post_body["name"] = data_utils.rand_name( "orm-plugin-TestTempestIms-image") diff --git a/ranger_tempest_plugin/tests/api/test_images.py b/ranger_tempest_plugin/tests/api/test_images.py index 05a8fa9..a67010d 100755 --- a/ranger_tempest_plugin/tests/api/test_images.py +++ b/ranger_tempest_plugin/tests/api/test_images.py @@ -233,16 +233,15 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): @decorators.idempotent_id('0331e02a-ab52-4341-b676-a02462244277') def test_create_image(self): post_body = self._get_image_params() + self.addCleanup( + self._del_img_validate_deletion_on_dcp_and_lcp, + post_body["id"]) # call client create_IMAGE and wait till status equals 'Success' _, body = self.client.create_image(**post_body) image = body["image"] test_image_id = image["id"] self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # do not forget to add this account to tempest cleanup - self.addCleanup( - self._del_img_validate_deletion_on_dcp_and_lcp, - test_image_id) # verify image record created successfully _, body = self.client.get_image(test_image_id) image = body["image"] @@ -254,9 +253,6 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): post_body = self._get_image_params(set_region=False) image = self._data_setup(post_body) test_image_id = image['id'] - self.addCleanup( - self._del_img_validate_deletion_on_dcp_and_lcp, - test_image_id) # setup region and change 'enabled', 'customers' properties region["name"] = self.region_id @@ -466,22 +462,23 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): self.assertEqual(image["regions"][0]["id"], post_body['id']) @decorators.idempotent_id('ae1223b5-cb75-442b-82eb-488969acc978') - def test_create_flavor_with_region_group(self): + def test_create_image_with_region_group(self): post_body = self._get_image_params() # region group region_group = {"name": "NCLargetest", "type": "group"} # update region_group to regions post_body["regions"].append(region_group) + # add image to tempest cleanup + self.addCleanup( + self._del_img_validate_deletion_on_dcp_and_lcp, + post_body["id"]) + # call client create_IMAGE and wait till status equals 'Success' _, body = self.client.create_image(**post_body) image = body["image"] test_image_id = image["id"] self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # add image to tempest cleanup - self.addCleanup( - self._del_img_validate_deletion_on_dcp_and_lcp, - test_image_id) # verify image record created successfully _, body = self.client.get_image(test_image_id) image = body["image"]