functional-tests: Make addresses for tunneling unique
OVS can hold only one tunnel with same endpoints. Some tests had hardcoded values for both tunnel endpoints which made them unable to run in parallel manner. This patch takes always exclusive address using resource allocator. Change-Id: If81296d54656551b24917d561f235edb96a6c2df Closes-bug: #1697533
This commit is contained in:
parent
7cb56a1628
commit
330ebbb1b1
neutron/tests
@ -19,6 +19,27 @@ import netaddr
|
||||
|
||||
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):
|
||||
parent_range = netaddr.IPRange(low, high)
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
import testscenarios
|
||||
|
||||
from neutron.tests.common.exclusive_resources import ip_address
|
||||
from neutron.tests.functional import base
|
||||
|
||||
|
||||
@ -37,3 +38,11 @@ class BaseOVSLinuxTestCase(testscenarios.WithScenarios, base.BaseSudoTestCase):
|
||||
def setUp(self):
|
||||
super(BaseOVSLinuxTestCase, self).setUp()
|
||||
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")
|
||||
def test_install_flood_to_tun(self):
|
||||
attrs = {
|
||||
'remote_ip': '192.0.2.1', # RFC 5737 TEST-NET-1
|
||||
'local_ip': '198.51.100.1', # RFC 5737 TEST-NET-2
|
||||
'remote_ip': self.get_test_net_address(1),
|
||||
'local_ip': self.get_test_net_address(2),
|
||||
}
|
||||
kwargs = {'vlan': 777, 'tun_id': 888}
|
||||
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):
|
||||
attrs = {
|
||||
'remote_ip': '192.0.2.1', # RFC 5737 TEST-NET-1
|
||||
'local_ip': '198.51.100.1', # RFC 5737 TEST-NET-2
|
||||
'remote_ip': self.get_test_net_address(1),
|
||||
'local_ip': self.get_test_net_address(2),
|
||||
}
|
||||
self._test_add_tunnel_port(attrs)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user