From f5699576d85bf29e9bc9f9160307db8d00ad5086 Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Fri, 15 Jan 2021 10:22:21 +1300 Subject: [PATCH] Remove the tests for unsupported Nova APIs Change-Id: Ib582c984796cbcd93fdb3a505d0b3fcdf6a2fbf2 --- .../tests/api/compute/test_fixed_ips_rbac.py | 78 ------------ .../compute/test_floating_ips_bulk_rbac.py | 112 ------------------ .../compute/test_virtual_interfaces_rbac.py | 64 ---------- 3 files changed, 254 deletions(-) delete mode 100644 patrole_tempest_plugin/tests/api/compute/test_fixed_ips_rbac.py delete mode 100644 patrole_tempest_plugin/tests/api/compute/test_floating_ips_bulk_rbac.py delete mode 100644 patrole_tempest_plugin/tests/api/compute/test_virtual_interfaces_rbac.py diff --git a/patrole_tempest_plugin/tests/api/compute/test_fixed_ips_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_fixed_ips_rbac.py deleted file mode 100644 index 64dd0d19..00000000 --- a/patrole_tempest_plugin/tests/api/compute/test_fixed_ips_rbac.py +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright 2017 NEC Corporation. -# 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 -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest import config -from tempest.lib import decorators - -from patrole_tempest_plugin import rbac_rule_validation -from patrole_tempest_plugin.tests.api.compute import rbac_base - -CONF = config.CONF - - -class FixedIpsRbacTest(rbac_base.BaseV2ComputeRbacTest): - - # Tests will fail with a 404 starting from microversion 2.36: - # See the following link for details: - # https://docs.openstack.org/api-ref/compute/#fixed-ips-os-fixed-ips-deprecated - max_microversion = '2.35' - - @classmethod - def skip_checks(cls): - super(FixedIpsRbacTest, cls).skip_checks() - if CONF.service_available.neutron: - msg = ("%s skipped as neutron is available" % cls.__name__) - raise cls.skipException(msg) - - @classmethod - def resource_setup(cls): - super(FixedIpsRbacTest, cls).resource_setup() - server = cls.create_test_server(wait_until='ACTIVE') - server = cls.servers_client.show_server(server['id'])['server'] - cls.ip = None - for ip_set in server['addresses']: - for ip in server['addresses'][ip_set]: - if ip['OS-EXT-IPS:type'] == 'fixed': - cls.ip = ip['addr'] - break - if cls.ip: - break - if cls.ip is None: - raise cls.skipException("No fixed ip found for server: %s" - % server['id']) - - @decorators.idempotent_id('c89391f7-4844-4a70-a116-37c1336efb99') - @rbac_rule_validation.action( - service="nova", - rules=["os_compute_api:os-fixed-ips"]) - def test_show_fixed_ip_details(self): - with self.override_role(): - self.fixed_ips_client.show_fixed_ip(self.ip) - - @decorators.idempotent_id('f0314501-735d-4315-9856-959e01e82f0d') - @rbac_rule_validation.action( - service="nova", - rules=["os_compute_api:os-fixed-ips"]) - def test_set_reserve(self): - with self.override_role(): - self.fixed_ips_client.reserve_fixed_ip(self.ip, reserve="None") - - @decorators.idempotent_id('866a6fdc-a237-4502-9bf2-52fe82aba356') - @rbac_rule_validation.action( - service="nova", - rules=["os_compute_api:os-fixed-ips"]) - def test_set_unreserve(self): - with self.override_role(): - self.fixed_ips_client.reserve_fixed_ip(self.ip, unreserve="None") diff --git a/patrole_tempest_plugin/tests/api/compute/test_floating_ips_bulk_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_floating_ips_bulk_rbac.py deleted file mode 100644 index 2a86053f..00000000 --- a/patrole_tempest_plugin/tests/api/compute/test_floating_ips_bulk_rbac.py +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright 2017 AT&T Corporation. -# 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 -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import netaddr - -from tempest.common import utils -from tempest import config -from tempest.lib.common.utils import test_utils -from tempest.lib import decorators -from tempest.lib import exceptions as lib_exc - -from patrole_tempest_plugin import rbac_rule_validation -from patrole_tempest_plugin.tests.api.compute import rbac_base - -CONF = config.CONF - - -# TODO(gmann): Remove this test class once the nova queens branch goes -# into extended maintenance mode. -class FloatingIpsBulkRbacTest(rbac_base.BaseV2ComputeRbacTest): - - # Tests will fail with a 404 starting from microversion 2.36: - # See the following link for details: - # https://docs.openstack.org/api-ref/compute/#floating-ips-bulk-os-floating-ips-bulk-deprecated - max_microversion = '2.35' - depends_on_nova_network = True - - @classmethod - def skip_checks(cls): - super(FloatingIpsBulkRbacTest, cls).skip_checks() - if not utils.is_extension_enabled('os-floating-ips-bulk', 'compute'): - msg = "%s skipped as os-floating-ips-bulk extension not enabled." \ - % cls.__name__ - raise cls.skipException(msg) - if not CONF.network_feature_enabled.floating_ips: - raise cls.skipException("Floating ips are not available") - - @classmethod - def setup_clients(cls): - super(FloatingIpsBulkRbacTest, cls).setup_clients() - cls.fip_bulk_client = cls.os_primary.floating_ips_bulk_client - - @classmethod - def resource_setup(cls): - super(FloatingIpsBulkRbacTest, cls).resource_setup() - cls.ip_range = CONF.validation.floating_ip_range - cls.verify_unallocated_floating_ip_range(cls.ip_range) - - @classmethod - def verify_unallocated_floating_ip_range(cls, ip_range): - # Verify whether configure floating IP range is not already allocated. - body = cls.fip_bulk_client.list_floating_ips_bulk()[ - 'floating_ip_info'] - allocated_ips_list = map(lambda x: x['address'], body) - for ip_addr in netaddr.IPNetwork(ip_range).iter_hosts(): - if str(ip_addr) in allocated_ips_list: - msg = ("Configured unallocated floating IP range is already " - "allocated. Configure the correct unallocated range " - "as 'floating_ip_range'") - raise lib_exc.InvalidConfiguration(msg) - return - - def _create_floating_ips_bulk(self): - pool = 'test_pool' - # NOTE(felipemonteiro): Comment copied from Tempest. Reserving the IP - # range but those are not attached anywhere. Using the below mentioned - # interface which is not ever expected to be used. Clean up already - # done for created IP range. - interface = 'eth0' - body = self.fip_bulk_client.create_floating_ips_bulk( - self.ip_range, pool, interface)['floating_ips_bulk_create'] - self.addCleanup(test_utils.call_and_ignore_notfound_exc, - self.fip_bulk_client.delete_floating_ips_bulk, - self.ip_range) - return body - - @decorators.idempotent_id('9a49e73f-96a0-4e93-830a-22c4e443b486') - @rbac_rule_validation.action( - service="nova", - rules=["os_compute_api:os-floating-ips-bulk"]) - def test_create_floating_ips_bulk(self): - with self.override_role(): - self._create_floating_ips_bulk() - - @decorators.idempotent_id('3b5c8a02-005d-4256-8a95-6fa2f389c6cf') - @rbac_rule_validation.action( - service="nova", - rules=["os_compute_api:os-floating-ips-bulk"]) - def test_list_floating_ips_bulk(self): - with self.override_role(): - self.fip_bulk_client.list_floating_ips_bulk() - - @decorators.idempotent_id('37c2b759-c494-4e20-9dba-6a67b2df9573') - @rbac_rule_validation.action( - service="nova", - rules=["os_compute_api:os-floating-ips-bulk"]) - def test_delete_floating_ips_bulk(self): - self._create_floating_ips_bulk() - with self.override_role(): - self.fip_bulk_client.delete_floating_ips_bulk(self.ip_range) diff --git a/patrole_tempest_plugin/tests/api/compute/test_virtual_interfaces_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_virtual_interfaces_rbac.py deleted file mode 100644 index 62eb0bf4..00000000 --- a/patrole_tempest_plugin/tests/api/compute/test_virtual_interfaces_rbac.py +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2017 AT&T Corporation. -# 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 -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest import config -from tempest.lib import decorators -from tempest.lib import exceptions as lib_exc - -from patrole_tempest_plugin import rbac_rule_validation -from patrole_tempest_plugin.tests.api.compute import rbac_base - -CONF = config.CONF - - -# TODO(rb560u): Remove this test class once the nova queens branch goes into -# extended maintenance mode. -class VirtualInterfacesRbacTest(rbac_base.BaseV2ComputeRbacTest): - # The compute os-virtual-interfaces API is deprecated from the Microversion - # 2.44 onward. For more information, see: - # https://docs.openstack.org/api-ref/compute/#servers-virtual-interfaces-servers-os-virtual-interfaces-deprecated - depends_on_nova_network = True - max_microversion = '2.43' - - @classmethod - def setup_credentials(cls): - # This test needs a network and a subnet - cls.set_network_resources(network=True, subnet=True) - super(VirtualInterfacesRbacTest, cls).setup_credentials() - - @classmethod - def resource_setup(cls): - super(VirtualInterfacesRbacTest, cls).resource_setup() - cls.server = cls.create_test_server(wait_until='ACTIVE') - - @rbac_rule_validation.action( - service="nova", - rules=["os_compute_api:os-virtual-interfaces"]) - @decorators.idempotent_id('fc719ae3-0f73-4689-8378-1b841f0f2818') - def test_list_virtual_interfaces(self): - """Test list virtual interfaces, part of os-virtual-interfaces. - - If Neutron is available, then call the API and expect it to fail - with a 400 BadRequest (policy enforcement is done before that happens). - """ - with self.override_role(): - if CONF.service_available.neutron: - msg = ("Listing virtual interfaces is not supported by this " - "cloud.") - with self.assertRaisesRegex(lib_exc.BadRequest, msg): - self.servers_client.list_virtual_interfaces( - self.server['id']) - else: - self.servers_client.list_virtual_interfaces(self.server['id'])