Fix broken Tempest conf options in API tests
Tempest commit ed6e586b9f8f0ada10af7711f297afa01b2b7754 changed configuration options defined in Tempest from tenant to project. Currently we use Tempest from PyPI, and since there hasn't yet been a Tempest release with the change that breaks us, we're still safe, however the next release will break us, so let's be ready for it. Long term I think the correct thing to do would be to define new options used exclusively in the Neutron tree. Change-Id: I054b94a43d900e42872a9cb28d33a3ed45e14779
This commit is contained in:
parent
153f535d55
commit
2397fd0d5c
@ -35,11 +35,11 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
Therefore, v2.x of the Neutron API is assumed. It is also assumed that the
|
||||
following options are defined in the [network] section of etc/tempest.conf:
|
||||
|
||||
tenant_network_cidr with a block of cidr's from which smaller blocks
|
||||
project_network_cidr with a block of cidr's from which smaller blocks
|
||||
can be allocated for tenant networks
|
||||
|
||||
tenant_network_mask_bits with the mask bits to be used to partition the
|
||||
block defined by tenant-network_cidr
|
||||
project_network_mask_bits with the mask bits to be used to partition
|
||||
the block defined by tenant-network_cidr
|
||||
|
||||
Finally, it is assumed that the following option is defined in the
|
||||
[service_available] section of etc/tempest.conf
|
||||
@ -232,12 +232,20 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
ip_version = ip_version if ip_version is not None else cls._ip_version
|
||||
gateway_not_set = gateway == ''
|
||||
if ip_version == 4:
|
||||
cidr = cidr or netaddr.IPNetwork(CONF.network.tenant_network_cidr)
|
||||
mask_bits = mask_bits or CONF.network.tenant_network_mask_bits
|
||||
cidr = cidr or netaddr.IPNetwork(
|
||||
config.safe_get_config_value(
|
||||
'network', 'project_network_cidr'))
|
||||
mask_bits = (
|
||||
mask_bits or config.safe_get_config_value(
|
||||
'network', 'project_network_mask_bits'))
|
||||
elif ip_version == 6:
|
||||
cidr = (
|
||||
cidr or netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr))
|
||||
mask_bits = mask_bits or CONF.network.tenant_network_v6_mask_bits
|
||||
cidr or netaddr.IPNetwork(
|
||||
config.safe_get_config_value(
|
||||
'network', 'project_network_v6_cidr')))
|
||||
mask_bits = (
|
||||
mask_bits or config.safe_get_config_value(
|
||||
'network', 'project_network_v6_mask_bits'))
|
||||
# Find a cidr that is not in use yet and create a subnet with it
|
||||
for subnet_cidr in cidr.subnet(mask_bits):
|
||||
if gateway_not_set:
|
||||
|
@ -99,7 +99,9 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest):
|
||||
@test.idempotent_id('4d6d178f-34f6-4bff-a01c-0a2f8fe909e4')
|
||||
def test_update_port_with_cidr_address_pair(self):
|
||||
# Update allowed address pair with cidr
|
||||
cidr = str(netaddr.IPNetwork(CONF.network.tenant_network_cidr))
|
||||
cidr = str(
|
||||
netaddr.IPNetwork(config.safe_get_config_value(
|
||||
'network', 'project_network_cidr')))
|
||||
self._update_port_with_address(cidr)
|
||||
|
||||
@test.attr(type='smoke')
|
||||
|
@ -79,10 +79,12 @@ class NetworksIpAvailabilityTest(base.BaseAdminNetworkTest):
|
||||
def _create_subnet(self, network, ip_version):
|
||||
if ip_version == lib_constants.IP_VERSION_4:
|
||||
cidr = netaddr.IPNetwork('20.0.0.0/24')
|
||||
mask_bits = CONF.network.tenant_network_mask_bits
|
||||
mask_bits = config.safe_get_config_value(
|
||||
'network', 'project_network_mask_bits')
|
||||
elif ip_version == lib_constants.IP_VERSION_6:
|
||||
cidr = netaddr.IPNetwork('20:db8::/64')
|
||||
mask_bits = CONF.network.tenant_network_v6_mask_bits
|
||||
mask_bits = config.safe_get_config_value(
|
||||
'network', 'project_network_v6_mask_bits')
|
||||
|
||||
subnet_cidr = cidr.subnet(mask_bits).next()
|
||||
prefix_len = subnet_cidr.prefixlen
|
||||
|
@ -34,9 +34,10 @@ class RoutersTest(base.BaseRouterTest):
|
||||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(RoutersTest, cls).resource_setup()
|
||||
cls.tenant_cidr = (CONF.network.tenant_network_cidr
|
||||
if cls._ip_version == 4 else
|
||||
CONF.network.tenant_network_v6_cidr)
|
||||
cls.tenant_cidr = (
|
||||
config.safe_get_config_value('network', 'project_network_cidr')
|
||||
if cls._ip_version == 4 else
|
||||
config.safe_get_config_value('network', 'project_network_v6_cidr'))
|
||||
|
||||
@test.attr(type='smoke')
|
||||
@test.idempotent_id('c72c1c0c-2193-4aca-eeee-b1442640eeee')
|
||||
|
@ -24,8 +24,6 @@ CONF = config.CONF
|
||||
|
||||
class NegativeSecGroupTest(base.BaseSecGroupTest):
|
||||
|
||||
_tenant_network_cidr = CONF.network.tenant_network_cidr
|
||||
|
||||
@classmethod
|
||||
@test.requires_ext(extension="security-group", service="network")
|
||||
def resource_setup(cls):
|
||||
@ -74,4 +72,3 @@ class NegativeSecGroupTest(base.BaseSecGroupTest):
|
||||
|
||||
class NegativeSecGroupIPv6Test(NegativeSecGroupTest):
|
||||
_ip_version = 6
|
||||
_tenant_network_cidr = CONF.network.tenant_network_v6_cidr
|
||||
|
@ -14,6 +14,7 @@ from oslo_config import cfg
|
||||
|
||||
from tempest import config
|
||||
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
@ -27,3 +28,20 @@ NeutronPluginOptions = [
|
||||
# transition to the Tempest plugin architecture
|
||||
for opt in NeutronPluginOptions:
|
||||
CONF.register_opt(opt, 'neutron_plugin_options')
|
||||
|
||||
|
||||
config_opts_translator = {
|
||||
'project_network_cidr': 'tenant_network_cidr',
|
||||
'project_network_v6_cidr': 'tenant_network_v6_cidr',
|
||||
'project_network_mask_bits': 'tenant_network_mask_bits',
|
||||
'project_network_v6_mask_bits': 'tenant_network_v6_mask_bits'}
|
||||
|
||||
|
||||
def safe_get_config_value(group, name):
|
||||
"""Safely get Oslo config opts from Tempest, using old and new names."""
|
||||
conf_group = getattr(CONF, group)
|
||||
|
||||
try:
|
||||
return getattr(conf_group, name)
|
||||
except cfg.NoSuchOptError:
|
||||
return getattr(conf_group, config_opts_translator[name])
|
||||
|
Loading…
Reference in New Issue
Block a user