Merge "functional-tests: Make addresses for tunneling unique"
This commit is contained in:
@@ -19,6 +19,27 @@ import netaddr
|
|||||||
|
|
||||||
from neutron.tests.common.exclusive_resources import resource_allocator
|
from neutron.tests.common.exclusive_resources import resource_allocator
|
||||||
|
|
||||||
|
TEST_NET_RANGE = {
|
||||||
|
1: ('192.0.2.1', '192.0.2.254'),
|
||||||
|
2: ('198.51.100.1', '198.51.100.254'),
|
||||||
|
3: ('203.0.113.1', '203.0.113.254'),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_test_net_address_fixture(test_net_number):
|
||||||
|
"""Return exclusive ip address on the system based on RFC 5737.
|
||||||
|
|
||||||
|
:param block: One of following constants: 1, 2, 3
|
||||||
|
|
||||||
|
https://tools.ietf.org/html/rfc5737
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
net_range = TEST_NET_RANGE[test_net_number]
|
||||||
|
except KeyError:
|
||||||
|
raise ValueError("Unknown constant for TEST-NET: %d" % test_net_number)
|
||||||
|
|
||||||
|
return ExclusiveIPAddress(*net_range)
|
||||||
|
|
||||||
|
|
||||||
def get_random_ip(low, high):
|
def get_random_ip(low, high):
|
||||||
parent_range = netaddr.IPRange(low, high)
|
parent_range = netaddr.IPRange(low, high)
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import testscenarios
|
import testscenarios
|
||||||
|
|
||||||
|
from neutron.tests.common.exclusive_resources import ip_address
|
||||||
from neutron.tests.functional import base
|
from neutron.tests.functional import base
|
||||||
|
|
||||||
|
|
||||||
@@ -37,3 +38,11 @@ class BaseOVSLinuxTestCase(testscenarios.WithScenarios, base.BaseSudoTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BaseOVSLinuxTestCase, self).setUp()
|
super(BaseOVSLinuxTestCase, self).setUp()
|
||||||
self.config(group='OVS', ovsdb_interface=self.ovsdb_interface)
|
self.config(group='OVS', ovsdb_interface=self.ovsdb_interface)
|
||||||
|
|
||||||
|
def get_test_net_address(self, block):
|
||||||
|
"""Return exclusive address based on RFC 5737.
|
||||||
|
|
||||||
|
:param block: One of constants 1, 2 or 3
|
||||||
|
"""
|
||||||
|
return str(self.useFixture(
|
||||||
|
ip_address.get_test_net_address_fixture(block)).address)
|
||||||
|
@@ -428,8 +428,8 @@ class OVSFlowTestCase(OVSAgentTestBase):
|
|||||||
@helpers.skip_if_ovs_older_than("2.5.1")
|
@helpers.skip_if_ovs_older_than("2.5.1")
|
||||||
def test_install_flood_to_tun(self):
|
def test_install_flood_to_tun(self):
|
||||||
attrs = {
|
attrs = {
|
||||||
'remote_ip': '192.0.2.1', # RFC 5737 TEST-NET-1
|
'remote_ip': self.get_test_net_address(1),
|
||||||
'local_ip': '198.51.100.1', # RFC 5737 TEST-NET-2
|
'local_ip': self.get_test_net_address(2),
|
||||||
}
|
}
|
||||||
kwargs = {'vlan': 777, 'tun_id': 888}
|
kwargs = {'vlan': 777, 'tun_id': 888}
|
||||||
port_name = common_utils.get_rand_device_name(net_helpers.PORT_PREFIX)
|
port_name = common_utils.get_rand_device_name(net_helpers.PORT_PREFIX)
|
||||||
|
@@ -206,8 +206,8 @@ class OVSBridgeTestCase(OVSBridgeTestBase):
|
|||||||
|
|
||||||
def test_add_tunnel_port_ipv4(self):
|
def test_add_tunnel_port_ipv4(self):
|
||||||
attrs = {
|
attrs = {
|
||||||
'remote_ip': '192.0.2.1', # RFC 5737 TEST-NET-1
|
'remote_ip': self.get_test_net_address(1),
|
||||||
'local_ip': '198.51.100.1', # RFC 5737 TEST-NET-2
|
'local_ip': self.get_test_net_address(2),
|
||||||
}
|
}
|
||||||
self._test_add_tunnel_port(attrs)
|
self._test_add_tunnel_port(attrs)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user