From 05ce5a1f9409d9fdd4ef92133f38d7ec9084b1c5 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Fri, 21 May 2021 09:44:22 +0000 Subject: [PATCH] VLAN "allocate_partially_specified_segment" can return any physnet When allocating a partially defined segment with VLAN type driver, any physical network can be returned. The method will select randomly any VLAN segment available, independently of the physnet configured order. Change-Id: I4d344f5ca6673b70b69a03503ec0f267bf0cadf7 Closes-Bug: #1929190 --- .../unit/plugins/ml2/drivers/test_type_vlan.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py index 62c92235e75..e707ca42f4f 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py @@ -247,11 +247,16 @@ class VlanTypeTest(testlib_api.SqlTestCase): observed = self.driver.reserve_provider_segment(self.context, segment) alloc = self._get_allocation(self.context, observed) self.assertTrue(alloc.allocated) - # NOTE(ralonsoh): first network provided in the configuration is - # PROVIDER_NET. - self.assertEqual(PROVIDER_NET, observed[api.PHYSICAL_NETWORK]) - self.assertIn(observed[api.SEGMENTATION_ID], - range(p_const.MIN_VLAN_TAG, p_const.MAX_VLAN_TAG + 1)) + if observed[api.PHYSICAL_NETWORK] == PROVIDER_NET: + self.assertIn(observed[api.SEGMENTATION_ID], + range(p_const.MIN_VLAN_TAG, + p_const.MAX_VLAN_TAG + 1)) + elif observed[api.PHYSICAL_NETWORK] == TENANT_NET: + self.assertIn(observed[api.SEGMENTATION_ID], + range(VLAN_MIN, VLAN_MAX + 1)) + else: + self.fail('The observed physical network %s does not match with ' + 'any configured' % [api.PHYSICAL_NETWORK]) def test_get_mtu(self): cfg.CONF.set_override('global_physnet_mtu', 1475)