Add 'allow_duplicate_networks' to compute-feature-enabled options
Nova commit 322cc9336fe6f6fe9b3f0da33c6b26a3e5ea9b0c added the
neutron.allow_duplicate_networks config option in Juno and it defaults
to False. To test it, we need a feature toggle in Tempest so anything
testing against a default Nova setup doesn't fail.
Separate changes will be made to devstack.
Also note Nova change Ideeb3c137ff68a4497189670be33f6edbb0ccb76 which
deprecated the option in Kilo and change
Icb3510bcf0c30e11d0304a86ead91a43f37602ec which removed it in Liberty,
Once kilo-eol happens this is the default behavior in Nova and we can
remove the config option from Tempest.
Related devstack change: Ifd075420f57c9b60746f4a6af6520c0ef04800db
Co-Authored-By: Racha Ben Ali <benali@gmail.com>
Change-Id: I05f81d86cde249c23be06d5804fadbf40fc4a7f3
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 1095e77..27d65e6 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -432,6 +432,11 @@
# value)
#attach_encrypted_volume = true
+# Does the test environment support creating instances with multiple
+# ports on the same network? This is only valid when using Neutron.
+# (boolean value)
+#allow_duplicate_networks = false
+
[dashboard]
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 39447b8..23a9cb3 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -65,6 +65,20 @@
cls.password = cls.server_initial['adminPass']
cls.server = cls.client.show_server(cls.server_initial['id'])
+ def _create_net_subnet_ret_net_from_cidr(self, cidr):
+ name_net = data_utils.rand_name(self.__class__.__name__)
+ net = self.network_client.create_network(name=name_net)
+ self.addCleanup(self.network_client.delete_network,
+ net['network']['id'])
+
+ subnet = self.network_client.create_subnet(
+ network_id=net['network']['id'],
+ cidr=cidr,
+ ip_version=4)
+ self.addCleanup(self.network_client.delete_subnet,
+ subnet['subnet']['id'])
+ return net
+
@test.attr(type='smoke')
@test.idempotent_id('5de47127-9977-400a-936f-abcfbec1218f')
def test_verify_server_details(self):
@@ -147,29 +161,8 @@
def test_verify_multiple_nics_order(self):
# Verify that the networks order given at the server creation is
# preserved within the server.
- name_net1 = data_utils.rand_name(self.__class__.__name__)
- net1 = self.network_client.create_network(name=name_net1)
- self.addCleanup(self.network_client.delete_network,
- net1['network']['id'])
-
- name_net2 = data_utils.rand_name(self.__class__.__name__)
- net2 = self.network_client.create_network(name=name_net2)
- self.addCleanup(self.network_client.delete_network,
- net2['network']['id'])
-
- subnet1 = self.network_client.create_subnet(
- network_id=net1['network']['id'],
- cidr='19.80.0.0/24',
- ip_version=4)
- self.addCleanup(self.network_client.delete_subnet,
- subnet1['subnet']['id'])
-
- subnet2 = self.network_client.create_subnet(
- network_id=net2['network']['id'],
- cidr='19.86.0.0/24',
- ip_version=4)
- self.addCleanup(self.network_client.delete_subnet,
- subnet2['subnet']['id'])
+ net1 = self._create_net_subnet_ret_net_from_cidr('19.80.0.0/24')
+ net2 = self._create_net_subnet_ret_net_from_cidr('19.86.0.0/24')
networks = [{'uuid': net1['network']['id']},
{'uuid': net2['network']['id']}]
@@ -196,13 +189,50 @@
# other times ['19.80.0.3', '19.86.0.3']. So we check if the first
# address is in first network, similarly second address is in second
# network.
- addr = [addresses[name_net1][0]['addr'],
- addresses[name_net2][0]['addr']]
+ addr = [addresses[net1['network']['name']][0]['addr'],
+ addresses[net2['network']['name']][0]['addr']]
networks = [netaddr.IPNetwork('19.80.0.0/24'),
netaddr.IPNetwork('19.86.0.0/24')]
for address, network in zip(addr, networks):
self.assertIn(address, network)
+ @test.idempotent_id('1678d144-ed74-43f8-8e57-ab10dbf9b3c2')
+ @testtools.skipUnless(CONF.service_available.neutron,
+ 'Neutron service must be available.')
+ # The below skipUnless should be removed once Kilo-eol happens.
+ @testtools.skipUnless(CONF.compute_feature_enabled.
+ allow_duplicate_networks,
+ 'Duplicate networks must be allowed')
+ def test_verify_duplicate_network_nics(self):
+ # Verify that server creation does not fail when more than one nic
+ # is created on the same network.
+ net1 = self._create_net_subnet_ret_net_from_cidr('19.80.0.0/24')
+ net2 = self._create_net_subnet_ret_net_from_cidr('19.86.0.0/24')
+
+ networks = [{'uuid': net1['network']['id']},
+ {'uuid': net2['network']['id']},
+ {'uuid': net1['network']['id']}]
+
+ server_multi_nics = self.create_test_server(
+ networks=networks, wait_until='ACTIVE')
+
+ def cleanup_server():
+ self.client.delete_server(server_multi_nics['id'])
+ self.client.wait_for_server_termination(server_multi_nics['id'])
+
+ self.addCleanup(cleanup_server)
+
+ addresses = self.client.list_addresses(server_multi_nics['id'])
+
+ addr = [addresses[net1['network']['name']][0]['addr'],
+ addresses[net2['network']['name']][0]['addr'],
+ addresses[net1['network']['name']][1]['addr']]
+ networks = [netaddr.IPNetwork('19.80.0.0/24'),
+ netaddr.IPNetwork('19.86.0.0/24'),
+ netaddr.IPNetwork('19.80.0.0/24')]
+ for address, network in zip(addr, networks):
+ self.assertIn(address, network)
+
class ServersWithSpecificFlavorTestJSON(base.BaseV2ComputeAdminTest):
disk_config = 'AUTO'
diff --git a/tempest/config.py b/tempest/config.py
index 7382088..a9f1e01 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -388,6 +388,14 @@
'encrypted volume to a running server instance? This may '
'depend on the combination of compute_driver in nova and '
'the volume_driver(s) in cinder.'),
+ # TODO(mriedem): Remove allow_duplicate_networks once kilo-eol happens
+ # since the option was removed from nova in Liberty and is the default
+ # behavior starting in Liberty.
+ cfg.BoolOpt('allow_duplicate_networks',
+ default=False,
+ help='Does the test environment support creating instances '
+ 'with multiple ports on the same network? This is only '
+ 'valid when using Neutron.'),
]