From 065eb4af8b7cc0284caa08bc5e8fbb035b91ca8a Mon Sep 17 00:00:00 2001 From: Artom Lifshitz Date: Wed, 13 Sep 2017 16:04:35 -0400 Subject: [PATCH] Cap compute floating IPs tests Nova removed the os-floating-ips endpoint in 2.36 and deprecated the associate and disassociate fip APIs in 2.44. To reflect this, this patch caps the corresponding tempest tests to 2.35 and 2.43. This patch also refactors some of the housekeeping classmethods in all floating IPs tests to reduce code duplication. Change-Id: Ic0eb61e6bdd427c320aef76a17da157d0d9524de --- tempest/api/compute/floating_ips/base.py | 18 +++++++ .../floating_ips/test_floating_ips_actions.py | 47 ++++++++----------- .../test_floating_ips_actions_negative.py | 28 +++++------ .../floating_ips/test_list_floating_ips.py | 19 ++------ .../test_list_floating_ips_negative.py | 18 ++----- 5 files changed, 56 insertions(+), 74 deletions(-) diff --git a/tempest/api/compute/floating_ips/base.py b/tempest/api/compute/floating_ips/base.py index 142eaec67f..262a3c1492 100644 --- a/tempest/api/compute/floating_ips/base.py +++ b/tempest/api/compute/floating_ips/base.py @@ -14,6 +14,10 @@ # under the License. from tempest.api.compute import base +from tempest.common import utils +from tempest import config + +CONF = config.CONF class BaseFloatingIPsTest(base.BaseV2ComputeTest): @@ -24,3 +28,17 @@ class BaseFloatingIPsTest(base.BaseV2ComputeTest): cls.set_network_resources(network=True, subnet=True, router=True, dhcp=True) super(BaseFloatingIPsTest, cls).setup_credentials() + + @classmethod + def skip_checks(cls): + super(BaseFloatingIPsTest, cls).skip_checks() + if not utils.get_service_list()['network']: + raise cls.skipException("network service not enabled.") + if not CONF.network_feature_enabled.floating_ips: + raise cls.skipException("Floating ips are not available") + + @classmethod + def setup_clients(cls): + super(BaseFloatingIPsTest, cls).setup_clients() + cls.client = cls.floating_ips_client + cls.pools_client = cls.floating_ip_pools_client 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 8938570446..2adc4826f0 100644 --- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py +++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py @@ -16,7 +16,6 @@ import testtools from tempest.api.compute.floating_ips import base -from tempest.common import utils from tempest import config from tempest.lib.common.utils import test_utils from tempest.lib import decorators @@ -27,32 +26,7 @@ CONF = config.CONF class FloatingIPsTestJSON(base.BaseFloatingIPsTest): - @classmethod - def skip_checks(cls): - super(FloatingIPsTestJSON, cls).skip_checks() - if not utils.get_service_list()['network']: - raise cls.skipException("network service not enabled.") - if not CONF.network_feature_enabled.floating_ips: - raise cls.skipException("Floating ips are not available") - - @classmethod - def setup_clients(cls): - super(FloatingIPsTestJSON, cls).setup_clients() - cls.client = cls.floating_ips_client - - @classmethod - def resource_setup(cls): - super(FloatingIPsTestJSON, cls).resource_setup() - - # Server creation - server = cls.create_test_server(wait_until='ACTIVE') - cls.server_id = server['id'] - # 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'] + max_microversion = '2.35' @decorators.idempotent_id('f7bfb946-297e-41b8-9e8c-aba8e9bb5194') def test_allocate_floating_ip(self): @@ -83,6 +57,25 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest): # Check it was really deleted. self.client.wait_for_resource_deletion(floating_ip_body['id']) + +class FloatingIPsAssociationTestJSON(base.BaseFloatingIPsTest): + + max_microversion = '2.43' + + @classmethod + def resource_setup(cls): + super(FloatingIPsAssociationTestJSON, cls).resource_setup() + + # Server creation + cls.server = cls.create_test_server(wait_until='ACTIVE') + cls.server_id = cls.server['id'] + # 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'] + @decorators.idempotent_id('307efa27-dc6f-48a0-8cd2-162ce3ef0b52') @testtools.skipUnless(CONF.network.public_network_id, 'The public_network_id option must be specified.') diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py index c3d7816733..9257458400 100644 --- a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py +++ b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py @@ -16,7 +16,6 @@ import testtools from tempest.api.compute.floating_ips import base -from tempest.common import utils from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators @@ -27,26 +26,12 @@ CONF = config.CONF class FloatingIPsNegativeTestJSON(base.BaseFloatingIPsTest): - @classmethod - def skip_checks(cls): - super(FloatingIPsNegativeTestJSON, cls).skip_checks() - if not utils.get_service_list()['network']: - raise cls.skipException("network service not enabled.") - if not CONF.network_feature_enabled.floating_ips: - raise cls.skipException("Floating ips are not available") - - @classmethod - def setup_clients(cls): - super(FloatingIPsNegativeTestJSON, cls).setup_clients() - cls.client = cls.floating_ips_client + max_microversion = '2.35' @classmethod def resource_setup(cls): super(FloatingIPsNegativeTestJSON, cls).resource_setup() - # Server creation - server = cls.create_test_server(wait_until='ACTIVE') - cls.server_id = server['id'] # Generating a nonexistent floatingIP id body = cls.client.list_floating_ips()['floating_ips'] floating_ip_ids = [floating_ip['id'] for floating_ip in body] @@ -77,6 +62,17 @@ class FloatingIPsNegativeTestJSON(base.BaseFloatingIPsTest): self.assertRaises(lib_exc.NotFound, self.client.delete_floating_ip, self.non_exist_id) + +class FloatingIPsAssociationNegativeTestJSON(base.BaseFloatingIPsTest): + + max_microversion = '2.43' + + @classmethod + def resource_setup(cls): + super(FloatingIPsAssociationNegativeTestJSON, cls).resource_setup() + cls.server = cls.create_test_server(wait_until='ACTIVE') + cls.server_id = cls.server['id'] + @decorators.attr(type=['negative']) @decorators.idempotent_id('595fa616-1a71-4670-9614-46564ac49a4c') def test_associate_nonexistent_floating_ip(self): 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 516c544dfa..944f79873a 100644 --- a/tempest/api/compute/floating_ips/test_list_floating_ips.py +++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py @@ -13,29 +13,16 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.api.compute import base -from tempest.common import utils +from tempest.api.compute.floating_ips import base from tempest import config from tempest.lib import decorators CONF = config.CONF -class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest): +class FloatingIPDetailsTestJSON(base.BaseFloatingIPsTest): - @classmethod - def skip_checks(cls): - super(FloatingIPDetailsTestJSON, cls).skip_checks() - if not utils.get_service_list()['network']: - raise cls.skipException("network service not enabled.") - if not CONF.network_feature_enabled.floating_ips: - raise cls.skipException("Floating ips are not available") - - @classmethod - def setup_clients(cls): - super(FloatingIPDetailsTestJSON, cls).setup_clients() - cls.client = cls.floating_ips_client - cls.pools_client = cls.floating_ip_pools_client + max_microversion = '2.35' @classmethod def resource_setup(cls): diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py index 0ade872bb0..d69248cd9b 100644 --- a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py +++ b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py @@ -13,8 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.api.compute import base -from tempest.common import utils +from tempest.api.compute.floating_ips import base from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import decorators @@ -23,20 +22,9 @@ from tempest.lib import exceptions as lib_exc CONF = config.CONF -class FloatingIPDetailsNegativeTestJSON(base.BaseV2ComputeTest): +class FloatingIPDetailsNegativeTestJSON(base.BaseFloatingIPsTest): - @classmethod - def skip_checks(cls): - super(FloatingIPDetailsNegativeTestJSON, cls).skip_checks() - if not utils.get_service_list()['network']: - raise cls.skipException("network service not enabled.") - if not CONF.network_feature_enabled.floating_ips: - raise cls.skipException("Floating ips are not available") - - @classmethod - def setup_clients(cls): - super(FloatingIPDetailsNegativeTestJSON, cls).setup_clients() - cls.client = cls.floating_ips_client + max_microversion = '2.35' @decorators.attr(type=['negative']) @decorators.idempotent_id('7ab18834-4a4b-4f28-a2c5-440579866695')