From aadf73a575d39ac0b89f4acbc00d8e1a7076367c Mon Sep 17 00:00:00 2001 From: jh629g Date: Thu, 12 Sep 2019 15:02:15 -0500 Subject: [PATCH] Create Auth Skipcheck Ranger currently has issue authing with certain credentials against some keystone environments. This patchset introduces a skipcheck if it is found that credentials provided do not allow the user to execute tests against the site. Change-Id: I5e3daff3b6ed6b5c4731320f82bb929d3caa6e07 --- .zuul.yaml | 29 ++----- flake8rc | 2 +- ranger_tempest_plugin/config.py | 3 + ranger_tempest_plugin/services/base_client.py | 1 - ranger_tempest_plugin/services/rms_client.py | 2 +- ranger_tempest_plugin/tests/api/base.py | 20 ++++- ranger_tempest_plugin/tests/api/cms_base.py | 3 +- .../tests/api/test_customers.py | 61 +++++++++------ .../tests/api/test_flavors.py | 65 +++++++++++----- .../tests/api/test_images.py | 75 +++++++++++++------ 10 files changed, 169 insertions(+), 92 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 12e4c8a..226f285 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,17 +1,16 @@ - project: - name: x/ranger-tempest-plugin check: jobs: + - openstack-tox-py36 + - openstack-tox-pep8 - ranger-tempest-sanity - - ranger-tox-py27 - - ranger-tox-pep8 - - ranger-tox-pylint + - ranger-pylint gate: jobs: + - openstack-tox-py36 + - openstack-tox-pep8 - ranger-tempest-sanity - - ranger-tox-py27 - - ranger-tox-pep8 - - ranger-tox-pylint + - ranger-pylint - job: name: ranger-tempest-sanity parent: openstack-tox @@ -20,21 +19,7 @@ vars: tox_envlist: 'tempest-sanity' - job: - name: ranger-tox-py27 - parent: openstack-tox - voting: true - timeout: 900 - vars: - tox_envlist: 'py27' -- job: - name: ranger-tox-pep8 - parent: openstack-tox - voting: true - timeout: 900 - vars: - tox_envlist: 'pep8' -- job: - name: ranger-tox-pylint + name: ranger-pylint parent: openstack-tox voting: true timeout: 900 diff --git a/flake8rc b/flake8rc index 09ba5f9..7157d0e 100644 --- a/flake8rc +++ b/flake8rc @@ -1,5 +1,5 @@ [flake8] -ignore = E125,E123,E129 +ignore = E125,E123,E129,H903 show-source = False exclude = .git, diff --git a/ranger_tempest_plugin/config.py b/ranger_tempest_plugin/config.py index 0da86c8..a673a91 100755 --- a/ranger_tempest_plugin/config.py +++ b/ranger_tempest_plugin/config.py @@ -57,6 +57,9 @@ ORM_GROUP_OPTIONS = [ cfg.StrOpt("domain", default='Default', help="Domain used for Ranger tempest testing"), + cfg.StrOpt("alt_region_available", + default=False, + help="Alt region for ranger tempest testing"), cfg.StrOpt("region_alt", default='', help="Provide alternate region for creating" diff --git a/ranger_tempest_plugin/services/base_client.py b/ranger_tempest_plugin/services/base_client.py index 210f678..4607e1c 100755 --- a/ranger_tempest_plugin/services/base_client.py +++ b/ranger_tempest_plugin/services/base_client.py @@ -39,7 +39,6 @@ class RangerClientBase(rest_client.RestClient): timeout = 10 - # def get_keystone_ep(rms_url, region_name): def get_keystone_ep(self): """Get the Keystone EP from tempest conf.""" identity_url = CONF.identity.uri_v3 or "" diff --git a/ranger_tempest_plugin/services/rms_client.py b/ranger_tempest_plugin/services/rms_client.py index bde727b..2a8c9bc 100755 --- a/ranger_tempest_plugin/services/rms_client.py +++ b/ranger_tempest_plugin/services/rms_client.py @@ -113,7 +113,7 @@ class RmsClient(base_client.RangerClientBase): def list_regions(self, filter=None): uri = '%s/%s/orm/regions' % (self.rms_url, self.version) if filter is not None: - uri += '?' + urllib.urlencode(filter) + uri += '?' + urllib.parse.urlencode(filter) return self.get_request(uri, schema.list_region) def delete_region(self, region_id): diff --git a/ranger_tempest_plugin/tests/api/base.py b/ranger_tempest_plugin/tests/api/base.py index 2f97561..0f29917 100755 --- a/ranger_tempest_plugin/tests/api/base.py +++ b/ranger_tempest_plugin/tests/api/base.py @@ -15,7 +15,7 @@ from oslo_log import log as logging from ranger_tempest_plugin import clients - +from ranger_tempest_plugin.services import base_client from tempest import config from tempest import test @@ -25,17 +25,31 @@ LOG = logging.getLogger(__name__) class BaseOrmTest(test.BaseTestCase): - credentials = ['admin', 'primary', 'alt'] - client_manager = clients.OrmClientManager + credentials = ['admin', 'primary', 'alt'] build_timeout = 120 build_interval = 10 + @classmethod + def setup_credentials(cls): + cls.set_network_resources(network=False, subnet=False, router=False) + super(BaseOrmTest, cls).setup_credentials() + @classmethod def setup_clients(cls): super(BaseOrmTest, cls).setup_clients() cls.identity_client = cls.os_admin.projects_client + try: + auth_agent = \ + base_client.RangerAuthProvider(cls.os_primary.credentials) + auth_agent.auth_request("GET", + CONF.ranger.ranger_rms_base_url, + headers=[]) + except Exception as auth_exception: + skip_msg = ("Ranger was unable to authenticate against keystone." + "due to exception: %s" % str(auth_exception)) + raise cls.skipException(skip_msg) @classmethod def skip_checks(cls): diff --git a/ranger_tempest_plugin/tests/api/cms_base.py b/ranger_tempest_plugin/tests/api/cms_base.py index 80c596e..fe0367b 100755 --- a/ranger_tempest_plugin/tests/api/cms_base.py +++ b/ranger_tempest_plugin/tests/api/cms_base.py @@ -92,7 +92,7 @@ class CmsBaseOrmTest(base.BaseOrmTest): region["users"] = [user] if region_users else [] regions = [region] metadata['my_server_name'] = cust_name - metadata['ocx_cust'] = random.randint(0, 999999999) + metadata['ocx_cust'] = str(random.randint(0, 999999999)) payload["description"] = cust_name payload["enabled"] = True if enabled else False payload["name"] = cust_name @@ -254,7 +254,6 @@ class CmsBaseOrmTest(base.BaseOrmTest): _, region = cls.os_admin.rms_client.get_region(rname) region_id = region["id"] cls.client.delete_region_from_customer(customer_id, region_id) - # cls._wait_for_cust_status_on_dcp(customer_id, "no regions") cls._wait_for_status(customer_id, "no regions") _, body = cls.client.get_customer(customer_id) regions_on_customer = [rgn for rgn in body["regions"]] diff --git a/ranger_tempest_plugin/tests/api/test_customers.py b/ranger_tempest_plugin/tests/api/test_customers.py index 9c93102..009ac05 100755 --- a/ranger_tempest_plugin/tests/api/test_customers.py +++ b/ranger_tempest_plugin/tests/api/test_customers.py @@ -18,6 +18,8 @@ import random from ranger_tempest_plugin.data_utils import data_utils from ranger_tempest_plugin.tests.api import cms_base from tempest import config +from tempest import test + from tempest.lib import decorators from tempest.lib import exceptions @@ -60,7 +62,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): 'status': status, } ) - self.addCleanup(self.os_admin.rms_client.delete_region, region_name) + test.addClassResourceCleanup( + self.os_admin.rms_client.delete_region, + region_name) return region @decorators.idempotent_id('6072c438-1e45-4c0b-97a6-e5127bd33d89') @@ -120,8 +124,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): post_body = self._get_customer_params(enabled=False) test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( **post_body) - self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, - test_customer_id) + test.addClassResourceCleanup( + self._del_cust_validate_deletion_on_dcp_and_lcp, + test_customer_id) # update enabled status from 'False' to 'True' and validate update OK _, body = self.client.get_customer(test_customer_id) @@ -139,8 +144,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): region_users=False) test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( **post_body) - self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, - test_customer_id) + test.addClassResourceCleanup( + self._del_cust_validate_deletion_on_dcp_and_lcp, + test_customer_id) _, body = self.client.get_customer(test_customer_id) self.assertFalse(body['users']) self.assertFalse(body["regions"][0]['users']) @@ -164,8 +170,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): default_user_id = post_body["users"][0]["id"] test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( **post_body) - self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, - test_customer_id) + test.addClassResourceCleanup( + self._del_cust_validate_deletion_on_dcp_and_lcp, + test_customer_id) _, body = self.client.get_customer(test_customer_id) self.assertEqual(default_user_id, body['users'][0]['id']) self.assertIn(default_user_id, @@ -189,8 +196,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): default_user_id = post_body["users"][0]["id"] test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( **post_body) - self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, - test_customer_id) + test.addClassResourceCleanup( + self._del_cust_validate_deletion_on_dcp_and_lcp, + test_customer_id) _, body = self.client.get_customer(test_customer_id) self.assertIn(default_user_id, [x['id'] for x in body['users']]) self.assertEqual(body['users'], body['regions'][0]['users']) @@ -218,8 +226,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): default_users=False) test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( **post_body) - self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, - test_customer_id) + test.addClassResourceCleanup( + self._del_cust_validate_deletion_on_dcp_and_lcp, + test_customer_id) _, body = self.client.get_customer(test_customer_id) # confirm that the region users body is empty after data creation self.assertFalse(body["regions"][0]["users"]) @@ -243,8 +252,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): region_user_id = post_body["regions"][0]["users"][0]["id"] test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( **post_body) - self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, - test_customer_id) + test.addResourceCleanup( + self._del_cust_validate_deletion_on_dcp_and_lcp, + test_customer_id) _, body = self.client.get_customer(test_customer_id) self.assertTrue(body["regions"][0]["users"]) @@ -262,8 +272,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): post_body = self._get_customer_params() test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( **post_body) - self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, - test_customer_id) + test.addClassResourceCleanup( + self._del_cust_validate_deletion_on_dcp_and_lcp, + test_customer_id) # update region user then confirm that update is successful put_region_user = self._get_user_params(alt=True) @@ -314,8 +325,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): region_name = post_body["regions"][0]["name"] test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( **post_body) - self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, - test_customer_id) + test.addClassResourceCleanup( + self._del_cust_validate_deletion_on_dcp_and_lcp, + test_customer_id) _, customer = self.client.get_customer(test_customer_id) self.assertTrue(customer["regions"]) _, body = self.client.delete_region_from_customer(test_customer_id, @@ -330,8 +342,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): test_cust_name = post_body['name'] _, body = self.client.create_customer(**post_body) test_customer_id = body['customer']['id'] - self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, - test_customer_id) + test.addClassResourceCleanup( + self._del_cust_validate_deletion_on_dcp_and_lcp, + test_customer_id) self._wait_for_status(test_customer_id, 'Success') _, body = self.client.get_customer(test_cust_name) self.assertIn(test_customer_id, body['uuid']) @@ -383,7 +396,10 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): resp, body = self.client.create_customer(**cust_body) self.assertIn('id', body['customer']) test_customer_id = body['customer']['id'] - self.addCleanup(self._delete_customer, test_customer_id, region_name) + test.addClassResourceCleanup( + self._delete_customer, + test_customer_id, + region_name) _, body = self.client.get_customer(test_customer_id) # since region is building it will give error # Notification to ORD failed @@ -400,7 +416,10 @@ class TestTempestCms(cms_base.CmsBaseOrmTest): resp, body = self.client.create_customer(**cust_body) self.assertIn('id', body['customer']) test_customer_id = body['customer']['id'] - self.addCleanup(self._delete_customer, test_customer_id, region_name) + test.addClassResourceCleanup( + self._delete_customer, + test_customer_id, + region_name) # since region is maintenance it will give error # Notification to ORD failed self.assertEqual(body['status'], 'Error') diff --git a/ranger_tempest_plugin/tests/api/test_flavors.py b/ranger_tempest_plugin/tests/api/test_flavors.py index abd7a63..5cc1d25 100755 --- a/ranger_tempest_plugin/tests/api/test_flavors.py +++ b/ranger_tempest_plugin/tests/api/test_flavors.py @@ -19,6 +19,7 @@ import uuid from ranger_tempest_plugin import data_utils as orm_data_utils from ranger_tempest_plugin.tests.api import fms_base from tempest import config +from tempest import test from tempest.lib import decorators from tempest.lib import exceptions @@ -75,14 +76,17 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): **orm_data_utils.rand_region_group([CONF.identity.region]) ) group_id = body['group']['id'] - self.addCleanup(self.rms_client.delete_region_group, group_id) + test.addClassResourceCleanup( + self.rms_client.delete_region_group, + group_id) return group_id def _data_setup(self, post_body): flavor = self._create_flv_and_validate_creation_on_dcp_and_lcp( **post_body) - self.addCleanup(self._del_flv_and_validate_deletion_on_dcp_and_lcp, - flavor["id"]) + test.addClassResourceCleanup( + self._del_flv_and_validate_deletion_on_dcp_and_lcp, + flavor["id"]) return flavor def _exec_tags_function(self, flavor_id, req_json, action, para): @@ -135,9 +139,10 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): test_flvr_id = body["flavor"]['id'] self._wait_for_flavor_status_on_dcp(test_flvr_id, 'Success') - # do not forget to add this account to addCleanUp - self.addCleanup(self._del_flv_and_validate_deletion_on_dcp_and_lcp, - test_flvr_id) + # add flavor to tempest cleanup + test.addClassResourceCleanup( + self._del_flv_and_validate_deletion_on_dcp_and_lcp, + test_flvr_id) # verify flavor record created successfully flavor = self._get_flavor_details(test_flvr_id) @@ -147,9 +152,10 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): @classmethod def resource_cleanup(cls): - # cls.delete_role_to_admin() flavor_id = cls.flavor['id'] - cls._del_flv_and_validate_deletion_on_dcp_and_lcp(flavor_id) + test.addClassResourceCleanup( + cls._del_flv_and_validate_deletion_on_dcp_and_lcp, + flavor_id) super(TestTempestFms, cls).resource_cleanup() def _create_region(self, status='functional'): @@ -160,7 +166,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): 'status': status, } ) - self.addCleanup(self.os_admin.rms_client.delete_region, region_name) + test.addClassResourceCleanup( + self.os_admin.rms_client.delete_region, + region_name) return region def _delete_flavor(self, flvr_id): @@ -236,7 +244,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): replace_tag_body = {"tags": {"ee": "ff", "gg": "hh"}} self._exec_tags_function(self.flavor_id, replace_tag_body, 'update', None) - self.addCleanup(self._restore_default_tags, self.flavor_id) + test.addClassResourceCleanup( + self._restore_default_tags, + self.flavor_id) _, tag_body = self.client.get_tags(self.flavor_id) self.assertDictEqual(replace_tag_body.get("tags"), tag_body.get("tags")) @@ -261,7 +271,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): # test delete_all_tags command - run get_tag again and confirm # that the tag dict is now empty self._exec_tags_function(self.flavor_id, None, 'delete', None) - self.addCleanup(self._restore_default_tags, self.flavor_id) + test.addClassResourceCleanup( + self._restore_default_tags, + self.flavor_id) _, tag_body = self.client.get_tags(self.flavor_id) # assert that tag_body contains nothing self.assertFalse(tag_body["tags"]) @@ -310,9 +322,14 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): def test_update_flvr_extra_specs(self): # add custom extra spec using update_extra_spec replace_es_body = {"os_extra_specs": {"z": "zebra", "x": "xray"}} - self._exec_ex_spec_function(self.flavor_id, replace_es_body, 'update', - None) - self.addCleanup(self._restore_custom_es, self.flavor_id) + self._exec_ex_spec_function( + self.flavor_id, + replace_es_body, + 'update', + None) + test.addClassResourceCleanup( + self._restore_custom_es, + self.flavor_id) # assert extra specs update results match expected _, flvr_ex_specs = self.client.get_extra_specs(self.flavor_id) @@ -342,7 +359,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): # run delete ALL extra specs - note that this will only # delete custom extra specs, NOT the default extra specs self._exec_ex_spec_function(self.flavor_id, None, 'delete', None) - self.addCleanup(self._restore_custom_es, self.flavor_id) + test.addClassResourceCleanup( + self._restore_custom_es, + self.flavor_id) _, flvr_ex_specs = self.client.get_extra_specs(self.flavor_id) # assert that flavor extra specs now contains only # the default extra specs @@ -390,7 +409,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): test_flvr_id = flavor['id'] # delete the data and do get_flavor to ensure 404-NotFound response - self._del_flv_and_validate_deletion_on_dcp_and_lcp(test_flvr_id) + test.addResourceCleanup( + self._del_flv_and_validate_deletion_on_dcp_and_lcp, + test_flvr_id) self.assertRaises(exceptions.NotFound, self.client.get_flavor, test_flvr_id) @@ -455,7 +476,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): **orm_data_utils.rand_region_group([CONF.identity.region]) ) group_id = body['group']['id'] - self.addCleanup(self.rms_client.delete_region_group, group_id) + test.addClassResourceCleanup( + self.rms_client.delete_region_group, + group_id) post_body = self._get_flavor_params() region_group = {'name': group_id, 'type': 'group'} @@ -541,7 +564,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): self.assertIn('id', body['flavor']) test_flvr_id = body['flavor']['id'] - self.addCleanup(self._delete_flavor, test_flvr_id) + test.addClassResourceCleanup( + self._delete_flavor, + test_flvr_id) flavor = self._get_flavor_details(test_flvr_id) self.assertEqual(flavor['id'], test_flvr_id) @@ -557,7 +582,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): _, body = self.client.create_flavor(**post_body) self.assertIn('id', body['flavor']) test_flvr_id = body['flavor']['id'] - self.addCleanup(self._delete_flavor, test_flvr_id) + test.addClassResourceCleanup( + self._delete_flavor, + test_flvr_id) flavor = self._get_flavor_details(test_flvr_id) self.assertEqual(flavor['id'], test_flvr_id) diff --git a/ranger_tempest_plugin/tests/api/test_images.py b/ranger_tempest_plugin/tests/api/test_images.py index d918d7c..e827569 100755 --- a/ranger_tempest_plugin/tests/api/test_images.py +++ b/ranger_tempest_plugin/tests/api/test_images.py @@ -1,5 +1,5 @@ # Copyright 2016 AT&T Corp -# All Rights Reserved. +# All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -18,6 +18,8 @@ import uuid from ranger_tempest_plugin.data_utils import data_utils from ranger_tempest_plugin.tests.api import ims_base from tempest import config +from tempest import test + from tempest.lib import decorators from tempest.lib import exceptions @@ -60,8 +62,9 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): def _data_setup(self, post_body): image = self._create_img_and_validate_creation_on_dcp_and_lcp( **post_body) - self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp, - image["id"]) + test.addClassResourceCleanup( + self._del_img_validate_deletion_on_dcp_and_lcp, + image["id"]) # only check for Success image status if "regions" is not empty if image["regions"]: self._wait_for_image_status_on_dcp(image["id"], 'Success') @@ -82,7 +85,9 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): 'status': status, } ) - self.addCleanup(self.os_admin.rms_client.delete_region, region_name) + test.addClassResourceCleanup( + self.os_admin.rms_client.delete_region, + region_name) return region @decorators.idempotent_id('2b1bb28b-4151-4e75-ae1b-d21089c3418c') @@ -228,9 +233,10 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): test_image_id = image["id"] self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # do not forget to add this account to addCleanUp - self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp, - test_image_id) + # do not forget to add this account to tempest cleanup + test.addClassResourceCleanup( + 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"] @@ -242,6 +248,9 @@ 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'] + test.addClassResourceCleanup( + self._del_img_validate_deletion_on_dcp_and_lcp, + test_image_id) # setup region and change 'enabled', 'customers' properties region["name"] = self.region_id @@ -284,9 +293,12 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): # create region with status down region = self._create_region(status='down') - # create flavor within that newly created region + # create image within that newly created region post_body = self._get_image_params() post_body['regions'][0]['name'] = region['name'] + + # TODO(JH629G): Determine if flavor resource deletion is necessary here + self.assertRaises(exceptions.BadRequest, self.client.create_image, **post_body) @@ -301,7 +313,19 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): _, body = self.client.create_image(**post_body) self.assertIn('id', body['image']) test_image_id = body['image']['id'] - self.addCleanup(self._delete_image, test_image_id) + + # add image to tempest cleanup + test.addClassResourceCleanup( + self._del_img_validate_deletion_on_dcp_and_lcp, + test_image_id) + + # jh629g: changed out below code for above, + # on first glance seems to be stronger + # validation of deletion, which should be good + # for stopping resource leaks + + # do not forget to add this account to tempest cleanup + # test.addClassResourceCleanup(self._delete_image, test_image_id) _, body = self.client.get_image(test_image_id) # since region is building it will give error @@ -321,8 +345,11 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): _, body = self.client.create_image(**post_body) self.assertIn('id', body['image']) test_image_id = body['image']['id'] - self.addCleanup(self._delete_image, test_image_id) + # add image to tempest cleanup + test.addClassResourceCleanup( + self._del_img_validate_deletion_on_dcp_and_lcp, + test_image_id) _, body = self.client.get_image(test_image_id) # since region is maintenance it will give error # Notification to ORD failed @@ -372,9 +399,10 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): test_image_id = image["id"] self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # do not forget to add this account to addCleanUp - self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp, - test_image_id) + # add image to temepst cleanup + test.addClassResourceCleanup( + 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"] @@ -407,9 +435,10 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): test_image_id = image["id"] self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # do not forget to add this account to addCleanUp - self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp, - test_image_id) + # add image to tempest cleanup + test.addClassResourceCleanup( + 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"] @@ -428,9 +457,10 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): test_image_id = image["id"] self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # do not forget to add this account to addCleanUp - self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp, - test_image_id) + # add image to tempest cleanup + test.addClassResourceCleanup( + 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"] @@ -449,9 +479,10 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): test_image_id = image["id"] self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # do not forget to add this account to addCleanUp - self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp, - test_image_id) + # add image to tempest cleanup + test.addClassResourceCleanup( + 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"]