From: Akihiro MOTOKI Date: Fri, 18 Oct 2013 06:09:29 +0000 (+0900) Subject: Ensure OVS plugin is loaded in OVS plugin test X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=31def3ccf425a8f1a617a674a30d29f89d733432;p=openstack-build%2Fneutron-build.git Ensure OVS plugin is loaded in OVS plugin test In TestOpenvswitchSGServerRpcCallBack and NetworkBindingsTest in OVS plugin tests, OVS plugin was not loaded properly. * For NetworkBindingsTest, it can be fixed by changing setUp() to take 'plugin' arguments in the base test classes SecurityGroupDBTestCase and SGServerRpcCallBackMixinTestCase. This fixes bug 1242510 in ML2 unit tests. * For NetworkBindingsTest, it can be fixed by passing the plugin class to super.setUp(). The test itself needs to be updated because network binding is added when a network is created. * NetworkBindingsTest in Linux Bridge plugin has the same issue, so it is also fixed in this patch. Closes-Bug: #1230083 Closes-Bug: #1242510 Change-Id: I914876225480585d822748c188e9b69d1adf46f3 --- diff --git a/neutron/tests/unit/linuxbridge/test_lb_db.py b/neutron/tests/unit/linuxbridge/test_lb_db.py index c9f13388f..737747c4e 100644 --- a/neutron/tests/unit/linuxbridge/test_lb_db.py +++ b/neutron/tests/unit/linuxbridge/test_lb_db.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from oslo.config import cfg import testtools from testtools import matchers @@ -30,6 +31,9 @@ VLAN_RANGES = {PHYS_NET: [(VLAN_MIN, VLAN_MAX)]} UPDATED_VLAN_RANGES = {PHYS_NET: [(VLAN_MIN + 5, VLAN_MAX + 5)], PHYS_NET_2: [(VLAN_MIN + 20, VLAN_MAX + 20)]} +PLUGIN_NAME = ('neutron.plugins.linuxbridge.' + 'lb_neutron_plugin.LinuxBridgePluginV2') + class NetworkStatesTest(base.BaseTestCase): def setUp(self): @@ -147,17 +151,19 @@ class NetworkStatesTest(base.BaseTestCase): class NetworkBindingsTest(test_plugin.NeutronDbPluginV2TestCase): def setUp(self): - super(NetworkBindingsTest, self).setUp() + cfg.CONF.set_override('network_vlan_ranges', ['physnet1:1000:2999'], + group='VLANS') + super(NetworkBindingsTest, self).setUp(plugin=PLUGIN_NAME) lb_db.initialize() self.session = db.get_session() def test_add_network_binding(self): - with self.network() as network: + params = {'provider:network_type': 'vlan', + 'provider:physical_network': PHYS_NET, + 'provider:segmentation_id': 1234} + params['arg_list'] = tuple(params.keys()) + with self.network(**params) as network: TEST_NETWORK_ID = network['network']['id'] - self.assertIsNone(lb_db.get_network_binding(self.session, - TEST_NETWORK_ID)) - lb_db.add_network_binding(self.session, TEST_NETWORK_ID, PHYS_NET, - 1234) binding = lb_db.get_network_binding(self.session, TEST_NETWORK_ID) self.assertIsNotNone(binding) self.assertEqual(binding.network_id, TEST_NETWORK_ID) diff --git a/neutron/tests/unit/openvswitch/test_ovs_db.py b/neutron/tests/unit/openvswitch/test_ovs_db.py index c7f2ff459..b53fa4df2 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_db.py +++ b/neutron/tests/unit/openvswitch/test_ovs_db.py @@ -16,6 +16,7 @@ # limitations under the License. import mock +from oslo.config import cfg import testtools from testtools import matchers @@ -40,6 +41,9 @@ TUN_MAX = 109 TUNNEL_RANGES = [(TUN_MIN, TUN_MAX)] UPDATED_TUNNEL_RANGES = [(TUN_MIN + 5, TUN_MAX + 5)] +PLUGIN_NAME = ('neutron.plugins.openvswitch.' + 'ovs_neutron_plugin.OVSNeutronPluginV2') + class VlanAllocationsTest(base.BaseTestCase): def setUp(self): @@ -295,17 +299,19 @@ class TunnelAllocationsTest(base.BaseTestCase): class NetworkBindingsTest(test_plugin.NeutronDbPluginV2TestCase): def setUp(self): - super(NetworkBindingsTest, self).setUp() + cfg.CONF.set_override('network_vlan_ranges', ['physnet1:1000:2999'], + group='OVS') + super(NetworkBindingsTest, self).setUp(plugin=PLUGIN_NAME) ovs_db_v2.initialize() self.session = db.get_session() def test_add_network_binding(self): - with self.network() as network: + params = {'provider:network_type': 'vlan', + 'provider:physical_network': PHYS_NET, + 'provider:segmentation_id': 1234} + params['arg_list'] = tuple(params.keys()) + with self.network(**params) as network: TEST_NETWORK_ID = network['network']['id'] - self.assertIsNone(ovs_db_v2.get_network_binding(self.session, - TEST_NETWORK_ID)) - ovs_db_v2.add_network_binding(self.session, TEST_NETWORK_ID, - 'vlan', PHYS_NET, 1234) binding = ovs_db_v2.get_network_binding(self.session, TEST_NETWORK_ID) self.assertIsNotNone(binding) diff --git a/neutron/tests/unit/test_extension_security_group.py b/neutron/tests/unit/test_extension_security_group.py index d0f6ae0bf..6fbc33a33 100644 --- a/neutron/tests/unit/test_extension_security_group.py +++ b/neutron/tests/unit/test_extension_security_group.py @@ -240,15 +240,11 @@ class SecurityGroupTestPlugin(db_base_plugin_v2.NeutronDbPluginV2, class SecurityGroupDBTestCase(SecurityGroupsTestCase): def setUp(self, plugin=None): - test_config['plugin_name_v2'] = DB_PLUGIN_KLASS + plugin = plugin or DB_PLUGIN_KLASS ext_mgr = SecurityGroupTestExtensionManager() test_config['extension_manager'] = ext_mgr super(SecurityGroupDBTestCase, self).setUp(plugin) - def tearDown(self): - del test_config['plugin_name_v2'] - super(SecurityGroupDBTestCase, self).tearDown() - class TestSecurityGroups(SecurityGroupDBTestCase): def test_create_security_group(self): diff --git a/neutron/tests/unit/test_security_groups_rpc.py b/neutron/tests/unit/test_security_groups_rpc.py index ca98a55be..85fa00dd6 100644 --- a/neutron/tests/unit/test_security_groups_rpc.py +++ b/neutron/tests/unit/test_security_groups_rpc.py @@ -52,7 +52,7 @@ class FakeSGCallback(sg_db_rpc.SecurityGroupServerRpcCallbackMixin): class SGServerRpcCallBackMixinTestCase(test_sg.SecurityGroupDBTestCase): def setUp(self, plugin=None): - super(SGServerRpcCallBackMixinTestCase, self).setUp() + super(SGServerRpcCallBackMixinTestCase, self).setUp(plugin) self.rpc = FakeSGCallback() def test_security_group_rules_for_devices_ipv4_ingress(self):