From b1de7a1e07969ed7aa5196ace91536d44d71e93a Mon Sep 17 00:00:00 2001 From: Andrea Frittoli Date: Tue, 29 Aug 2017 18:41:04 +0100 Subject: [PATCH] Remove unneeded resource_cleanups in compute tests Replace resource_cleanups with addClassResourceCleanup. Change-Id: Icc101eaab88dc19290eace5c10039b73e25b743f --- tempest/api/compute/admin/test_flavors_extra_specs.py | 11 +++++------ .../admin/test_flavors_extra_specs_negative.py | 11 +++++------ .../compute/floating_ips/test_floating_ips_actions.py | 9 +-------- .../compute/floating_ips/test_list_floating_ips.py | 10 ++-------- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py index d4e7bd5703..4d27a22661 100644 --- a/tempest/api/compute/admin/test_flavors_extra_specs.py +++ b/tempest/api/compute/admin/test_flavors_extra_specs.py @@ -53,12 +53,11 @@ class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest): ephemeral=ephemeral, swap=swap, rxtx_factor=rxtx)['flavor'] - - @classmethod - def resource_cleanup(cls): - cls.admin_flavors_client.delete_flavor(cls.flavor['id']) - cls.admin_flavors_client.wait_for_resource_deletion(cls.flavor['id']) - super(FlavorsExtraSpecsTestJSON, cls).resource_cleanup() + cls.addClassResourceCleanup( + cls.admin_flavors_client.wait_for_resource_deletion, + cls.flavor['id']) + cls.addClassResourceCleanup(cls.admin_flavors_client.delete_flavor, + cls.flavor['id']) @decorators.idempotent_id('0b2f9d4b-1ca2-4b99-bb40-165d4bb94208') def test_flavor_set_get_update_show_unset_keys(self): diff --git a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py index bc32346b5b..5cde39e32b 100644 --- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py +++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py @@ -55,12 +55,11 @@ class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest): ephemeral=ephemeral, swap=swap, rxtx_factor=rxtx)['flavor'] - - @classmethod - def resource_cleanup(cls): - cls.admin_flavors_client.delete_flavor(cls.flavor['id']) - cls.admin_flavors_client.wait_for_resource_deletion(cls.flavor['id']) - super(FlavorsExtraSpecsNegativeTestJSON, cls).resource_cleanup() + cls.addClassResourceCleanup( + cls.admin_flavors_client.wait_for_resource_deletion, + cls.flavor['id']) + cls.addClassResourceCleanup(cls.admin_flavors_client.delete_flavor, + cls.flavor['id']) @decorators.attr(type=['negative']) @decorators.idempotent_id('a00a3b81-5641-45a8-ab2b-4a8ec41e1d7d') diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions.py b/tempest/api/compute/floating_ips/test_floating_ips_actions.py index 9ee0ac99bd..86e244ba9c 100644 --- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py +++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py @@ -45,7 +45,6 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest): @classmethod def resource_setup(cls): super(FloatingIPsTestJSON, cls).resource_setup() - cls.floating_ip_id = None # Server creation server = cls.create_test_server(wait_until='ACTIVE') @@ -53,16 +52,10 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest): # Floating IP creation body = cls.client.create_floating_ip( pool=CONF.network.floating_network_name)['floating_ip'] + cls.addClassResourceCleanup(cls.client.delete_floating_ip, body['id']) cls.floating_ip_id = body['id'] cls.floating_ip = body['ip'] - @classmethod - def resource_cleanup(cls): - # Deleting the floating IP which is created in this method - if cls.floating_ip_id: - cls.client.delete_floating_ip(cls.floating_ip_id) - super(FloatingIPsTestJSON, cls).resource_cleanup() - @decorators.idempotent_id('f7bfb946-297e-41b8-9e8c-aba8e9bb5194') def test_allocate_floating_ip(self): # Positive test:Allocation of a new floating IP to a project diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips.py b/tempest/api/compute/floating_ips/test_list_floating_ips.py index 2314433ab3..516c544dfa 100644 --- a/tempest/api/compute/floating_ips/test_list_floating_ips.py +++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py @@ -41,18 +41,12 @@ class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest): def resource_setup(cls): super(FloatingIPDetailsTestJSON, cls).resource_setup() cls.floating_ip = [] - cls.floating_ip_id = [] for _ in range(3): body = cls.client.create_floating_ip( pool=CONF.network.floating_network_name)['floating_ip'] + cls.addClassResourceCleanup(cls.client.delete_floating_ip, + body['id']) cls.floating_ip.append(body) - cls.floating_ip_id.append(body['id']) - - @classmethod - def resource_cleanup(cls): - for f_id in cls.floating_ip_id: - cls.client.delete_floating_ip(f_id) - super(FloatingIPDetailsTestJSON, cls).resource_cleanup() @decorators.idempotent_id('16db31c3-fb85-40c9-bbe2-8cf7b67ff99f') def test_list_floating_ips(self):