Add subnet_id option
When tested network contained more than one subnet then test failed due to assert call. Subnet_id option specifies which subnet should be used for testing when more than one subnet in network is present. If subnet_id is specified then each created VM is assigned a floating IP within the range of the subnet. Closes-Bug: 1856671 Change-Id: Ie4d44b16595055201e12f10982fc78683a12d41a
This commit is contained in:
parent
4bc12aad2e
commit
2385e0417b
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- A new config option 'subnet_id' is added to section
|
||||||
|
'network' to specify subnet which should be used for
|
||||||
|
allocation of IPs for VMs created during testing.
|
||||||
|
It should be used when the tested network contains more
|
||||||
|
than one subnet otherwise test of external connectivity
|
||||||
|
will fail. (Fixes bug #1856671)
|
@ -699,6 +699,11 @@ NetworkGroup = [
|
|||||||
cfg.StrOpt('floating_network_name',
|
cfg.StrOpt('floating_network_name',
|
||||||
help="Default floating network name. Used to allocate floating "
|
help="Default floating network name. Used to allocate floating "
|
||||||
"IPs when neutron is enabled."),
|
"IPs when neutron is enabled."),
|
||||||
|
cfg.StrOpt('subnet_id',
|
||||||
|
default="",
|
||||||
|
help="Subnet id of subnet which is used for allocation of "
|
||||||
|
"floating IPs. Specify when two or more subnets are "
|
||||||
|
"present in network."),
|
||||||
cfg.StrOpt('public_router_id',
|
cfg.StrOpt('public_router_id',
|
||||||
default="",
|
default="",
|
||||||
help="Id of the public router that provides external "
|
help="Id of the public router that provides external "
|
||||||
|
@ -1008,13 +1008,18 @@ class NetworkScenarioTest(ScenarioTest):
|
|||||||
port_id, ip4 = self._get_server_port_id_and_ip4(thing)
|
port_id, ip4 = self._get_server_port_id_and_ip4(thing)
|
||||||
else:
|
else:
|
||||||
ip4 = None
|
ip4 = None
|
||||||
result = client.create_floatingip(
|
|
||||||
floating_network_id=external_network_id,
|
kwargs = {
|
||||||
port_id=port_id,
|
'floating_network_id': external_network_id,
|
||||||
tenant_id=thing['tenant_id'],
|
'port_id': port_id,
|
||||||
fixed_ip_address=ip4
|
'tenant_id': thing['tenant_id'],
|
||||||
)
|
'fixed_ip_address': ip4,
|
||||||
|
}
|
||||||
|
if CONF.network.subnet_id:
|
||||||
|
kwargs['subnet_id'] = CONF.network.subnet_id
|
||||||
|
result = client.create_floatingip(**kwargs)
|
||||||
floating_ip = result['floatingip']
|
floating_ip = result['floatingip']
|
||||||
|
|
||||||
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
||||||
client.delete_floatingip,
|
client.delete_floatingip,
|
||||||
floating_ip['id'])
|
floating_ip['id'])
|
||||||
|
@ -346,10 +346,19 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
|
|||||||
network_id=CONF.network.public_network_id)['subnets']
|
network_id=CONF.network.public_network_id)['subnets']
|
||||||
if s['ip_version'] == 4
|
if s['ip_version'] == 4
|
||||||
]
|
]
|
||||||
self.assertEqual(1, len(v4_subnets),
|
|
||||||
"Found %d IPv4 subnets" % len(v4_subnets))
|
|
||||||
|
|
||||||
|
if len(v4_subnets) > 1:
|
||||||
|
self.assertTrue(
|
||||||
|
CONF.network.subnet_id,
|
||||||
|
"Found %d subnets. Specify subnet using configuration "
|
||||||
|
"option [network].subnet_id."
|
||||||
|
% len(v4_subnets))
|
||||||
|
subnet = self.os_admin.subnets_client.show_subnet(
|
||||||
|
CONF.network.subnet_id)['subnet']
|
||||||
|
external_ips = [subnet['gateway_ip']]
|
||||||
|
else:
|
||||||
external_ips = [v4_subnets[0]['gateway_ip']]
|
external_ips = [v4_subnets[0]['gateway_ip']]
|
||||||
|
|
||||||
self._check_server_connectivity(self.floating_ip_tuple.floating_ip,
|
self._check_server_connectivity(self.floating_ip_tuple.floating_ip,
|
||||||
external_ips)
|
external_ips)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user