Merge "Use correct base class for unit tests for ML2 drivers"

This commit is contained in:
Jenkins
2014-11-19 15:24:37 +00:00
committed by Gerrit Code Review
6 changed files with 42 additions and 78 deletions

View 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 import config as ml2_config
from neutron.plugins.ml2.drivers.brocade import (mechanism_brocade from neutron.plugins.ml2.drivers.brocade import (mechanism_brocade
as brocademechanism) as brocademechanism)
from neutron.tests.unit import test_db_plugin from neutron.tests.unit.ml2 import test_ml2_plugin
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
MECHANISM_NAME = ('neutron.plugins.ml2.' MECHANISM_NAME = ('neutron.plugins.ml2.'
'drivers.brocade.mechanism_brocade.BrocadeMechanism') 'drivers.brocade.mechanism_brocade.BrocadeMechanism')
class TestBrocadeMechDriverV2(test_db_plugin.NeutronDbPluginV2TestCase): class TestBrocadeMechDriverV2(test_ml2_plugin.Ml2PluginV2TestCase):
"""Test Brocade VCS/VDX mechanism driver. """Test Brocade VCS/VDX mechanism driver.
""" """
@@ -53,17 +53,17 @@ class TestBrocadeMechDriverV2(test_db_plugin.NeutronDbPluginV2TestCase):
self.mechanism_driver = importutils.import_object(_mechanism_name) self.mechanism_driver = importutils.import_object(_mechanism_name)
class TestBrocadeMechDriverNetworksV2(test_db_plugin.TestNetworksV2, class TestBrocadeMechDriverNetworksV2(test_ml2_plugin.TestMl2NetworksV2,
TestBrocadeMechDriverV2): TestBrocadeMechDriverV2):
pass pass
class TestBrocadeMechDriverPortsV2(test_db_plugin.TestPortsV2, class TestBrocadeMechDriverPortsV2(test_ml2_plugin.TestMl2PortsV2,
TestBrocadeMechDriverV2): TestBrocadeMechDriverV2):
pass pass
class TestBrocadeMechDriverSubnetsV2(test_db_plugin.TestSubnetsV2, class TestBrocadeMechDriverSubnetsV2(test_ml2_plugin.TestMl2SubnetsV2,
TestBrocadeMechDriverV2): TestBrocadeMechDriverV2):
pass pass

View File

@@ -24,7 +24,6 @@ from neutron.extensions import portbindings
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as p_const 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_api as api
from neutron.plugins.ml2 import driver_context from neutron.plugins.ml2 import driver_context
from neutron.plugins.ml2.drivers.cisco.nexus import config as cisco_config 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 mech_cisco_nexus
from neutron.plugins.ml2.drivers.cisco.nexus import nexus_db_v2 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.cisco.nexus import nexus_network_driver
from neutron.plugins.ml2.drivers import type_vlan as vlan_config from neutron.tests.unit.ml2 import test_ml2_plugin
from neutron.tests.unit import test_db_plugin
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
ML2_PLUGIN = 'neutron.plugins.ml2.plugin.Ml2Plugin'
PHYS_NET = 'physnet1' PHYS_NET = 'physnet1'
COMP_HOST_NAME = 'testhost' COMP_HOST_NAME = 'testhost'
COMP_HOST_NAME_2 = 'testhost_2' 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} 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): def setUp(self):
"""Configure for end-to-end neutron testing using a mock ncclient. """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 # Configure the Cisco Nexus mechanism driver
nexus_config = { nexus_config = {
(NEXUS_IP_ADDR, 'username'): 'admin', (NEXUS_IP_ADDR, 'username'): 'admin',
@@ -135,7 +119,7 @@ class CiscoML2MechanismTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
'_is_status_active').start() '_is_status_active').start()
self.mock_status.side_effect = _mock_check_bind_state self.mock_status.side_effect = _mock_check_bind_state
super(CiscoML2MechanismTestCase, self).setUp(ML2_PLUGIN) super(CiscoML2MechanismTestCase, self).setUp()
self.port_create_status = 'DOWN' self.port_create_status = 'DOWN'
@@ -228,19 +212,19 @@ class CiscoML2MechanismTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
class TestCiscoBasicGet(CiscoML2MechanismTestCase, class TestCiscoBasicGet(CiscoML2MechanismTestCase,
test_db_plugin.TestBasicGet): test_ml2_plugin.TestMl2BasicGet):
pass pass
class TestCiscoV2HTTPResponse(CiscoML2MechanismTestCase, class TestCiscoV2HTTPResponse(CiscoML2MechanismTestCase,
test_db_plugin.TestV2HTTPResponse): test_ml2_plugin.TestMl2V2HTTPResponse):
pass pass
class TestCiscoPortsV2(CiscoML2MechanismTestCase, class TestCiscoPortsV2(CiscoML2MechanismTestCase,
test_db_plugin.TestPortsV2): test_ml2_plugin.TestMl2PortsV2):
@contextlib.contextmanager @contextlib.contextmanager
def _create_resources(self, name=NETWORK_NAME, cidr=CIDR_1, def _create_resources(self, name=NETWORK_NAME, cidr=CIDR_1,
@@ -718,7 +702,7 @@ class TestCiscoPortsV2(CiscoML2MechanismTestCase,
class TestCiscoNetworksV2(CiscoML2MechanismTestCase, class TestCiscoNetworksV2(CiscoML2MechanismTestCase,
test_db_plugin.TestNetworksV2): test_ml2_plugin.TestMl2NetworksV2):
def test_create_networks_bulk_emulated_plugin_failure(self): def test_create_networks_bulk_emulated_plugin_failure(self):
real_has_attr = hasattr real_has_attr = hasattr
@@ -769,7 +753,7 @@ class TestCiscoNetworksV2(CiscoML2MechanismTestCase,
class TestCiscoSubnetsV2(CiscoML2MechanismTestCase, class TestCiscoSubnetsV2(CiscoML2MechanismTestCase,
test_db_plugin.TestSubnetsV2): test_ml2_plugin.TestMl2SubnetsV2):
def test_create_subnets_bulk_emulated_plugin_failure(self): def test_create_subnets_bulk_emulated_plugin_failure(self):
real_has_attr = hasattr real_has_attr = hasattr

View File

@@ -19,18 +19,18 @@ from oslo.config import cfg
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.plugins.ml2.drivers.freescale import mechanism_fslsdn from neutron.plugins.ml2.drivers.freescale import mechanism_fslsdn
from neutron.tests import base 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.""" """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.""" """Testing mechanism driver with ML2 plugin."""
def setUp(self): def setUp(self):
cfg.CONF.set_override('mechanism_drivers', ['fslsdn'], 'ml2')
def mocked_fslsdn_init(self): def mocked_fslsdn_init(self):
# Mock CRD client, since it requires CRD service running. # Mock CRD client, since it requires CRD service running.
@@ -41,18 +41,18 @@ class TestFslSdnMechDriverV2(test_db_plugin.NeutronDbPluginV2TestCase):
super(TestFslSdnMechDriverV2, self).setUp() super(TestFslSdnMechDriverV2, self).setUp()
class TestFslSdnMechDriverNetworksV2(test_db_plugin.TestNetworksV2, class TestFslSdnMechDriverNetworksV2(test_ml2_plugin.TestMl2NetworksV2,
TestFslSdnMechDriverV2): TestFslSdnMechDriverV2):
pass pass
class TestFslSdnMechDriverPortsV2(test_db_plugin.TestPortsV2, class TestFslSdnMechDriverPortsV2(test_ml2_plugin.TestMl2PortsV2,
TestFslSdnMechDriverV2): TestFslSdnMechDriverV2):
VIF_TYPE = portbindings.VIF_TYPE_OVS VIF_TYPE = portbindings.VIF_TYPE_OVS
CAP_PORT_FILTER = True CAP_PORT_FILTER = True
class TestFslSdnMechDriverSubnetsV2(test_db_plugin.TestSubnetsV2, class TestFslSdnMechDriverSubnetsV2(test_ml2_plugin.TestMl2SubnetsV2,
TestFslSdnMechDriverV2): TestFslSdnMechDriverV2):
pass pass

View File

@@ -24,11 +24,10 @@ from neutron.extensions import portbindings
from neutron.extensions import providernet as pnet from neutron.extensions import providernet as pnet
from neutron import manager from neutron import manager
from neutron.openstack.common import timeutils 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.drivers.l2pop import mech_driver as l2pop_mech_driver
from neutron.plugins.ml2 import managers from neutron.plugins.ml2 import managers
from neutron.plugins.ml2 import rpc 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' HOST = 'my_l2_host'
L2_AGENT = { L2_AGENT = {
@@ -81,32 +80,23 @@ L2_AGENT_5 = {
'topic': constants.L2_AGENT_TOPIC, 'topic': constants.L2_AGENT_TOPIC,
'configurations': {'tunneling_ip': '20.0.0.5', 'configurations': {'tunneling_ip': '20.0.0.5',
'tunnel_types': [], 'tunnel_types': [],
'bridge_mappings': {'phys1': 'br'}, 'bridge_mappings': {'physnet1': 'br'},
'l2pop_network_types': ['vlan']}, 'l2pop_network_types': ['vlan']},
'agent_type': constants.AGENT_TYPE_OFA, 'agent_type': constants.AGENT_TYPE_OFA,
'tunnel_type': [], 'tunnel_type': [],
'start_flag': True 'start_flag': True
} }
PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
NOTIFIER = 'neutron.plugins.ml2.rpc.AgentNotifierApi' NOTIFIER = 'neutron.plugins.ml2.rpc.AgentNotifierApi'
DEVICE_OWNER_COMPUTE = 'compute:None' DEVICE_OWNER_COMPUTE = 'compute:None'
class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase): class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
_mechanism_drivers = ['openvswitch', 'linuxbridge',
'ofagent', 'l2population']
def setUp(self): def setUp(self):
# Enable the test mechanism driver to ensure that super(TestL2PopulationRpcTestCase, self).setUp()
# 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)
self.adminContext = context.get_admin_context() self.adminContext = context.get_admin_context()
@@ -122,7 +112,7 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
**net_arg) **net_arg)
net_arg = {pnet.NETWORK_TYPE: 'vlan', net_arg = {pnet.NETWORK_TYPE: 'vlan',
pnet.PHYSICAL_NETWORK: 'phys1', pnet.PHYSICAL_NETWORK: 'physnet1',
pnet.SEGMENTATION_ID: '2'} pnet.SEGMENTATION_ID: '2'}
self._network2 = self._make_network(self.fmt, 'net2', True, self._network2 = self._make_network(self.fmt, 'net2', True,
arg_list=(pnet.NETWORK_TYPE, arg_list=(pnet.NETWORK_TYPE,

View File

@@ -13,23 +13,18 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from neutron.plugins.ml2 import config as config
from neutron.plugins.ml2.drivers import mechanism_ncs 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): def setUp(self):
# Enable the test mechanism driver to ensure that # Enable the test mechanism driver to ensure that
# we can successfully call through to all mechanism # we can successfully call through to all mechanism
# driver apis. # driver apis.
config.cfg.CONF.set_override('mechanism_drivers', super(NCSTestCase, self).setUp()
['logger', 'ncs'],
'ml2')
super(NCSTestCase, self).setUp(PLUGIN_NAME)
self.port_create_status = 'DOWN' self.port_create_status = 'DOWN'
mechanism_ncs.NCSMechanismDriver.sendjson = self.check_sendjson mechanism_ncs.NCSMechanismDriver.sendjson = self.check_sendjson
@@ -38,13 +33,13 @@ class NCSTestCase(test_plugin.NeutronDbPluginV2TestCase):
self.assertFalse(urlpath.startswith("http://")) self.assertFalse(urlpath.startswith("http://"))
class NCSMechanismTestBasicGet(test_plugin.TestBasicGet, NCSTestCase): class NCSMechanismTestBasicGet(test_plugin.TestMl2BasicGet, NCSTestCase):
pass pass
class NCSMechanismTestNetworksV2(test_plugin.TestNetworksV2, NCSTestCase): class NCSMechanismTestNetworksV2(test_plugin.TestMl2NetworksV2, NCSTestCase):
pass pass
class NCSMechanismTestPortsV2(test_plugin.TestPortsV2, NCSTestCase): class NCSMechanismTestPortsV2(test_plugin.TestMl2PortsV2, NCSTestCase):
pass pass

View 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.drivers import mechanism_odl
from neutron.plugins.ml2 import plugin from neutron.plugins.ml2 import plugin
from neutron.tests import base 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 from neutron.tests.unit import testlib_api
PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin' PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
class OpenDaylightTestCase(test_plugin.NeutronDbPluginV2TestCase): class OpenDaylightTestCase(test_plugin.Ml2PluginV2TestCase):
_mechanism_drivers = ['logger', 'opendaylight']
def setUp(self): 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. # Set URL/user/pass so init doesn't throw a cfg required error.
# They are not used in these tests since sendjson is overwritten. # 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('url', 'http://127.0.0.1:9999', 'ml2_odl')
config.cfg.CONF.set_override('username', 'someuser', 'ml2_odl') config.cfg.CONF.set_override('username', 'someuser', 'ml2_odl')
config.cfg.CONF.set_override('password', 'somepass', '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.port_create_status = 'DOWN'
self.mech = mechanism_odl.OpenDaylightMechanismDriver() self.mech = mechanism_odl.OpenDaylightMechanismDriver()
mechanism_odl.OpenDaylightMechanismDriver.sendjson = ( mechanism_odl.OpenDaylightMechanismDriver.sendjson = (
@@ -84,22 +79,22 @@ class OpenDayLightMechanismConfigTests(testlib_api.SqlTestCase):
self._test_missing_config(password=None) self._test_missing_config(password=None)
class OpenDaylightMechanismTestBasicGet(test_plugin.TestBasicGet, class OpenDaylightMechanismTestBasicGet(test_plugin.TestMl2BasicGet,
OpenDaylightTestCase): OpenDaylightTestCase):
pass pass
class OpenDaylightMechanismTestNetworksV2(test_plugin.TestNetworksV2, class OpenDaylightMechanismTestNetworksV2(test_plugin.TestMl2NetworksV2,
OpenDaylightTestCase): OpenDaylightTestCase):
pass pass
class OpenDaylightMechanismTestSubnetsV2(test_plugin.TestSubnetsV2, class OpenDaylightMechanismTestSubnetsV2(test_plugin.TestMl2SubnetsV2,
OpenDaylightTestCase): OpenDaylightTestCase):
pass pass
class OpenDaylightMechanismTestPortsV2(test_plugin.TestPortsV2, class OpenDaylightMechanismTestPortsV2(test_plugin.TestMl2PortsV2,
OpenDaylightTestCase): OpenDaylightTestCase):
pass pass