fixed! In addition, before proposing for merge, all of the
current tests should be passing.
+Structure of the unit test tree
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The structure of the unit test tree should match the structure of the
+code tree, e.g. ::
+
+ - target module: neutron.agent.utils
+
+ - test module: neutron.tests.unit.agent.test_utils
+
+Unit test modules should have the same path under neutron/tests/unit/
+as the module they target has under neutron/, and their name should be
+the name of the target module prefixed by 'test_'. This requirement
+is intended to make it easier for developers to find the unit tests
+for a given module.
+
+Similarly, when a test module targets a package, that module's name
+should be the name of the package prefixed by 'test_' with the same
+path as when a test targets a module, e.g. ::
+
+ - target package: neutron.ipam
+
+ - test module: neutron.tests.unit.test_ipam
+
+The following command can be used to validate whether the unit test
+tree is structured according to the above requirements: ::
+
+ ./tools/check_unit_test_structure.sh
+
+Where appropriate, exceptions can be added to the above script. If
+code is not part of the neutron namespace, for example, it's probably
+reasonable to exclude their unit tests from the check.
+
Virtual environments
~~~~~~~~~~~~~~~~~~~~
paste.filter_factory = neutron.common.extensions:plugin_aware_extension_middleware_factory
[app:extensions_test_app]
-paste.app_factory = neutron.tests.unit.test_extensions:app_factory
+paste.app_factory = neutron.tests.unit.api.test_extensions:app_factory
from neutron.tests import base as tests_base
from neutron.tests.retargetable import client_fixtures
-from neutron.tests.unit.ml2 import test_ml2_plugin
+from neutron.tests.unit.plugins.ml2 import test_ml2_plugin
# Each plugin must add a class to plugin_configurations that can configure the
from neutron import context
from neutron.extensions import portbindings
from neutron import manager
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2
-class PortBindingsTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
+class PortBindingsTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
# VIF_TYPE must be overridden according to plugin vif_type
VIF_TYPE = portbindings.VIF_TYPE_OTHER
from neutron.agent import securitygroups_rpc as sg_cfg
from neutron.common import constants
from neutron.tests import base
-from neutron.tests.unit import test_api_v2
+from neutron.tests.unit.api.v2 import test_base
-_uuid = test_api_v2._uuid
+_uuid = test_base._uuid
#TODO(mangelajo): replace all 'IPv4', 'IPv6' to constants
FAKE_PREFIX = {'IPv4': '10.0.0.0/24',
'IPv6': 'fe80::/48'}
from neutron.extensions import securitygroup as ext_sg
from neutron import manager
from neutron.tests import base
-from neutron.tests.unit import test_extension_security_group as test_sg
+from neutron.tests.unit.extensions import test_securitygroup as test_sg
FAKE_PREFIX = {const.IPv4: '10.0.0.0/24',
const.IPv6: '2001:db8::/64'}
'IPv6_LLA': 'fe80::123',
'IPv6_DHCP': '2001:db8::3'}
-TEST_PLUGIN_CLASS = ('neutron.tests.unit.test_security_groups_rpc.'
+TEST_PLUGIN_CLASS = ('neutron.tests.unit.agent.test_securitygroups_rpc.'
'SecurityGroupRpcTestPlugin')
from neutron.plugins.ml2 import plugin as ml2_plugin
from neutron import quota
from neutron.tests import base
+from neutron.tests.unit.api.v2 import test_base
from neutron.tests.unit import extension_stubs as ext_stubs
import neutron.tests.unit.extensions
from neutron.tests.unit.extensions import extendedattribute as extattr
-from neutron.tests.unit import test_api_v2
from neutron.tests.unit import testlib_api
from neutron import wsgi
LOG = logging.getLogger(__name__)
-_uuid = test_api_v2._uuid
-_get_path = test_api_v2._get_path
+_uuid = test_base._uuid
+_get_path = test_base._get_path
extensions_path = ':'.join(neutron.tests.unit.extensions.__path__)
def setUp(self):
super(ExtensionExtendedAttributeTestCase, self).setUp()
plugin = (
- "neutron.tests.unit.test_extensions."
+ "neutron.tests.unit.api.test_extensions."
"ExtensionExtendedAttributeTestPlugin"
)
def setUp(self):
super(SubresourceTest, self).setUp()
- plugin = 'neutron.tests.unit.test_api_v2.TestSubresourcePlugin'
+ plugin = 'neutron.tests.unit.api.v2.test_base.TestSubresourcePlugin'
extensions.PluginAwareExtensionManager._instance = None
# Save the global RESOURCE_ATTRIBUTE_MAP
from neutron.extensions import metering
from neutron.plugins.common import constants
from neutron.services.metering import metering_plugin
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2
DB_METERING_PLUGIN_KLASS = (
"neutron.services.metering."
yield metering_label_rule
-class MeteringPluginDbTestCase(test_db_plugin.NeutronDbPluginV2TestCase,
- MeteringPluginDbTestCaseMixin):
+class MeteringPluginDbTestCase(
+ test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
+ MeteringPluginDbTestCaseMixin):
fmt = 'json'
resource_prefix_map = dict(
from neutron.extensions import portsecurity as psec
from neutron.extensions import securitygroup as secgroup
from neutron import manager
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2
from oslo_config import cfg
-DB_PLUGIN_KLASS = ('neutron.tests.unit.test_extension_allowedaddresspairs.'
+DB_PLUGIN_KLASS = ('neutron.tests.unit.db.test_allowedaddresspairs_db.'
'AllowedAddressPairTestPlugin')
-class AllowedAddressPairTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
+class AllowedAddressPairTestCase(
+ test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
def setUp(self, plugin=None, ext_mgr=None):
super(AllowedAddressPairTestCase, self).setUp(plugin)
from neutron.db import models_v2
from neutron import manager
from neutron.tests import base
-from neutron.tests.unit import test_extensions
+from neutron.tests.unit.api import test_extensions
from neutron.tests.unit import testlib_api
DB_PLUGIN_KLASS = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2'
from neutron.api import extensions
from neutron.api.v2 import attributes
from neutron import quota
-from neutron.tests.unit import test_api_v2
-from neutron.tests.unit import test_extensions
+from neutron.tests.unit.api import test_extensions
+from neutron.tests.unit.api.v2 import test_base
from neutron.tests.unit import testlib_api
if self._translate_resource_name:
path = path.replace('_', '-')
res = self.api.delete(
- test_api_v2._get_path(path, id=entity_id, fmt=self.fmt))
+ test_base._get_path(path, id=entity_id, fmt=self.fmt))
delete_entity = getattr(self.plugin.return_value, "delete_" + entity)
delete_entity.assert_called_with(mock.ANY, entity_id)
self.assertEqual(res.status_int, exc.HTTPNoContent.code)
from neutron.db import db_base_plugin_v2
from neutron.extensions import agent
from neutron.openstack.common import uuidutils
-from neutron.tests.unit import test_api_v2
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.api.v2 import test_base
+from neutron.tests.unit.db import test_db_base_plugin_v2
LOG = logging.getLogger(__name__)
_uuid = uuidutils.generate_uuid
-_get_path = test_api_v2._get_path
+_get_path = test_base._get_path
L3_HOSTA = 'hosta'
DHCP_HOSTA = 'hosta'
L3_HOSTB = 'hostb'
class AgentDBTestCase(AgentDBTestMixIn,
- test_db_plugin.NeutronDbPluginV2TestCase):
+ test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
fmt = 'json'
def setUp(self):
- plugin = 'neutron.tests.unit.test_agent_ext_plugin.TestAgentPlugin'
+ plugin = 'neutron.tests.unit.extensions.test_agent.TestAgentPlugin'
# for these tests we need to enable overlapping ips
cfg.CONF.set_default('allow_overlapping_ips', True)
# Save the original RESOURCE_ATTRIBUTE_MAP
from neutron.extensions import external_net as external_net
from neutron import manager
from neutron.openstack.common import uuidutils
-from neutron.tests.unit import test_api_v2
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.api.v2 import test_base
+from neutron.tests.unit.db import test_db_base_plugin_v2
LOG = logging.getLogger(__name__)
_uuid = uuidutils.generate_uuid
-_get_path = test_api_v2._get_path
+_get_path = test_base._get_path
class ExtNetTestExtensionManager(object):
return []
-class ExtNetDBTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
+class ExtNetDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
def _create_network(self, fmt, name, admin_state_up, **kwargs):
"""Override the routine for allowing the router:external attribute."""
fmt, name, admin_state_up, arg_list=arg_list, **new_args)
def setUp(self):
- plugin = 'neutron.tests.unit.test_l3_plugin.TestNoL3NatPlugin'
+ plugin = 'neutron.tests.unit.extensions.test_l3.TestNoL3NatPlugin'
ext_mgr = ExtNetTestExtensionManager()
super(ExtNetDBTestCase, self).setUp(plugin=plugin, ext_mgr=ext_mgr)
from neutron.db import db_base_plugin_v2
from neutron.db import extradhcpopt_db as edo_db
from neutron.extensions import extra_dhcp_opt as edo_ext
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2
LOG = logging.getLogger(__name__)
DB_PLUGIN_KLASS = (
- 'neutron.tests.unit.test_extension_extradhcpopts.ExtraDhcpOptTestPlugin')
+ 'neutron.tests.unit.extensions.test_extra_dhcp_opt.ExtraDhcpOptTestPlugin')
class ExtraDhcpOptTestPlugin(db_base_plugin_v2.NeutronDbPluginV2,
return rtn_port
-class ExtraDhcpOptDBTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
+class ExtraDhcpOptDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
def setUp(self, plugin=DB_PLUGIN_KLASS):
super(ExtraDhcpOptDBTestCase, self).setUp(plugin=plugin)
from neutron.extensions import extraroute
from neutron.extensions import l3
from neutron.openstack.common import uuidutils
-from neutron.tests.unit import test_api_v2
-from neutron.tests.unit import test_l3_plugin as test_l3
+from neutron.tests.unit.api.v2 import test_base
+from neutron.tests.unit.extensions import test_l3 as test_l3
LOG = logging.getLogger(__name__)
_uuid = uuidutils.generate_uuid
-_get_path = test_api_v2._get_path
+_get_path = test_base._get_path
class ExtraRouteTestExtensionManager(object):
def setUp(self, plugin=None, ext_mgr=None):
if not plugin:
- plugin = ('neutron.tests.unit.test_extension_extraroute.'
+ plugin = ('neutron.tests.unit.extensions.test_extraroute.'
'TestExtraRouteIntPlugin')
# for these tests we need to enable overlapping ips
cfg.CONF.set_default('allow_overlapping_ips', True)
ExtraRouteDBTestCaseBase):
def setUp(self):
# the plugin without L3 support
- plugin = 'neutron.tests.unit.test_l3_plugin.TestNoL3NatPlugin'
+ plugin = 'neutron.tests.unit.extensions.test_l3.TestNoL3NatPlugin'
# the L3 service plugin
- l3_plugin = ('neutron.tests.unit.test_extension_extraroute.'
+ l3_plugin = ('neutron.tests.unit.extensions.test_extraroute.'
'TestExtraRouteL3NatServicePlugin')
service_plugins = {'l3_plugin_name': l3_plugin}
from neutron.plugins.common import constants as service_constants
from neutron.tests import base
from neutron.tests import fake_notifier
-from neutron.tests.unit import test_agent_ext_plugin
-from neutron.tests.unit import test_api_v2
-from neutron.tests.unit import test_api_v2_extension
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.api.v2 import test_base
+from neutron.tests.unit.db import test_db_base_plugin_v2
+from neutron.tests.unit.extensions import base as test_extensions_base
+from neutron.tests.unit.extensions import test_agent
LOG = logging.getLogger(__name__)
_uuid = uuidutils.generate_uuid
-_get_path = test_api_v2._get_path
+_get_path = test_base._get_path
class L3TestExtensionManager(object):
return []
-class L3NatExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
+class L3NatExtensionTestCase(test_extensions_base.ExtensionTestCase):
fmt = 'json'
def setUp(self):
private_port = None
if port_id:
private_port = self._show('ports', port_id)
- with test_db_plugin.optional_ctx(private_port,
+ with test_db_base_plugin_v2.optional_ctx(private_port,
self.port) as private_port:
with self.router() as r:
sid = private_port['port']['fixed_ips'][0]['subnet_id']
self._test_notify_op_agent(self._test_floatingips_op_agent)
-class L3BaseForIntTests(test_db_plugin.NeutronDbPluginV2TestCase):
+class L3BaseForIntTests(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
mock_rescheduling = True
def setUp(self, plugin=None, ext_mgr=None, service_plugins=None):
if not plugin:
- plugin = 'neutron.tests.unit.test_l3_plugin.TestL3NatIntPlugin'
+ plugin = 'neutron.tests.unit.extensions.test_l3.TestL3NatIntPlugin'
# for these tests we need to enable overlapping ips
cfg.CONF.set_default('allow_overlapping_ips', True)
ext_mgr = ext_mgr or L3TestExtensionManager()
self.setup_notification_driver()
-class L3BaseForSepTests(test_db_plugin.NeutronDbPluginV2TestCase):
+class L3BaseForSepTests(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
def setUp(self, plugin=None, ext_mgr=None):
# the plugin without L3 support
if not plugin:
- plugin = 'neutron.tests.unit.test_l3_plugin.TestNoL3NatPlugin'
+ plugin = 'neutron.tests.unit.extensions.test_l3.TestNoL3NatPlugin'
# the L3 service plugin
- l3_plugin = ('neutron.tests.unit.test_l3_plugin.'
+ l3_plugin = ('neutron.tests.unit.extensions.test_l3.'
'TestL3NatServicePlugin')
service_plugins = {'l3_plugin_name': l3_plugin}
class L3NatDBIntAgentSchedulingTestCase(L3BaseForIntTests,
L3NatTestCaseMixin,
- test_agent_ext_plugin.
+ test_agent.
AgentDBTestMixIn):
"""Unit tests for core plugin with L3 routing and scheduling integrated."""
- def setUp(self, plugin='neutron.tests.unit.test_l3_plugin.'
+ def setUp(self, plugin='neutron.tests.unit.extensions.test_l3.'
'TestL3NatIntAgentSchedulingPlugin',
ext_mgr=None, service_plugins=None):
self.mock_rescheduling = False
from neutron.extensions import l3
from neutron.extensions import l3_ext_gw_mode
from neutron.openstack.common import uuidutils
-from neutron.tests.unit import test_db_plugin
-from neutron.tests.unit import test_l3_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2
+from neutron.tests.unit.extensions import test_l3
from neutron.tests.unit import testlib_api
_uuid = uuidutils.generate_uuid
# A simple class for making a concrete class out of the mixin
# for the case of a plugin that integrates l3 routing.
-class TestDbIntPlugin(test_l3_plugin.TestL3NatIntPlugin,
+class TestDbIntPlugin(test_l3.TestL3NatIntPlugin,
l3_gwmode_db.L3_NAT_db_mixin):
supported_extension_aliases = ["external-net", "router", "ext-gw-mode"]
# A simple class for making a concrete class out of the mixin
# for the case of a l3 router service plugin
-class TestDbSepPlugin(test_l3_plugin.TestL3NatServicePlugin,
+class TestDbSepPlugin(test_l3.TestL3NatServicePlugin,
l3_gwmode_db.L3_NAT_db_mixin):
supported_extension_aliases = ["router", "ext-gw-mode"]
self.assertIsNone(router.get('enable_snat'))
-class ExtGwModeIntTestCase(test_db_plugin.NeutronDbPluginV2TestCase,
- test_l3_plugin.L3NatTestCaseMixin):
+class ExtGwModeIntTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
+ test_l3.L3NatTestCaseMixin):
def setUp(self, plugin=None, svc_plugins=None, ext_mgr=None):
# Store l3 resource attribute map as it will be updated
self._l3_attribute_map_bk[item] = (
l3.RESOURCE_ATTRIBUTE_MAP[item].copy())
plugin = plugin or (
- 'neutron.tests.unit.test_extension_ext_gw_mode.TestDbIntPlugin')
+ 'neutron.tests.unit.extensions.test_l3_ext_gw_mode.'
+ 'TestDbIntPlugin')
# for these tests we need to enable overlapping ips
cfg.CONF.set_default('allow_overlapping_ips', True)
ext_mgr = ext_mgr or TestExtensionManager()
self._l3_attribute_map_bk[item] = (
l3.RESOURCE_ATTRIBUTE_MAP[item].copy())
plugin = plugin or (
- 'neutron.tests.unit.test_l3_plugin.TestNoL3NatPlugin')
+ 'neutron.tests.unit.extensions.test_l3.TestNoL3NatPlugin')
# the L3 service plugin
- l3_plugin = ('neutron.tests.unit.test_extension_ext_gw_mode.'
+ l3_plugin = ('neutron.tests.unit.extensions.test_l3_ext_gw_mode.'
'TestDbSepPlugin')
svc_plugins = {'l3_plugin_name': l3_plugin}
# for these tests we need to enable overlapping ips
from neutron.db import db_base_plugin_v2
from neutron.db import netmtu_db
from neutron.extensions import netmtu
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2
class NetmtuExtensionManager(object):
supported_extension_aliases = ["net-mtu"]
-class NetmtuExtensionTestCase(test_db_plugin.TestNetworksV2):
+class NetmtuExtensionTestCase(test_db_base_plugin_v2.TestNetworksV2):
"""Test API extension net-mtu attributes.
"""
def setUp(self):
- plugin = ('neutron.tests.unit.test_extension_netmtu.' +
+ plugin = ('neutron.tests.unit.extensions.test_netmtu.' +
'NetmtuExtensionTestPlugin')
ext_mgr = NetmtuExtensionManager()
super(NetmtuExtensionTestCase, self).setUp(plugin=plugin,
from neutron.extensions import portsecurity as psec
from neutron.extensions import securitygroup as ext_sg
from neutron import manager
-from neutron.tests.unit import test_db_plugin
-from neutron.tests.unit import test_extension_security_group
+from neutron.tests.unit.db import test_db_base_plugin_v2
+from neutron.tests.unit.extensions import test_securitygroup
-DB_PLUGIN_KLASS = ('neutron.tests.unit.test_extension_portsecurity.'
+DB_PLUGIN_KLASS = ('neutron.tests.unit.extensions.test_portsecurity.'
'PortSecurityTestPlugin')
class PortSecurityTestCase(
- test_extension_security_group.SecurityGroupsTestCase,
- test_db_plugin.NeutronDbPluginV2TestCase):
+ test_securitygroup.SecurityGroupsTestCase,
+ test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
def setUp(self, plugin=None):
ext_mgr = (
- test_extension_security_group.SecurityGroupTestExtensionManager())
+ test_securitygroup.SecurityGroupTestExtensionManager())
super(PortSecurityTestCase, self).setUp(plugin=plugin, ext_mgr=ext_mgr)
# Check if a plugin supports security groups
from neutron import manager
from neutron.openstack.common import uuidutils
from neutron import quota
-from neutron.tests.unit import test_api_v2
-from neutron.tests.unit import test_extensions
+from neutron.tests.unit.api import test_extensions
+from neutron.tests.unit.api.v2 import test_base
from neutron.tests.unit import testlib_api
instance.get_network.return_value = {'tenant_id': ctx.tenant_id,
'shared': False}
net_id = uuidutils.generate_uuid()
- res = self.api.put(test_api_v2._get_path('networks',
- id=net_id,
- fmt=self.fmt),
+ res = self.api.put(test_base._get_path('networks',
+ id=net_id,
+ fmt=self.fmt),
self.serialize({'network': data}),
extra_environ=env,
expect_errors=expect_errors)
def _post_network_with_provider_attrs(self, ctx, expect_errors=False):
data = self._prepare_net_data()
env = {'neutron.context': ctx}
- res = self.api.post(test_api_v2._get_path('networks', fmt=self.fmt),
+ res = self.api.post(test_base._get_path('networks', fmt=self.fmt),
self.serialize({'network': data}),
content_type='application/' + self.fmt,
extra_environ=env,
data = self._prepare_net_data()
data.update(bad_data)
env = {'neutron.context': ctx}
- res = self.api.post(test_api_v2._get_path('networks', fmt=self.fmt),
+ res = self.api.post(test_base._get_path('networks', fmt=self.fmt),
self.serialize({'network': data}),
content_type='application/' + self.fmt,
extra_environ=env,
from neutron.db import quota_db
from neutron import quota
from neutron.tests import base
-from neutron.tests.unit import test_api_v2
+from neutron.tests.unit.api.v2 import test_base
from neutron.tests.unit import testlib_api
TARGET_PLUGIN = 'neutron.plugins.ml2.plugin.Ml2Plugin'
-_get_path = test_api_v2._get_path
+_get_path = test_base._get_path
class QuotaExtensionTestCase(testlib_api.WebTestCase):
from neutron.extensions import securitygroup as ext_sg
from neutron import manager
from neutron.tests import base
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2
-DB_PLUGIN_KLASS = ('neutron.tests.unit.test_extension_security_group.'
+DB_PLUGIN_KLASS = ('neutron.tests.unit.extensions.test_securitygroup.'
'SecurityGroupTestPlugin')
return []
-class SecurityGroupsTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
+class SecurityGroupsTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
def _create_security_group(self, fmt, name, description, **kwargs):
from neutron.extensions import servicetype
from neutron.plugins.common import constants
from neutron.services import provider_configuration as provconf
+from neutron.tests.unit.api import test_extensions
+from neutron.tests.unit.api.v2 import test_base
+from neutron.tests.unit.db import test_db_base_plugin_v2
from neutron.tests.unit import dummy_plugin as dp
-from neutron.tests.unit import test_api_v2
-from neutron.tests.unit import test_db_plugin
-from neutron.tests.unit import test_extensions
from neutron.tests.unit import testlib_api
DEFAULT_SERVICE_DEFS = [{'service_class': constants.DUMMY,
'plugin': dp.DUMMY_PLUGIN_NAME}]
-_uuid = test_api_v2._uuid
-_get_path = test_api_v2._get_path
+_uuid = test_base._uuid
+_get_path = test_base._get_path
class ServiceTypeManagerTestCase(testlib_api.SqlTestCase):
def setUp(self):
# This is needed because otherwise a failure will occur due to
# nonexisting core_plugin
- self.setup_coreplugin(test_db_plugin.DB_PLUGIN_KLASS)
+ self.setup_coreplugin(test_db_base_plugin_v2.DB_PLUGIN_KLASS)
cfg.CONF.set_override('service_plugins',
["%s.%s" % (dp.__name__,
from neutron.ipam import subnet_alloc
from neutron import manager
from neutron.openstack.common import uuidutils
-from neutron.tests.unit import test_db_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2
from neutron.tests.unit import testlib_api
def setUp(self):
super(TestSubnetAllocation, self).setUp()
self._tenant_id = 'test-tenant'
- self.setup_coreplugin(test_db_plugin.DB_PLUGIN_KLASS)
+ self.setup_coreplugin(test_db_base_plugin_v2.DB_PLUGIN_KLASS)
self.plugin = manager.NeutronManager.get_plugin()
self.ctx = context.get_admin_context()
cfg.CONF.set_override('allow_overlapping_ips', True)
from neutron import context
from neutron.plugins.brocade.db import models as brocade_db
-from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
TEST_VLAN = 1000
from neutron.extensions import portbindings
from neutron.plugins.brocade import NeutronPlugin as brocade_plugin
from neutron.tests.unit import _test_extension_portbindings as test_bindings
-from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
PLUGIN_NAME = ('neutron.plugins.brocade.'
from neutron.plugins.cisco.common import cisco_exceptions as c_exc
from neutron.plugins.cisco.db import n1kv_db_v2
from neutron.plugins.cisco.db import n1kv_models_v2
-from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
from neutron.tests.unit import testlib_api
from neutron.plugins.cisco.n1kv import n1kv_client
from neutron.plugins.cisco.n1kv import n1kv_neutron_plugin
from neutron.tests.unit import _test_extension_portbindings as test_bindings
-from neutron.tests.unit.cisco.n1kv import fake_client
-from neutron.tests.unit import test_api_v2
-from neutron.tests.unit import test_db_plugin as test_plugin
-from neutron.tests.unit import test_l3_plugin
-from neutron.tests.unit import test_l3_schedulers
+from neutron.tests.unit.api.v2 import test_base
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
+from neutron.tests.unit.extensions import test_l3
+from neutron.tests.unit.plugins.cisco.n1kv import fake_client
+from neutron.tests.unit.scheduler import test_l3_agent_scheduler
PHYS_NET = 'some-phys-net'
create. Default argument value chosen to correspond to the
default name specified in config.py file.
"""
- uuid = test_api_v2._uuid()
+ uuid = test_base._uuid()
profile = {'id': uuid,
'name': name}
return n1kv_db_v2.create_policy_profile(profile)
self.assertEqual(1, mock_method.call_count)
-class TestN1kvL3Test(test_l3_plugin.L3NatExtensionTestCase):
+class TestN1kvL3Test(test_l3.L3NatExtensionTestCase):
pass
-class TestN1kvL3SchedulersTest(test_l3_schedulers.L3SchedulerTestCase):
+class TestN1kvL3SchedulersTest(test_l3_agent_scheduler.L3SchedulerTestCase):
pass
from oslo_config import cfg
from neutron.plugins.embrane.common import config # noqa
-from neutron.tests.unit import test_extension_extraroute as extraroute_test
+from neutron.tests.unit.extensions import test_extraroute as extraroute_test
PLUGIN_NAME = ('neutron.plugins.embrane.plugins.embrane_fake_plugin.'
'EmbraneFakePlugin')
from oslo_config import cfg
from neutron.plugins.embrane.common import config # noqa
-from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
PLUGIN_NAME = ('neutron.plugins.embrane.plugins.embrane_fake_plugin.'
'EmbraneFakePlugin')
from neutron.extensions import portbindings
from neutron.tests.unit import _test_extension_portbindings as test_bindings
-from neutron.tests.unit import test_db_plugin as test_plugin
-from neutron.tests.unit import test_l3_plugin as test_l3_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
+from neutron.tests.unit.extensions import test_l3 as test_l3
from neutron.plugins.ibm.common import constants
VIF_TYPE = portbindings.VIF_TYPE_OVS
-class IBMPluginRouterTestCase(test_l3_plugin.L3NatDBIntTestCase):
+class IBMPluginRouterTestCase(test_l3.L3NatDBIntTestCase):
def setUp(self):
with contextlib.nested(
from neutron.plugins.ml2.drivers.cisco.apic import mechanism_apic as md
from neutron.plugins.ml2.drivers import type_vlan # noqa
from neutron.tests import base
-from neutron.tests.unit.ml2.drivers.cisco.apic import (
+from neutron.tests.unit.plugins.ml2.drivers.cisco.apic import (
test_cisco_apic_common as mocked)
from neutron.plugins.ml2.drivers.cisco.apic import apic_topology
from neutron.tests import base
-from neutron.tests.unit.ml2.drivers.cisco.apic import (
+from neutron.tests.unit.plugins.ml2.drivers.cisco.apic import (
test_cisco_apic_common as mocked)
NOTIFIER = ('neutron.plugins.ml2.drivers.cisco.apic.'
# under the License.
from neutron.plugins.ml2.drivers.cisco.ncs import driver
-from neutron.tests.unit.ml2 import test_ml2_plugin as test_plugin
+from neutron.tests.unit.plugins.ml2 import test_ml2_plugin as test_plugin
class NCSTestCase(test_plugin.Ml2PluginV2TestCase):
from neutron.db import model_base
from neutron.db import models_v2
from neutron.plugins.ml2 import driver_api
-from neutron.tests.unit.ml2 import extensions as test_extensions
+from neutron.tests.unit.plugins.ml2 import extensions as test_extensions
class TestExtensionDriverBase(driver_api.ExtensionDriver):
from neutron.extensions import portbindings
from neutron.plugins.ml2.drivers.freescale import mechanism_fslsdn
from neutron.tests import base
-from neutron.tests.unit.ml2 import test_ml2_plugin
+from neutron.tests.unit.plugins.ml2 import test_ml2_plugin
"""Unit testing for Freescale SDN mechanism driver."""
from neutron.plugins.ml2 import driver_api as api
from neutron.plugins.ml2.drivers.mech_sriov import exceptions as exc
from neutron.plugins.ml2.drivers.mech_sriov import mech_driver
-from neutron.tests.unit.ml2 import _test_mech_agent as base
+from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
MELLANOX_CONNECTX3_PCI_INFO = '15b3:1004'
DEFAULT_PCI_INFO = ['15b3:1004', '8086:10ca']
from neutron.plugins.ml2 import managers
from neutron.plugins.ml2 import rpc
from neutron.tests import base
-from neutron.tests.unit.ml2 import test_ml2_plugin as test_plugin
+from neutron.tests.unit.plugins.ml2 import test_ml2_plugin as test_plugin
HOST = 'my_l2_host'
L2_AGENT = {
from neutron.common import constants
from neutron.extensions import portbindings
from neutron.plugins.ml2 import driver_api as api
-from neutron.tests.unit.ml2 import _test_mech_agent as base
+from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
m_const_mock = mock.Mock()
# License for the specific language governing permissions and limitations
# under the License.
-from neutron.tests.unit.ml2 import test_ml2_plugin
-from neutron.tests.unit.openvswitch import test_agent_scheduler
+from neutron.tests.unit.plugins.ml2 import test_ml2_plugin
+from neutron.tests.unit.plugins.openvswitch import test_agent_scheduler
class Ml2AgentSchedulerTestCase(
# under the License.
from neutron.plugins.ml2 import config
-from neutron.tests.unit.ml2 import test_ml2_plugin
-from neutron.tests.unit import test_extension_portsecurity as test_psec
+from neutron.tests.unit.extensions import test_portsecurity as test_psec
+from neutron.tests.unit.plugins.ml2 import test_ml2_plugin
class PSExtDriverTestCase(test_ml2_plugin.Ml2PluginV2TestCase,
from neutron import context
from neutron import manager
from neutron.plugins.ml2 import config
-from neutron.tests.unit.ml2.drivers import ext_test
-from neutron.tests.unit.ml2 import test_ml2_plugin
+from neutron.tests.unit.plugins.ml2.drivers import ext_test
+from neutron.tests.unit.plugins.ml2 import test_ml2_plugin
class ExtensionDriverTestCase(test_ml2_plugin.Ml2PluginV2TestCase):
from neutron.common import constants
from neutron.extensions import portbindings
from neutron.plugins.ml2.drivers import mech_linuxbridge
-from neutron.tests.unit.ml2 import _test_mech_agent as base
+from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
class LinuxbridgeMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
from neutron.common import constants
from neutron.extensions import portbindings
from neutron.plugins.ml2.drivers import mech_openvswitch
-from neutron.tests.unit.ml2 import _test_mech_agent as base
+from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
class OpenvswitchMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
import mock
from neutron import context
-from neutron.tests.unit.ml2 import test_ml2_plugin as test_plugin
+from neutron.tests.unit.plugins.ml2 import test_ml2_plugin as test_plugin
with mock.patch.dict(sys.modules,
from neutron.plugins.ml2 import plugin as ml2_plugin
from neutron.tests import base
from neutron.tests.unit import _test_extension_portbindings as test_bindings
-from neutron.tests.unit.ml2.drivers import mechanism_logger as mech_logger
-from neutron.tests.unit.ml2.drivers import mechanism_test as mech_test
-from neutron.tests.unit import test_db_plugin as test_plugin
-from neutron.tests.unit import test_extension_allowedaddresspairs as test_pair
-from neutron.tests.unit import test_extension_extradhcpopts as test_dhcpopts
-from neutron.tests.unit import test_security_groups_rpc as test_sg_rpc
+from neutron.tests.unit.agent import test_securitygroups_rpc as test_sg_rpc
+from neutron.tests.unit.db import test_allowedaddresspairs_db as test_pair
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
+from neutron.tests.unit.extensions import test_extra_dhcp_opt as test_dhcpopts
+from neutron.tests.unit.plugins.ml2.drivers import mechanism_logger as \
+ mech_logger
+from neutron.tests.unit.plugins.ml2.drivers import mechanism_test as mech_test
config.cfg.CONF.import_opt('network_vlan_ranges',
def setup_parent(self):
"""Perform parent setup with the common plugin configuration class."""
- l3_plugin = ('neutron.tests.unit.test_l3_plugin.'
+ l3_plugin = ('neutron.tests.unit.extensions.test_l3.'
'TestL3NatServicePlugin')
service_plugins = {'l3_plugin_name': l3_plugin}
# Ensure that the parent setup can be called without arguments
from neutron import manager
from neutron.plugins.ml2 import config as config
from neutron.plugins.ml2 import models as ml2_models
-from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
from neutron.common import constants as const
from neutron.extensions import securitygroup as ext_sg
from neutron import manager
-from neutron.tests.unit import test_api_v2
-from neutron.tests.unit import test_extension_security_group as test_sg
-from neutron.tests.unit import test_security_groups_rpc as test_sg_rpc
+from neutron.tests.unit.agent import test_securitygroups_rpc as test_sg_rpc
+from neutron.tests.unit.api.v2 import test_base
+from neutron.tests.unit.extensions import test_securitygroup as test_sg
PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
NOTIFIER = 'neutron.plugins.ml2.rpc.AgentNotifierApi'
# return no ports to exit the method early since we are mocking
# the query
fmock.return_value.all.return_value = []
- plugin.get_ports_from_devices([test_api_v2._uuid(),
- test_api_v2._uuid()])
+ plugin.get_ports_from_devices([test_base._uuid(),
+ test_base._uuid()])
# the or_ function should only have one argument
or_mock.assert_called_once_with(mock.ANY)
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2 import config
from neutron.plugins.ml2.drivers import type_gre
-from neutron.tests.unit.ml2 import test_rpcapi
-from neutron.tests.unit.ml2 import test_type_tunnel
+from neutron.tests.unit.plugins.ml2 import test_rpcapi
+from neutron.tests.unit.plugins.ml2 import test_type_tunnel
from neutron.tests.unit import testlib_api
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2 import config
from neutron.plugins.ml2.drivers import type_vxlan
-from neutron.tests.unit.ml2 import test_rpcapi
-from neutron.tests.unit.ml2 import test_type_tunnel
+from neutron.tests.unit.plugins.ml2 import test_rpcapi
+from neutron.tests.unit.plugins.ml2 import test_type_tunnel
from neutron.tests.unit import testlib_api
from neutron import manager
from neutron.plugins.oneconvergence import plugin as nvsd_plugin
from neutron.tests.unit import _test_extension_portbindings as test_bindings
-from neutron.tests.unit import test_db_plugin as test_plugin
-from neutron.tests.unit import test_l3_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
+from neutron.tests.unit.extensions import test_l3
PLUGIN_NAME = 'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2'
pass
-class TestOneConvergenceL3NatTestCase(test_l3_plugin.L3NatDBIntTestCase):
+class TestOneConvergenceL3NatTestCase(test_l3.L3NatDBIntTestCase):
_plugin_name = PLUGIN_NAME
def setUp(self):
self.nvsdlib = mock.Mock()
self.nvsdlib.create_network.side_effect = side_effect
- ext_mgr = test_l3_plugin.L3TestExtensionManager()
+ ext_mgr = test_l3.L3TestExtensionManager()
with mock.patch.object(nvsd_plugin.OneConvergencePluginV2,
'oneconvergence_init',
from neutron.extensions import securitygroup as ext_sg
from neutron import manager
from neutron.plugins.oneconvergence import plugin as nvsd_plugin
-from neutron.tests.unit import test_extension_security_group as test_sg
-from neutron.tests.unit import test_security_groups_rpc as test_sg_rpc
+from neutron.tests.unit.agent import test_securitygroups_rpc as test_sg_rpc
+from neutron.tests.unit.extensions import test_securitygroup as test_sg
PLUGIN_NAME = ('neutron.plugins.oneconvergence.'
'plugin.OneConvergencePluginV2')
AGENTNOTIFIER = ('neutron.plugins.oneconvergence.'
'plugin.NVSDPluginV2AgentNotifierApi')
-DUMMY_NVSD_LIB = ('neutron.tests.unit.oneconvergence.dummynvsdlib.NVSDApi')
+DUMMY_NVSD_LIB = ('neutron.tests.unit.plugins.oneconvergence.'
+ 'dummynvsdlib.NVSDApi')
class OneConvergenceSecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase):
from neutron.extensions import portbindings
from neutron.extensions import securitygroup as ext_sg
from neutron.tests.unit import _test_extension_portbindings as test_bindings
-from neutron.tests.unit import test_db_plugin as test_plugin
-from neutron.tests.unit import test_extension_security_group as test_sg
-from neutron.tests.unit import test_extensions
-from neutron.tests.unit import test_l3_plugin
+from neutron.tests.unit.api import test_extensions
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
+from neutron.tests.unit.extensions import test_l3
+from neutron.tests.unit.extensions import test_securitygroup as test_sg
CONTRAIL_PKG_PATH = "neutron.plugins.opencontrail.contrail_plugin"
class TestContrailL3NatTestCase(ContrailPluginTestCase,
- test_l3_plugin.L3NatDBIntTestCase):
+ test_l3.L3NatDBIntTestCase):
mock_rescheduling = False
def setUp(self):
from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants as service_constants
from neutron.tests import fake_notifier
-from neutron.tests.unit import test_agent_ext_plugin
-from neutron.tests.unit import test_db_plugin as test_plugin
-from neutron.tests.unit import test_extensions
-from neutron.tests.unit import test_l3_plugin
+from neutron.tests.unit.api import test_extensions
+from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
+from neutron.tests.unit.extensions import test_agent
+from neutron.tests.unit.extensions import test_l3
from neutron.tests.unit import testlib_api
from neutron import wsgi
return agent_data['id']
-class OvsAgentSchedulerTestCaseBase(test_l3_plugin.L3NatTestCaseMixin,
- test_agent_ext_plugin.AgentDBTestMixIn,
+class OvsAgentSchedulerTestCaseBase(test_l3.L3NatTestCaseMixin,
+ test_agent.AgentDBTestMixIn,
AgentSchedulerTestMixIn,
test_plugin.NeutronDbPluginV2TestCase):
fmt = 'json'
plugin_str = 'neutron.plugins.ml2.plugin.Ml2Plugin'
- l3_plugin = ('neutron.tests.unit.test_l3_plugin.'
+ l3_plugin = ('neutron.tests.unit.extensions.test_l3.'
'TestL3NatAgentSchedulingServicePlugin')
def setUp(self):
exc.HTTPNotFound.code)
-class OvsDhcpAgentNotifierTestCase(test_l3_plugin.L3NatTestCaseMixin,
- test_agent_ext_plugin.AgentDBTestMixIn,
+class OvsDhcpAgentNotifierTestCase(test_l3.L3NatTestCaseMixin,
+ test_agent.AgentDBTestMixIn,
AgentSchedulerTestMixIn,
test_plugin.NeutronDbPluginV2TestCase):
plugin_str = 'neutron.plugins.ml2.plugin.Ml2Plugin'
self.assertTrue(self._is_schedule_network_called(device_id))
-class OvsL3AgentNotifierTestCase(test_l3_plugin.L3NatTestCaseMixin,
- test_agent_ext_plugin.AgentDBTestMixIn,
+class OvsL3AgentNotifierTestCase(test_l3.L3NatTestCaseMixin,
+ test_agent.AgentDBTestMixIn,
AgentSchedulerTestMixIn,
test_plugin.NeutronDbPluginV2TestCase):
plugin_str = 'neutron.plugins.ml2.plugin.Ml2Plugin'
- l3_plugin = ('neutron.tests.unit.test_l3_plugin.'
+ l3_plugin = ('neutron.tests.unit.extensions.test_l3.'
'TestL3NatAgentSchedulingServicePlugin')
def setUp(self):
from neutron import manager
from neutron.scheduler import l3_agent_scheduler
from neutron.tests import base
-from neutron.tests.unit import test_db_plugin
-from neutron.tests.unit import test_l3_plugin
+from neutron.tests.unit.db import test_db_base_plugin_v2
+from neutron.tests.unit.extensions import test_l3
from neutron.tests.unit import testlib_api
# the below code is required for the following reason
class L3SchedulerTestCase(l3_agentschedulers_db.L3AgentSchedulerDbMixin,
l3_db.L3_NAT_db_mixin,
common_db_mixin.CommonDbMixin,
- test_db_plugin.NeutronDbPluginV2TestCase,
- test_l3_plugin.L3NatTestCaseMixin,
+ test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
+ test_l3.L3NatTestCaseMixin,
L3SchedulerBaseMixin,
L3SchedulerTestBaseMixin):
def setUp(self):
self.mock_rescheduling = False
- ext_mgr = test_l3_plugin.L3TestExtensionManager()
- plugin_str = ('neutron.tests.unit.test_l3_plugin.'
+ ext_mgr = test_l3.L3TestExtensionManager()
+ plugin_str = ('neutron.tests.unit.extensions.test_l3.'
'TestL3NatIntAgentSchedulingPlugin')
super(L3SchedulerTestCase, self).setUp(plugin=plugin_str,
ext_mgr=ext_mgr)
from neutron.plugins.ml2.drivers.cisco.apic import mechanism_apic as md
from neutron.services.l3_router import l3_apic
-from neutron.tests.unit.ml2.drivers.cisco.apic import (
+from neutron.tests.unit.plugins.ml2.drivers.cisco.apic import (
test_cisco_apic_common as mocked)
from neutron.tests.unit import testlib_api
from neutron.services.metering.drivers.iptables import iptables_driver
from neutron.tests import base
-from neutron.tests.unit import test_api_v2
+from neutron.tests.unit.api.v2 import test_base
-_uuid = test_api_v2._uuid
+_uuid = test_base._uuid
TEST_ROUTERS = [
from neutron import manager
from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants
-from neutron.tests.unit.db.metering import test_db_metering
-from neutron.tests.unit import test_db_plugin
-from neutron.tests.unit import test_l3_plugin
+from neutron.tests.unit.db.metering import test_metering_db
+from neutron.tests.unit.db import test_db_base_plugin_v2
+from neutron.tests.unit.extensions import test_l3
_uuid = uuidutils.generate_uuid
return []
-class TestMeteringPlugin(test_db_plugin.NeutronDbPluginV2TestCase,
- test_l3_plugin.L3NatTestCaseMixin,
- test_db_metering.MeteringPluginDbTestCaseMixin):
+class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
+ test_l3.L3NatTestCaseMixin,
+ test_metering_db.MeteringPluginDbTestCaseMixin):
resource_prefix_map = dict(
(k.replace('_', '-'), constants.COMMON_PREFIXES[constants.METERING])
)
def setUp(self):
- plugin = 'neutron.tests.unit.test_l3_plugin.TestL3NatIntPlugin'
+ plugin = 'neutron.tests.unit.extensions.test_l3.TestL3NatIntPlugin'
service_plugins = {'metering_plugin_name':
METERING_SERVICE_PLUGIN_KLASS}
ext_mgr = MeteringTestExtensionManager()
class TestMeteringPluginL3AgentScheduler(
l3_agentschedulers_db.L3AgentSchedulerDbMixin,
- test_db_plugin.NeutronDbPluginV2TestCase,
- test_l3_plugin.L3NatTestCaseMixin,
- test_db_metering.MeteringPluginDbTestCaseMixin):
+ test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
+ test_l3.L3NatTestCaseMixin,
+ test_metering_db.MeteringPluginDbTestCaseMixin):
resource_prefix_map = dict(
(k.replace('_', '-'), constants.COMMON_PREFIXES[constants.METERING])
def setUp(self, plugin_str=None, service_plugins=None, scheduler=None):
if not plugin_str:
- plugin_str = ('neutron.tests.unit.test_l3_plugin.'
+ plugin_str = ('neutron.tests.unit.extensions.test_l3.'
'TestL3NatIntAgentSchedulingPlugin')
if not service_plugins:
"""
def setUp(self):
- l3_plugin = ('neutron.tests.unit.test_l3_plugin.'
+ l3_plugin = ('neutron.tests.unit.extensions.test_l3.'
'TestL3NatAgentSchedulingServicePlugin')
service_plugins = {'metering_plugin_name':
METERING_SERVICE_PLUGIN_KLASS,
'l3_plugin_name': l3_plugin}
- plugin_str = ('neutron.tests.unit.test_l3_plugin.'
+ plugin_str = ('neutron.tests.unit.extensions.test_l3.'
'TestNoL3NatPlugin')
super(TestMeteringPluginL3AgentSchedulerServicePlugin, self).setUp(
class TestMeteringPluginRpcFromL3Agent(
- test_db_plugin.NeutronDbPluginV2TestCase,
- test_l3_plugin.L3NatTestCaseMixin,
- test_db_metering.MeteringPluginDbTestCaseMixin):
+ test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
+ test_l3.L3NatTestCaseMixin,
+ test_metering_db.MeteringPluginDbTestCaseMixin):
resource_prefix_map = dict(
(k.replace('_', '-'), constants.COMMON_PREFIXES[constants.METERING])
service_plugins = {'metering_plugin_name':
METERING_SERVICE_PLUGIN_KLASS}
- plugin = ('neutron.tests.unit.test_l3_plugin.'
+ plugin = ('neutron.tests.unit.extensions.test_l3.'
'TestL3NatIntAgentSchedulingPlugin')
ext_mgr = MeteringTestExtensionManager()
["neutron.tests.unit.dummy_plugin."
"DummyServicePlugin"])
cfg.CONF.set_override("core_plugin",
- "neutron.tests.unit.test_neutron_manager."
+ "neutron.tests.unit.test_manager."
"MultiServiceCorePlugin")
e = self.assertRaises(ValueError, manager.NeutronManager.get_instance)
self.assertIn(constants.DUMMY, e.message)
def test_core_plugin_supports_services(self):
cfg.CONF.set_override("core_plugin",
- "neutron.tests.unit.test_neutron_manager."
+ "neutron.tests.unit.test_manager."
"MultiServiceCorePlugin")
mgr = manager.NeutronManager.get_instance()
svc_plugins = mgr.get_service_plugins()
["neutron.tests.unit.dummy_plugin."
"DummyServicePlugin"])
cfg.CONF.set_override("core_plugin",
- "neutron.tests.unit.test_neutron_manager."
+ "neutron.tests.unit.test_manager."
"CorePluginWithAgentNotifiers")
expected = {'l3': 'l3_agent_notifier',
'dhcp': 'dhcp_agent_notifier',
neutron.ml2.mechanism_drivers =
ovsvapp = neutron.plugins.ml2.drivers.ovsvapp.mech_driver:OVSvAppAgentMechanismDriver
opendaylight = neutron.plugins.ml2.drivers.opendaylight.driver:OpenDaylightMechanismDriver
- logger = neutron.tests.unit.ml2.drivers.mechanism_logger:LoggerMechanismDriver
- test = neutron.tests.unit.ml2.drivers.mechanism_test:TestMechanismDriver
+ logger = neutron.tests.unit.plugins.ml2.drivers.mechanism_logger:LoggerMechanismDriver
+ test = neutron.tests.unit.plugins.ml2.drivers.mechanism_test:TestMechanismDriver
linuxbridge = neutron.plugins.ml2.drivers.mech_linuxbridge:LinuxbridgeMechanismDriver
openvswitch = neutron.plugins.ml2.drivers.mech_openvswitch:OpenvswitchMechanismDriver
hyperv = neutron.plugins.ml2.drivers.hyperv.mech_hyperv:HypervMechanismDriver
fslsdn = neutron.plugins.ml2.drivers.freescale.mechanism_fslsdn:FslsdnMechanismDriver
sriovnicswitch = neutron.plugins.ml2.drivers.mech_sriov.mech_driver:SriovNicSwitchMechanismDriver
nuage = neutron.plugins.ml2.drivers.mech_nuage.driver:NuageMechanismDriver
- fake_agent = neutron.tests.unit.ml2.drivers.mech_fake_agent:FakeAgentMechanismDriver
+ fake_agent = neutron.tests.unit.plugins.ml2.drivers.mech_fake_agent:FakeAgentMechanismDriver
sdnve = neutron.plugins.ml2.drivers.ibm.mechanism_sdnve:SdnveMechanismDriver
neutron.ml2.extension_drivers =
- test = neutron.tests.unit.ml2.drivers.ext_test:TestExtensionDriver
- testdb = neutron.tests.unit.ml2.drivers.ext_test:TestDBExtensionDriver
+ test = neutron.tests.unit.plugins.ml2.drivers.ext_test:TestExtensionDriver
+ testdb = neutron.tests.unit.plugins.ml2.drivers.ext_test:TestDBExtensionDriver
port_security = neutron.plugins.ml2.extensions.port_security:PortSecurityExtensionDriver
cisco_n1kv_ext = neutron.plugins.ml2.drivers.cisco.n1kv.n1kv_ext_driver:CiscoN1kvExtensionDriver
neutron.openstack.common.cache.backends =
--- /dev/null
+#!/bin/bash
+
+# This script identifies the unit test modules that do not correspond
+# directly with a module in the code tree. See TESTING.rst for the
+# intended structure.
+
+neutron_path=$(cd "$(dirname "$0")/.." && pwd)
+base_test_path=neutron/tests/unit
+test_path=$neutron_path/$base_test_path
+
+test_files=$(find ${test_path} -iname 'test_*.py')
+
+ignore_regexes=(
+ "^plugins.*$"
+)
+
+error_count=0
+ignore_count=0
+total_count=0
+for test_file in ${test_files[@]}; do
+ relative_path=${test_file#$test_path/}
+ expected_path=$(dirname $neutron_path/neutron/$relative_path)
+ test_filename=$(basename "$test_file")
+ expected_filename=${test_filename#test_}
+ # Module filename (e.g. foo/bar.py -> foo/test_bar.py)
+ filename=$expected_path/$expected_filename
+ # Package dir (e.g. foo/ -> test_foo.py)
+ package_dir=${filename%.py}
+ if [ ! -f "$filename" ] && [ ! -d "$package_dir" ]; then
+ for ignore_regex in ${ignore_regexes[@]}; do
+ if [[ "$relative_path" =~ $ignore_regex ]]; then
+ ((ignore_count++))
+ continue 2
+ fi
+ done
+ echo "Unexpected test file: $base_test_path/$relative_path"
+ ((error_count++))
+ fi
+ ((total_count++))
+done
+
+if [ "$ignore_count" -ne 0 ]; then
+ echo "$ignore_count unmatched test modules were ignored"
+fi
+
+if [ "$error_count" -eq 0 ]; then
+ echo 'Success! All test modules match targets in the code tree.'
+ exit 0
+else
+ echo "Failure! $error_count of $total_count test modules do not match targets in the code tree."
+ exit 1
+fi
# If you cannot avoid the use of bash, please change the EXPECTED var below.
OBSERVED=$(grep -E '^([[:space:]]*[^#[:space:]]|#!).*bash' \
tox.ini tools/* | wc -l)
- EXPECTED=7
+ EXPECTED=8
if [ ${EXPECTED} -ne ${OBSERVED} ]; then
echo "Bash usage has been detected!" >>$FAILURES
fi
commands=
# If it is easier to add a check via a shell script, consider adding it in this file
sh ./tools/misc-sanity-checks.sh
+ {toxinidir}/tools/check_unit_test_structure.sh
# Checks for coding and style guidelines
flake8
sh ./tools/coding-checks.sh --pylint '{posargs}'