]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Ensure OVS plugin is loaded in OVS plugin test
authorAkihiro MOTOKI <motoki@da.jp.nec.com>
Fri, 18 Oct 2013 06:09:29 +0000 (15:09 +0900)
committerAkihiro MOTOKI <motoki@da.jp.nec.com>
Sat, 26 Oct 2013 11:52:15 +0000 (20:52 +0900)
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

neutron/tests/unit/linuxbridge/test_lb_db.py
neutron/tests/unit/openvswitch/test_ovs_db.py
neutron/tests/unit/test_extension_security_group.py
neutron/tests/unit/test_security_groups_rpc.py

index c9f13388f55c8bba3ec546b97289c3a210c36b46..737747c4ebf609722e5e8ebdf7dd55cab4538ace 100644 (file)
@@ -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)
index c7f2ff459d94707e86ad5120b7158ca466d2c413..b53fa4df29abe7bd7a07b9b6807075a8c2139644 100644 (file)
@@ -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)
index d0f6ae0bff6febaccafafba7ce8db203245d7c9d..6fbc33a33a1f2c6c261084007889c6f9c21154b8 100644 (file)
@@ -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):
index ca98a55be911d04f95e01209313364b038e59771..85fa00dd6fe4a781d6c310c7ee1e11fc1c863c17 100644 (file)
@@ -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):