Merge "functional-tests: Make addresses for tunneling unique"

This commit is contained in:
Jenkins 2017-06-26 18:25:21 +00:00 committed by Gerrit Code Review
commit 3c5e099733
4 changed files with 34 additions and 4 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)