]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use correct base class for unit tests for ML2 drivers
authorAKamyshnikova <akamyshnikova@mirantis.com>
Fri, 3 Oct 2014 06:27:44 +0000 (10:27 +0400)
committerAnn Kamyshnikova <akamyshnikova@mirantis.com>
Thu, 6 Nov 2014 16:13:10 +0000 (19:13 +0300)
In unit tests for several ML2 mechanism drivers (listed below)
the NeutronDbPluginV2TestCase class is used instead of Ml2PluginV2TestCase
which is desired to be used.

Unit tests for ML2 mechanism drivers in neutron/tests/unit/ml2:
   drivers/cisco/nexus/test_cisco_mech.py
   drivers/brocade/test_brocade_mechanism_driver.py
   drivers/freescale/test_mechanism_fslsdn.py
   test_mechanism_ncs.py
   test_mechanism_odl.py
   test_l2population.py

Partial-Bug: #1373153

Change-Id: I9524cafb39975b1384954a2eefcbf754231d2198

neutron/tests/unit/ml2/drivers/brocade/test_brocade_mechanism_driver.py
neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py
neutron/tests/unit/ml2/drivers/freescale/test_mechanism_fslsdn.py
neutron/tests/unit/ml2/drivers/test_l2population.py
neutron/tests/unit/ml2/test_mechanism_ncs.py
neutron/tests/unit/ml2/test_mechanism_odl.py

index 4f20f2ccc82853a16c06c1387f388a145649d419..5eea451d1465e4574feefd9711d7cda470c63800 100644 (file)
@@ -20,14 +20,14 @@ from neutron.openstack.common import log as logging
 from neutron.plugins.ml2 import config as ml2_config
 from neutron.plugins.ml2.drivers.brocade import (mechanism_brocade
                                                  as brocademechanism)
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.ml2 import test_ml2_plugin
 
 LOG = logging.getLogger(__name__)
 MECHANISM_NAME = ('neutron.plugins.ml2.'
                   'drivers.brocade.mechanism_brocade.BrocadeMechanism')
 
 
-class TestBrocadeMechDriverV2(test_db_plugin.NeutronDbPluginV2TestCase):
+class TestBrocadeMechDriverV2(test_ml2_plugin.Ml2PluginV2TestCase):
     """Test Brocade VCS/VDX mechanism driver.
     """
 
@@ -53,17 +53,17 @@ class TestBrocadeMechDriverV2(test_db_plugin.NeutronDbPluginV2TestCase):
             self.mechanism_driver = importutils.import_object(_mechanism_name)
 
 
-class TestBrocadeMechDriverNetworksV2(test_db_plugin.TestNetworksV2,
+class TestBrocadeMechDriverNetworksV2(test_ml2_plugin.TestMl2NetworksV2,
                                       TestBrocadeMechDriverV2):
     pass
 
 
-class TestBrocadeMechDriverPortsV2(test_db_plugin.TestPortsV2,
+class TestBrocadeMechDriverPortsV2(test_ml2_plugin.TestMl2PortsV2,
                                    TestBrocadeMechDriverV2):
     pass
 
 
-class TestBrocadeMechDriverSubnetsV2(test_db_plugin.TestSubnetsV2,
+class TestBrocadeMechDriverSubnetsV2(test_ml2_plugin.TestMl2SubnetsV2,
                                      TestBrocadeMechDriverV2):
     pass
 
index efd3c7188c4c0e83de05ca6a31150801406743ff..26e813495c3f403ae70726d9babee19bd0c5beb0 100644 (file)
@@ -24,7 +24,6 @@ from neutron.extensions import portbindings
 from neutron import manager
 from neutron.openstack.common import log as logging
 from neutron.plugins.common import constants as p_const
-from neutron.plugins.ml2 import config as ml2_config
 from neutron.plugins.ml2 import driver_api as api
 from neutron.plugins.ml2 import driver_context
 from neutron.plugins.ml2.drivers.cisco.nexus import config as cisco_config
@@ -32,12 +31,10 @@ from neutron.plugins.ml2.drivers.cisco.nexus import exceptions as c_exc
 from neutron.plugins.ml2.drivers.cisco.nexus import mech_cisco_nexus
 from neutron.plugins.ml2.drivers.cisco.nexus import nexus_db_v2
 from neutron.plugins.ml2.drivers.cisco.nexus import nexus_network_driver
-from neutron.plugins.ml2.drivers import type_vlan as vlan_config
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.ml2 import test_ml2_plugin
 
 
 LOG = logging.getLogger(__name__)
-ML2_PLUGIN = 'neutron.plugins.ml2.plugin.Ml2Plugin'
 PHYS_NET = 'physnet1'
 COMP_HOST_NAME = 'testhost'
 COMP_HOST_NAME_2 = 'testhost_2'
@@ -61,7 +58,8 @@ BOUND_SEGMENT2 = {api.NETWORK_TYPE: p_const.TYPE_VLAN,
                   api.SEGMENTATION_ID: VLAN_START + 1}
 
 
-class CiscoML2MechanismTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
+class CiscoML2MechanismTestCase(test_ml2_plugin.Ml2PluginV2TestCase):
+    _mechanism_drivers = ['cisco_nexus']
 
     def setUp(self):
         """Configure for end-to-end neutron testing using a mock ncclient.
@@ -75,20 +73,6 @@ class CiscoML2MechanismTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
 
         """
 
-        # Configure the ML2 mechanism drivers and network types
-        ml2_opts = {
-            'mechanism_drivers': ['cisco_nexus'],
-            'tenant_network_types': ['vlan'],
-        }
-        for opt, val in ml2_opts.items():
-                ml2_config.cfg.CONF.set_override(opt, val, 'ml2')
-
-        # Configure the ML2 VLAN parameters
-        phys_vrange = ':'.join([PHYS_NET, str(VLAN_START), str(VLAN_END)])
-        vlan_config.cfg.CONF.set_override('network_vlan_ranges',
-                                          [phys_vrange],
-                                          'ml2_type_vlan')
-
         # Configure the Cisco Nexus mechanism driver
         nexus_config = {
             (NEXUS_IP_ADDR, 'username'): 'admin',
@@ -135,7 +119,7 @@ class CiscoML2MechanismTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
             '_is_status_active').start()
         self.mock_status.side_effect = _mock_check_bind_state
 
-        super(CiscoML2MechanismTestCase, self).setUp(ML2_PLUGIN)
+        super(CiscoML2MechanismTestCase, self).setUp()
 
         self.port_create_status = 'DOWN'
 
@@ -228,19 +212,19 @@ class CiscoML2MechanismTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
 
 
 class TestCiscoBasicGet(CiscoML2MechanismTestCase,
-                        test_db_plugin.TestBasicGet):
+                        test_ml2_plugin.TestMl2BasicGet):
 
     pass
 
 
 class TestCiscoV2HTTPResponse(CiscoML2MechanismTestCase,
-                              test_db_plugin.TestV2HTTPResponse):
+                              test_ml2_plugin.TestMl2V2HTTPResponse):
 
     pass
 
 
 class TestCiscoPortsV2(CiscoML2MechanismTestCase,
-                       test_db_plugin.TestPortsV2):
+                       test_ml2_plugin.TestMl2PortsV2):
 
     @contextlib.contextmanager
     def _create_resources(self, name=NETWORK_NAME, cidr=CIDR_1,
@@ -718,7 +702,7 @@ class TestCiscoPortsV2(CiscoML2MechanismTestCase,
 
 
 class TestCiscoNetworksV2(CiscoML2MechanismTestCase,
-                          test_db_plugin.TestNetworksV2):
+                          test_ml2_plugin.TestMl2NetworksV2):
 
     def test_create_networks_bulk_emulated_plugin_failure(self):
         real_has_attr = hasattr
@@ -769,7 +753,7 @@ class TestCiscoNetworksV2(CiscoML2MechanismTestCase,
 
 
 class TestCiscoSubnetsV2(CiscoML2MechanismTestCase,
-                         test_db_plugin.TestSubnetsV2):
+                         test_ml2_plugin.TestMl2SubnetsV2):
 
     def test_create_subnets_bulk_emulated_plugin_failure(self):
         real_has_attr = hasattr
index c5c10737509f666da19d59a7983f696e4e8b5c5c..3a4326ff55f679b23c9c2552da69e1e22bcf6be1 100644 (file)
@@ -19,18 +19,18 @@ from oslo.config import cfg
 from neutron.extensions import portbindings
 from neutron.plugins.ml2.drivers.freescale import mechanism_fslsdn
 from neutron.tests import base
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.ml2 import test_ml2_plugin
 
 
 """Unit testing for Freescale SDN mechanism driver."""
 
 
-class TestFslSdnMechDriverV2(test_db_plugin.NeutronDbPluginV2TestCase):
+class TestFslSdnMechDriverV2(test_ml2_plugin.Ml2PluginV2TestCase):
+    _mechanism_drivers = ['fslsdn']
 
     """Testing mechanism driver with ML2 plugin."""
 
     def setUp(self):
-        cfg.CONF.set_override('mechanism_drivers', ['fslsdn'], 'ml2')
 
         def mocked_fslsdn_init(self):
             # Mock CRD client, since it requires CRD service running.
@@ -41,18 +41,18 @@ class TestFslSdnMechDriverV2(test_db_plugin.NeutronDbPluginV2TestCase):
             super(TestFslSdnMechDriverV2, self).setUp()
 
 
-class TestFslSdnMechDriverNetworksV2(test_db_plugin.TestNetworksV2,
+class TestFslSdnMechDriverNetworksV2(test_ml2_plugin.TestMl2NetworksV2,
                                      TestFslSdnMechDriverV2):
     pass
 
 
-class TestFslSdnMechDriverPortsV2(test_db_plugin.TestPortsV2,
+class TestFslSdnMechDriverPortsV2(test_ml2_plugin.TestMl2PortsV2,
                                   TestFslSdnMechDriverV2):
     VIF_TYPE = portbindings.VIF_TYPE_OVS
     CAP_PORT_FILTER = True
 
 
-class TestFslSdnMechDriverSubnetsV2(test_db_plugin.TestSubnetsV2,
+class TestFslSdnMechDriverSubnetsV2(test_ml2_plugin.TestMl2SubnetsV2,
                                     TestFslSdnMechDriverV2):
     pass
 
index 85d8b37a7315fe8950a21599416e261d8abfde5a..fa5a8be995c09de4d0746bcedabeb5edcbb3a5af 100644 (file)
@@ -24,11 +24,10 @@ from neutron.extensions import portbindings
 from neutron.extensions import providernet as pnet
 from neutron import manager
 from neutron.openstack.common import timeutils
-from neutron.plugins.ml2 import config as config
 from neutron.plugins.ml2.drivers.l2pop import mech_driver as l2pop_mech_driver
 from neutron.plugins.ml2 import managers
 from neutron.plugins.ml2 import rpc
-from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit.ml2 import test_ml2_plugin as test_plugin
 
 HOST = 'my_l2_host'
 L2_AGENT = {
@@ -81,32 +80,23 @@ L2_AGENT_5 = {
     'topic': constants.L2_AGENT_TOPIC,
     'configurations': {'tunneling_ip': '20.0.0.5',
                        'tunnel_types': [],
-                       'bridge_mappings': {'phys1': 'br'},
+                       'bridge_mappings': {'physnet1': 'br'},
                        'l2pop_network_types': ['vlan']},
     'agent_type': constants.AGENT_TYPE_OFA,
     'tunnel_type': [],
     'start_flag': True
 }
 
-PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
 NOTIFIER = 'neutron.plugins.ml2.rpc.AgentNotifierApi'
 DEVICE_OWNER_COMPUTE = 'compute:None'
 
 
-class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
+class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
+    _mechanism_drivers = ['openvswitch', 'linuxbridge',
+                          'ofagent', 'l2population']
 
     def setUp(self):
-        # Enable the test mechanism driver to ensure that
-        # we can successfully call through to all mechanism
-        # driver apis.
-        config.cfg.CONF.set_override('mechanism_drivers',
-                                     ['openvswitch', 'linuxbridge',
-                                      'ofagent', 'l2population'],
-                                     'ml2')
-        config.cfg.CONF.set_override('network_vlan_ranges',
-                                     ['phys1:1:100'],
-                                     'ml2_type_vlan')
-        super(TestL2PopulationRpcTestCase, self).setUp(PLUGIN_NAME)
+        super(TestL2PopulationRpcTestCase, self).setUp()
 
         self.adminContext = context.get_admin_context()
 
@@ -122,7 +112,7 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
                                            **net_arg)
 
         net_arg = {pnet.NETWORK_TYPE: 'vlan',
-                   pnet.PHYSICAL_NETWORK: 'phys1',
+                   pnet.PHYSICAL_NETWORK: 'physnet1',
                    pnet.SEGMENTATION_ID: '2'}
         self._network2 = self._make_network(self.fmt, 'net2', True,
                                             arg_list=(pnet.NETWORK_TYPE,
index 9ae267823fce2186169a6198196d4a7d5cdd9ea8..6c40a168554e0c7aa8ae5268e6936cb684bda650 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from neutron.plugins.ml2 import config as config
 from neutron.plugins.ml2.drivers import mechanism_ncs
-from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit.ml2 import test_ml2_plugin as test_plugin
 
-PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
 
-
-class NCSTestCase(test_plugin.NeutronDbPluginV2TestCase):
+class NCSTestCase(test_plugin.Ml2PluginV2TestCase):
+    _mechanism_drivers = ['logger', 'ncs']
 
     def setUp(self):
         # Enable the test mechanism driver to ensure that
         # we can successfully call through to all mechanism
         # driver apis.
-        config.cfg.CONF.set_override('mechanism_drivers',
-                                     ['logger', 'ncs'],
-                                     'ml2')
-        super(NCSTestCase, self).setUp(PLUGIN_NAME)
+        super(NCSTestCase, self).setUp()
         self.port_create_status = 'DOWN'
         mechanism_ncs.NCSMechanismDriver.sendjson = self.check_sendjson
 
@@ -38,13 +33,13 @@ class NCSTestCase(test_plugin.NeutronDbPluginV2TestCase):
         self.assertFalse(urlpath.startswith("http://"))
 
 
-class NCSMechanismTestBasicGet(test_plugin.TestBasicGet, NCSTestCase):
+class NCSMechanismTestBasicGet(test_plugin.TestMl2BasicGet, NCSTestCase):
     pass
 
 
-class NCSMechanismTestNetworksV2(test_plugin.TestNetworksV2, NCSTestCase):
+class NCSMechanismTestNetworksV2(test_plugin.TestMl2NetworksV2, NCSTestCase):
     pass
 
 
-class NCSMechanismTestPortsV2(test_plugin.TestPortsV2, NCSTestCase):
+class NCSMechanismTestPortsV2(test_plugin.TestMl2PortsV2, NCSTestCase):
     pass
index f9e348170a0c26011284ac8b96a8e38ee8c3d602..1242e86bb16742b89ef5fd829941a0ee0247986c 100644 (file)
@@ -23,28 +23,23 @@ from neutron.plugins.ml2 import driver_api as api
 from neutron.plugins.ml2.drivers import mechanism_odl
 from neutron.plugins.ml2 import plugin
 from neutron.tests import base
-from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit.ml2 import test_ml2_plugin as test_plugin
 from neutron.tests.unit import testlib_api
 
 PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
 
 
-class OpenDaylightTestCase(test_plugin.NeutronDbPluginV2TestCase):
+class OpenDaylightTestCase(test_plugin.Ml2PluginV2TestCase):
+    _mechanism_drivers = ['logger', 'opendaylight']
 
     def setUp(self):
-        # Enable the test mechanism driver to ensure that
-        # we can successfully call through to all mechanism
-        # driver apis.
-        config.cfg.CONF.set_override('mechanism_drivers',
-                                     ['logger', 'opendaylight'],
-                                     'ml2')
         # Set URL/user/pass so init doesn't throw a cfg required error.
         # They are not used in these tests since sendjson is overwritten.
         config.cfg.CONF.set_override('url', 'http://127.0.0.1:9999', 'ml2_odl')
         config.cfg.CONF.set_override('username', 'someuser', 'ml2_odl')
         config.cfg.CONF.set_override('password', 'somepass', 'ml2_odl')
 
-        super(OpenDaylightTestCase, self).setUp(PLUGIN_NAME)
+        super(OpenDaylightTestCase, self).setUp()
         self.port_create_status = 'DOWN'
         self.mech = mechanism_odl.OpenDaylightMechanismDriver()
         mechanism_odl.OpenDaylightMechanismDriver.sendjson = (
@@ -84,22 +79,22 @@ class OpenDayLightMechanismConfigTests(testlib_api.SqlTestCase):
         self._test_missing_config(password=None)
 
 
-class OpenDaylightMechanismTestBasicGet(test_plugin.TestBasicGet,
+class OpenDaylightMechanismTestBasicGet(test_plugin.TestMl2BasicGet,
                                         OpenDaylightTestCase):
     pass
 
 
-class OpenDaylightMechanismTestNetworksV2(test_plugin.TestNetworksV2,
+class OpenDaylightMechanismTestNetworksV2(test_plugin.TestMl2NetworksV2,
                                           OpenDaylightTestCase):
     pass
 
 
-class OpenDaylightMechanismTestSubnetsV2(test_plugin.TestSubnetsV2,
+class OpenDaylightMechanismTestSubnetsV2(test_plugin.TestMl2SubnetsV2,
                                          OpenDaylightTestCase):
     pass
 
 
-class OpenDaylightMechanismTestPortsV2(test_plugin.TestPortsV2,
+class OpenDaylightMechanismTestPortsV2(test_plugin.TestMl2PortsV2,
                                        OpenDaylightTestCase):
     pass