Reorganize vmware_nsx/tests structure
This patch is based on https://review.openstack.org/161194 It renames vmware_nsx/tests/unit/vmware/ to vmware_nsx/tests/unit/ and creates subdirectories vmware_nsx/tests/unit/dvs/ vmware_nsx/tests/unit/nsx_mh/ vmware_nsx/tests/unit/nsx_v/ vmware_nsx/tests/unit/nsx_v3/ vmware_nsx/tests/unit/nsxlib/mh/ vmware_nsx/tests/unit/nsxlib/v3/ This is part of new vmware_nsx directory structure proposed in https://goo.gl/GdWXyH. Change-Id: I16aa2455bce55f6455bb5e504ee9684c675b4257
This commit is contained in:
parent
fda6b6a585
commit
4483fe5006
@ -4,7 +4,7 @@ Testing VMware-NSX
|
|||||||
Overview
|
Overview
|
||||||
--------
|
--------
|
||||||
|
|
||||||
The unit tests (vmware_nsx/neutron/test/unit/) are meant to cover as much
|
The unit tests (vmware_nsx/tests/unit/) are meant to cover as much
|
||||||
code as possible and should be executed without the service running. They
|
code as possible and should be executed without the service running. They
|
||||||
are designed to test the various pieces of the neutron and VMware NSX tree
|
are designed to test the various pieces of the neutron and VMware NSX tree
|
||||||
to make sure any new changes don't break existing functionality.
|
to make sure any new changes don't break existing functionality.
|
||||||
@ -125,13 +125,13 @@ For executing a specific test case, specify the name of the test case
|
|||||||
class separating it from the module path with a colon.
|
class separating it from the module path with a colon.
|
||||||
|
|
||||||
For example, the following would run only the TestSubnetsV2 tests from
|
For example, the following would run only the TestSubnetsV2 tests from
|
||||||
vmware_nsx/tests/unit/vmware/test_nsx_v_plugin.py::
|
vmware_nsx/tests/unit/nsx_v/test_plugin.py::
|
||||||
|
|
||||||
$ ./run_tests.sh vmware_nsx.tests.unit.vmware.test_nsx_v_plugin.TestSubnetsV2
|
$ ./run_tests.sh vmware_nsx.tests.unit.nsx_v.test_plugin.TestSubnetsV2
|
||||||
|
|
||||||
or::
|
or::
|
||||||
|
|
||||||
$ tox -e py27 vmware_nsx.tests.unit.vmware.test_nsx_v_plugin.TestSubnetsV2
|
$ tox -e py27 vmware_nsx.tests.unit.nsx_v.test_plugin.TestSubnetsV2
|
||||||
|
|
||||||
Adding more tests
|
Adding more tests
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# Copyright 2011 OpenStack Foundation.
|
# Copyright 2013 OpenStack Foundation.
|
||||||
|
#
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
@ -13,7 +14,45 @@
|
|||||||
# 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 oslo_config import cfg
|
import os
|
||||||
|
|
||||||
|
from networking_l2gw.db.l2gateway import l2gateway_models # noqa
|
||||||
|
|
||||||
|
from vmware_nsx.api_client import client as nsx_client
|
||||||
|
from vmware_nsx.api_client import eventlet_client
|
||||||
|
from vmware_nsx import extensions
|
||||||
|
import vmware_nsx.plugin as neutron_plugin
|
||||||
|
from vmware_nsx.plugins.nsx_v.vshield.common import (
|
||||||
|
VcnsApiClient as vcnsapi)
|
||||||
|
from vmware_nsx.plugins.nsx_v.vshield import edge_utils
|
||||||
|
from vmware_nsx.plugins.nsx_v.vshield import vcns
|
||||||
|
import vmware_nsx.plugins.nsx_v.vshield.vcns_driver as vcnsdriver
|
||||||
|
|
||||||
|
|
||||||
cfg.CONF.use_stderr = False
|
plugin = neutron_plugin.NsxPlugin
|
||||||
|
api_client = nsx_client.NsxApiClient
|
||||||
|
evt_client = eventlet_client.EventletApiClient
|
||||||
|
vcns_class = vcns.Vcns
|
||||||
|
vcns_driver = vcnsdriver.VcnsDriver
|
||||||
|
vcns_api_helper = vcnsapi.VcnsApiHelper
|
||||||
|
edge_manage_class = edge_utils.EdgeManager
|
||||||
|
|
||||||
|
STUBS_PATH = os.path.join(os.path.dirname(__file__), 'etc')
|
||||||
|
NSXEXT_PATH = os.path.dirname(extensions.__file__)
|
||||||
|
NSXAPI_NAME = '%s.%s' % (api_client.__module__, api_client.__name__)
|
||||||
|
PLUGIN_NAME = '%s.%s' % (plugin.__module__, plugin.__name__)
|
||||||
|
CLIENT_NAME = '%s.%s' % (evt_client.__module__, evt_client.__name__)
|
||||||
|
VCNS_NAME = '%s.%s' % (vcns_class.__module__, vcns_class.__name__)
|
||||||
|
VCNS_DRIVER_NAME = '%s.%s' % (vcns_driver.__module__, vcns_driver.__name__)
|
||||||
|
VCNSAPI_NAME = '%s.%s' % (vcns_api_helper.__module__, vcns_api_helper.__name__)
|
||||||
|
EDGE_MANAGE_NAME = '%s.%s' % (edge_manage_class.__module__,
|
||||||
|
edge_manage_class.__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def get_fake_conf(filename):
|
||||||
|
return os.path.join(STUBS_PATH, filename)
|
||||||
|
|
||||||
|
|
||||||
|
def nsx_method(method_name, module_name='nsxlib'):
|
||||||
|
return '%s.%s.%s' % ('vmware_nsx', module_name,
|
||||||
|
method_name)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
from neutron.extensions import allowedaddresspairs as addr_pair
|
from neutron.extensions import allowedaddresspairs as addr_pair
|
||||||
from neutron.tests.unit.db import test_allowedaddresspairs_db as ext_pairs
|
from neutron.tests.unit.db import test_allowedaddresspairs_db as ext_pairs
|
||||||
|
|
||||||
from vmware_nsx.tests.unit.vmware import test_nsx_plugin
|
from vmware_nsx.tests.unit.nsx_mh import test_plugin as test_nsx_plugin
|
||||||
|
|
||||||
|
|
||||||
class TestAllowedAddressPairs(test_nsx_plugin.NsxPluginV2TestCase,
|
class TestAllowedAddressPairs(test_nsx_plugin.NsxPluginV2TestCase,
|
@ -23,9 +23,9 @@ import six
|
|||||||
|
|
||||||
from vmware_nsx.api_client import version
|
from vmware_nsx.api_client import version
|
||||||
from vmware_nsx.common import sync
|
from vmware_nsx.common import sync
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware.apiclient import fake
|
from vmware_nsx.tests.unit.nsx_mh.apiclient import fake
|
||||||
from vmware_nsx.tests.unit.vmware import test_utils
|
from vmware_nsx.tests.unit import test_utils
|
||||||
|
|
||||||
|
|
||||||
class MacLearningExtensionManager(object):
|
class MacLearningExtensionManager(object):
|
@ -38,8 +38,8 @@ from vmware_nsx.db import nsx_models
|
|||||||
from vmware_nsx.extensions import networkgw
|
from vmware_nsx.extensions import networkgw
|
||||||
from vmware_nsx.nsxlib import mh as nsxlib
|
from vmware_nsx.nsxlib import mh as nsxlib
|
||||||
from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib
|
from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware import test_nsx_plugin
|
from vmware_nsx.tests.unit.nsx_mh import test_plugin as test_nsx_plugin
|
||||||
|
|
||||||
_uuid = test_base._uuid
|
_uuid = test_base._uuid
|
||||||
_get_path = test_base._get_path
|
_get_path = test_base._get_path
|
@ -17,9 +17,9 @@ import mock
|
|||||||
|
|
||||||
from neutron.tests.unit.extensions import test_portsecurity as psec
|
from neutron.tests.unit.extensions import test_portsecurity as psec
|
||||||
from vmware_nsx.common import sync
|
from vmware_nsx.common import sync
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware.apiclient import fake
|
from vmware_nsx.tests.unit.nsx_mh.apiclient import fake
|
||||||
from vmware_nsx.tests.unit.vmware import test_utils
|
from vmware_nsx.tests.unit import test_utils
|
||||||
|
|
||||||
|
|
||||||
class PortSecurityTestCase(psec.PortSecurityDBTestCase):
|
class PortSecurityTestCase(psec.PortSecurityDBTestCase):
|
@ -18,8 +18,8 @@ import webob.exc
|
|||||||
|
|
||||||
from neutron.extensions import multiprovidernet as mpnet
|
from neutron.extensions import multiprovidernet as mpnet
|
||||||
from neutron.extensions import providernet as pnet
|
from neutron.extensions import providernet as pnet
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware import test_nsx_plugin
|
from vmware_nsx.tests.unit.nsx_mh import test_plugin as test_nsx_plugin
|
||||||
|
|
||||||
|
|
||||||
class TestProvidernet(test_nsx_plugin.NsxPluginV2TestCase):
|
class TestProvidernet(test_nsx_plugin.NsxPluginV2TestCase):
|
@ -24,8 +24,8 @@ from neutron.tests.unit.api import test_extensions
|
|||||||
from vmware_nsx.db import qos_db
|
from vmware_nsx.db import qos_db
|
||||||
from vmware_nsx.extensions import qos as ext_qos
|
from vmware_nsx.extensions import qos as ext_qos
|
||||||
from vmware_nsx.nsxlib import mh as nsxlib
|
from vmware_nsx.nsxlib import mh as nsxlib
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware import test_nsx_plugin
|
from vmware_nsx.tests.unit.nsx_mh import test_plugin as test_nsx_plugin
|
||||||
|
|
||||||
|
|
||||||
class QoSTestExtensionManager(object):
|
class QoSTestExtensionManager(object):
|
@ -24,10 +24,10 @@ from neutron import manager
|
|||||||
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db_plugin
|
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db_plugin
|
||||||
from vmware_nsx.db import vnic_index_db
|
from vmware_nsx.db import vnic_index_db
|
||||||
from vmware_nsx.extensions import vnicindex as vnicidx
|
from vmware_nsx.extensions import vnicindex as vnicidx
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
|
|
||||||
|
|
||||||
DB_PLUGIN_KLASS = ('vmware_nsx.tests.unit.vmware.extensions.'
|
DB_PLUGIN_KLASS = ('vmware_nsx.tests.unit.extensions.'
|
||||||
'test_vnic_index.VnicIndexTestPlugin')
|
'test_vnic_index.VnicIndexTestPlugin')
|
||||||
|
|
||||||
_uuid = uuidutils.generate_uuid
|
_uuid = uuidutils.generate_uuid
|
@ -27,7 +27,7 @@ from vmware_nsx.api_client import (
|
|||||||
eventlet_client as client)
|
eventlet_client as client)
|
||||||
from vmware_nsx.api_client import (
|
from vmware_nsx.api_client import (
|
||||||
eventlet_request as request)
|
eventlet_request as request)
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
@ -21,9 +21,9 @@ from neutron.tests.unit.db import test_agentschedulers_db # noqa
|
|||||||
|
|
||||||
from vmware_nsx.common import sync
|
from vmware_nsx.common import sync
|
||||||
from vmware_nsx.dhcp_meta import rpc
|
from vmware_nsx.dhcp_meta import rpc
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware.apiclient import fake
|
from vmware_nsx.tests.unit.nsx_mh.apiclient import fake
|
||||||
from vmware_nsx.tests.unit.vmware import test_utils
|
from vmware_nsx.tests.unit import test_utils
|
||||||
|
|
||||||
|
|
||||||
class DhcpAgentNotifierTestCase(
|
class DhcpAgentNotifierTestCase(
|
@ -29,7 +29,7 @@ from vmware_nsx.common import exceptions
|
|||||||
from vmware_nsx.common import sync
|
from vmware_nsx.common import sync
|
||||||
from vmware_nsx import nsx_cluster
|
from vmware_nsx import nsx_cluster
|
||||||
from vmware_nsx.nsxlib.mh import lsn as lsnlib
|
from vmware_nsx.nsxlib.mh import lsn as lsnlib
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
|
|
||||||
BASE_CONF_PATH = vmware.get_fake_conf('neutron.conf.test')
|
BASE_CONF_PATH = vmware.get_fake_conf('neutron.conf.test')
|
||||||
NSX_INI_PATH = vmware.get_fake_conf('nsx.ini.basic.test')
|
NSX_INI_PATH = vmware.get_fake_conf('nsx.ini.basic.test')
|
@ -51,9 +51,9 @@ from vmware_nsx.common import sync
|
|||||||
from vmware_nsx.common import utils
|
from vmware_nsx.common import utils
|
||||||
from vmware_nsx.db import db as nsx_db
|
from vmware_nsx.db import db as nsx_db
|
||||||
from vmware_nsx.nsxlib import mh as nsxlib
|
from vmware_nsx.nsxlib import mh as nsxlib
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware.apiclient import fake
|
from vmware_nsx.tests.unit.nsx_mh.apiclient import fake
|
||||||
from vmware_nsx.tests.unit.vmware import test_utils
|
from vmware_nsx.tests.unit import test_utils
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
@ -39,8 +39,8 @@ from vmware_nsx.db import db
|
|||||||
from vmware_nsx import nsx_cluster as cluster
|
from vmware_nsx import nsx_cluster as cluster
|
||||||
from vmware_nsx.nsxlib import mh as nsxlib
|
from vmware_nsx.nsxlib import mh as nsxlib
|
||||||
from vmware_nsx import plugin
|
from vmware_nsx import plugin
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware.apiclient import fake
|
from vmware_nsx.tests.unit.nsx_mh.apiclient import fake
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
@ -26,8 +26,8 @@ from vmware_nsx.common import nsx_utils
|
|||||||
from vmware_nsx.common import utils
|
from vmware_nsx.common import utils
|
||||||
from vmware_nsx.db import nsx_models
|
from vmware_nsx.db import nsx_models
|
||||||
from vmware_nsx.nsxlib import mh as nsxlib
|
from vmware_nsx.nsxlib import mh as nsxlib
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware.nsxlib import base as nsx_base
|
from vmware_nsx.tests.unit.nsxlib.mh import base as nsx_base
|
||||||
|
|
||||||
|
|
||||||
class NsxUtilsTestCase(base.BaseTestCase):
|
class NsxUtilsTestCase(base.BaseTestCase):
|
@ -56,10 +56,10 @@ from vmware_nsx.extensions import (
|
|||||||
from vmware_nsx.plugins.nsx_v.vshield.common import (
|
from vmware_nsx.plugins.nsx_v.vshield.common import (
|
||||||
constants as vcns_const)
|
constants as vcns_const)
|
||||||
from vmware_nsx.plugins.nsx_v.vshield import edge_utils
|
from vmware_nsx.plugins.nsx_v.vshield import edge_utils
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware.extensions import test_vnic_index
|
from vmware_nsx.tests.unit.extensions import test_vnic_index
|
||||||
from vmware_nsx.tests.unit.vmware import test_utils
|
from vmware_nsx.tests.unit.nsx_v.vshield import fake_vcns
|
||||||
from vmware_nsx.tests.unit.vmware.vshield import fake_vcns
|
from vmware_nsx.tests.unit import test_utils
|
||||||
|
|
||||||
PLUGIN_NAME = 'vmware_nsx.plugin.NsxVPlugin'
|
PLUGIN_NAME = 'vmware_nsx.plugin.NsxVPlugin'
|
||||||
|
|
@ -27,7 +27,7 @@ from vmware_nsx.db import nsxv_db
|
|||||||
from vmware_nsx.plugins.nsx_v.vshield.common import (
|
from vmware_nsx.plugins.nsx_v.vshield.common import (
|
||||||
constants as vcns_const)
|
constants as vcns_const)
|
||||||
from vmware_nsx.plugins.nsx_v.vshield import edge_utils
|
from vmware_nsx.plugins.nsx_v.vshield import edge_utils
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
|
|
||||||
_uuid = uuidutils.generate_uuid
|
_uuid = uuidutils.generate_uuid
|
||||||
|
|
@ -25,8 +25,8 @@ from vmware_nsx.plugins.nsx_v.vshield.tasks import (
|
|||||||
constants as ts_const)
|
constants as ts_const)
|
||||||
from vmware_nsx.plugins.nsx_v.vshield.tasks import tasks as ts
|
from vmware_nsx.plugins.nsx_v.vshield.tasks import tasks as ts
|
||||||
from vmware_nsx.plugins.nsx_v.vshield import vcns_driver
|
from vmware_nsx.plugins.nsx_v.vshield import vcns_driver
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware.vshield import fake_vcns
|
from vmware_nsx.tests.unit.nsx_v.vshield import fake_vcns
|
||||||
|
|
||||||
VCNS_CONFIG_FILE = vmware.get_fake_conf("vcns.ini.test")
|
VCNS_CONFIG_FILE = vmware.get_fake_conf("vcns.ini.test")
|
||||||
|
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
from neutron.extensions import portbindings as pbin
|
from neutron.extensions import portbindings as pbin
|
||||||
|
|
||||||
from vmware_nsx.tests.unit.vmware import test_nsx_v3_plugin
|
from vmware_nsx.tests.unit.nsx_v3 import test_plugin as test_nsx_v3_plugin
|
||||||
|
|
||||||
|
|
||||||
class TestParentTagPortBinding(test_nsx_v3_plugin.NsxPluginV3TestCase):
|
class TestParentTagPortBinding(test_nsx_v3_plugin.NsxPluginV3TestCase):
|
@ -37,8 +37,8 @@ from vmware_nsx.common import utils
|
|||||||
from vmware_nsx.nsxlib import v3 as nsxlib
|
from vmware_nsx.nsxlib import v3 as nsxlib
|
||||||
from vmware_nsx.nsxlib.v3 import dfw_api as firewall
|
from vmware_nsx.nsxlib.v3 import dfw_api as firewall
|
||||||
from vmware_nsx.nsxlib.v3 import resources as nsx_resources
|
from vmware_nsx.nsxlib.v3 import resources as nsx_resources
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware import nsx_v3_mocks
|
from vmware_nsx.tests.unit.nsx_v3 import mocks as nsx_v3_mocks
|
||||||
|
|
||||||
PLUGIN_NAME = ('vmware_nsx.plugin.NsxV3Plugin')
|
PLUGIN_NAME = ('vmware_nsx.plugin.NsxV3Plugin')
|
||||||
|
|
0
vmware_nsx/tests/unit/nsxlib/mh/__init__.py
Normal file
0
vmware_nsx/tests/unit/nsxlib/mh/__init__.py
Normal file
@ -23,8 +23,8 @@ from vmware_nsx.api_client import exception
|
|||||||
from vmware_nsx.api_client import version
|
from vmware_nsx.api_client import version
|
||||||
from vmware_nsx.common import config # noqa
|
from vmware_nsx.common import config # noqa
|
||||||
from vmware_nsx import nsx_cluster as cluster
|
from vmware_nsx import nsx_cluster as cluster
|
||||||
from vmware_nsx.tests.unit import vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.vmware.apiclient import fake
|
from vmware_nsx.tests.unit.nsx_mh.apiclient import fake
|
||||||
|
|
||||||
_uuid = test_base._uuid
|
_uuid = test_base._uuid
|
||||||
|
|
@ -24,7 +24,7 @@ from vmware_nsx.common import utils as nsx_utils
|
|||||||
from vmware_nsx.nsxlib import mh as nsxlib
|
from vmware_nsx.nsxlib import mh as nsxlib
|
||||||
from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib
|
from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib
|
||||||
from vmware_nsx.nsxlib.mh import switch as switchlib
|
from vmware_nsx.nsxlib.mh import switch as switchlib
|
||||||
from vmware_nsx.tests.unit.vmware.nsxlib import base
|
from vmware_nsx.tests.unit.nsxlib.mh import base
|
||||||
|
|
||||||
_uuid = test_base._uuid
|
_uuid = test_base._uuid
|
||||||
|
|
@ -20,7 +20,7 @@ from neutron.common import exceptions
|
|||||||
from vmware_nsx.api_client import exception as api_exc
|
from vmware_nsx.api_client import exception as api_exc
|
||||||
from vmware_nsx.nsxlib import mh as nsxlib
|
from vmware_nsx.nsxlib import mh as nsxlib
|
||||||
from vmware_nsx.nsxlib.mh import queue as queuelib
|
from vmware_nsx.nsxlib.mh import queue as queuelib
|
||||||
from vmware_nsx.tests.unit.vmware.nsxlib import base
|
from vmware_nsx.tests.unit.nsxlib.mh import base
|
||||||
|
|
||||||
|
|
||||||
class TestLogicalQueueLib(base.NsxlibTestCase):
|
class TestLogicalQueueLib(base.NsxlibTestCase):
|
@ -27,7 +27,7 @@ from vmware_nsx.common import utils
|
|||||||
from vmware_nsx.nsxlib import mh as nsxlib
|
from vmware_nsx.nsxlib import mh as nsxlib
|
||||||
from vmware_nsx.nsxlib.mh import router as routerlib
|
from vmware_nsx.nsxlib.mh import router as routerlib
|
||||||
from vmware_nsx.nsxlib.mh import switch as switchlib
|
from vmware_nsx.nsxlib.mh import switch as switchlib
|
||||||
from vmware_nsx.tests.unit.vmware.nsxlib import base
|
from vmware_nsx.tests.unit.nsxlib.mh import base
|
||||||
|
|
||||||
_uuid = test_base._uuid
|
_uuid = test_base._uuid
|
||||||
|
|
@ -20,7 +20,7 @@ from neutron.tests.unit.api.v2 import test_base
|
|||||||
|
|
||||||
from vmware_nsx.nsxlib import mh as nsxlib
|
from vmware_nsx.nsxlib import mh as nsxlib
|
||||||
from vmware_nsx.nsxlib.mh import secgroup as secgrouplib
|
from vmware_nsx.nsxlib.mh import secgroup as secgrouplib
|
||||||
from vmware_nsx.tests.unit.vmware.nsxlib import base
|
from vmware_nsx.tests.unit.nsxlib.mh import base
|
||||||
|
|
||||||
_uuid = test_base._uuid
|
_uuid = test_base._uuid
|
||||||
|
|
@ -23,7 +23,7 @@ from neutron.tests.unit.api.v2 import test_base
|
|||||||
|
|
||||||
from vmware_nsx.common import utils
|
from vmware_nsx.common import utils
|
||||||
from vmware_nsx.nsxlib.mh import switch as switchlib
|
from vmware_nsx.nsxlib.mh import switch as switchlib
|
||||||
from vmware_nsx.tests.unit.vmware.nsxlib import base
|
from vmware_nsx.tests.unit.nsxlib.mh import base
|
||||||
|
|
||||||
_uuid = test_base._uuid
|
_uuid = test_base._uuid
|
||||||
|
|
0
vmware_nsx/tests/unit/nsxlib/v3/__init__.py
Normal file
0
vmware_nsx/tests/unit/nsxlib/v3/__init__.py
Normal file
@ -16,18 +16,26 @@
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
import vmware_nsx.common.exceptions as exep
|
import vmware_nsx.common.exceptions as exep
|
||||||
import vmware_nsx.tests.unit.vmware.nsx_v3_mocks as mocks
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from vmware_nsx.nsxlib.v3 import client
|
from vmware_nsx.nsxlib.v3 import client
|
||||||
from vmware_nsx.tests.unit.vmware.nsxlib.v3 import nsxlib_testcase
|
from vmware_nsx.tests.unit.nsx_v3 import mocks
|
||||||
|
from vmware_nsx.tests.unit.nsxlib.v3 import nsxlib_testcase
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
CLIENT_PKG = 'vmware_nsx.nsxlib.v3.client'
|
CLIENT_PKG = 'vmware_nsx.nsxlib.v3.client'
|
||||||
|
|
||||||
|
# Cache the pointers to those functions because they are overridden
|
||||||
|
# by tests/unit/nsx_v3/test_plugin.py. This is only needed when running
|
||||||
|
# tox on multiple tests.
|
||||||
|
client_get_resource = client.get_resource
|
||||||
|
client_create_resource = client.create_resource
|
||||||
|
client_update_resource = client.update_resource
|
||||||
|
client_delete_resource = client.delete_resource
|
||||||
|
|
||||||
|
|
||||||
def assert_session_call(mock_call, url, verify, data, headers, cert):
|
def assert_session_call(mock_call, url, verify, data, headers, cert):
|
||||||
mock_call.assert_called_once_with(
|
mock_call.assert_called_once_with(
|
||||||
@ -324,7 +332,7 @@ class NsxV3APIClientBridgeTestCase(BaseClientTestCase):
|
|||||||
@mock.patch("%s.%s" % (CLIENT_PKG, 'requests.Session.get'))
|
@mock.patch("%s.%s" % (CLIENT_PKG, 'requests.Session.get'))
|
||||||
@mock.patch(CLIENT_PKG + '.RESTClient._validate_result')
|
@mock.patch(CLIENT_PKG + '.RESTClient._validate_result')
|
||||||
def test_get_resource(self, mock_validate, mock_get):
|
def test_get_resource(self, mock_validate, mock_get):
|
||||||
client.get_resource('ports')
|
client_get_resource('ports')
|
||||||
|
|
||||||
assert_session_call(
|
assert_session_call(
|
||||||
mock_get,
|
mock_get,
|
||||||
@ -336,7 +344,7 @@ class NsxV3APIClientBridgeTestCase(BaseClientTestCase):
|
|||||||
@mock.patch("%s.%s" % (CLIENT_PKG, 'requests.Session.post'))
|
@mock.patch("%s.%s" % (CLIENT_PKG, 'requests.Session.post'))
|
||||||
@mock.patch(CLIENT_PKG + '.RESTClient._validate_result')
|
@mock.patch(CLIENT_PKG + '.RESTClient._validate_result')
|
||||||
def test_create_resource(self, mock_validate, mock_post):
|
def test_create_resource(self, mock_validate, mock_post):
|
||||||
client.create_resource('ports', {'resource-name': 'port1'})
|
client_create_resource('ports', {'resource-name': 'port1'})
|
||||||
|
|
||||||
assert_session_call(
|
assert_session_call(
|
||||||
mock_post,
|
mock_post,
|
||||||
@ -348,7 +356,7 @@ class NsxV3APIClientBridgeTestCase(BaseClientTestCase):
|
|||||||
@mock.patch("%s.%s" % (CLIENT_PKG, 'requests.Session.put'))
|
@mock.patch("%s.%s" % (CLIENT_PKG, 'requests.Session.put'))
|
||||||
@mock.patch(CLIENT_PKG + '.RESTClient._validate_result')
|
@mock.patch(CLIENT_PKG + '.RESTClient._validate_result')
|
||||||
def test_update_resource(self, mock_validate, mock_put):
|
def test_update_resource(self, mock_validate, mock_put):
|
||||||
client.update_resource('ports/1', {'name': 'a-new-name'})
|
client_update_resource('ports/1', {'name': 'a-new-name'})
|
||||||
|
|
||||||
assert_session_call(
|
assert_session_call(
|
||||||
mock_put,
|
mock_put,
|
||||||
@ -360,7 +368,7 @@ class NsxV3APIClientBridgeTestCase(BaseClientTestCase):
|
|||||||
@mock.patch("%s.%s" % (CLIENT_PKG, 'requests.Session.delete'))
|
@mock.patch("%s.%s" % (CLIENT_PKG, 'requests.Session.delete'))
|
||||||
@mock.patch(CLIENT_PKG + '.RESTClient._validate_result')
|
@mock.patch(CLIENT_PKG + '.RESTClient._validate_result')
|
||||||
def test_delete_resource(self, mock_validate, mock_delete):
|
def test_delete_resource(self, mock_validate, mock_delete):
|
||||||
client.delete_resource('ports/11')
|
client_delete_resource('ports/11')
|
||||||
|
|
||||||
assert_session_call(
|
assert_session_call(
|
||||||
mock_delete,
|
mock_delete,
|
@ -19,8 +19,8 @@ import mock
|
|||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
from vmware_nsx.nsxlib import v3 as nsxlib
|
from vmware_nsx.nsxlib import v3 as nsxlib
|
||||||
from vmware_nsx.tests.unit.vmware.nsxlib.v3 import nsxlib_testcase
|
from vmware_nsx.tests.unit.nsx_v3 import test_constants as test_constants_v3
|
||||||
from vmware_nsx.tests.unit.vmware import test_constants_v3
|
from vmware_nsx.tests.unit.nsxlib.v3 import nsxlib_testcase
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
@ -14,13 +14,13 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
import mock
|
import mock
|
||||||
import vmware_nsx.tests.unit.vmware.nsx_v3_mocks as mocks
|
|
||||||
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from vmware_nsx.nsxlib.v3 import client
|
from vmware_nsx.nsxlib.v3 import client
|
||||||
from vmware_nsx.nsxlib.v3 import resources
|
from vmware_nsx.nsxlib.v3 import resources
|
||||||
from vmware_nsx.tests.unit.vmware.nsxlib.v3 import test_client
|
from vmware_nsx.tests.unit.nsx_v3 import mocks
|
||||||
from vmware_nsx.tests.unit.vmware import test_constants_v3
|
from vmware_nsx.tests.unit.nsx_v3 import test_constants as test_constants_v3
|
||||||
|
from vmware_nsx.tests.unit.nsxlib.v3 import test_client
|
||||||
|
|
||||||
|
|
||||||
CLIENT_PKG = test_client.CLIENT_PKG
|
CLIENT_PKG = test_client.CLIENT_PKG
|
||||||
@ -163,6 +163,10 @@ class LogicalPortTestCase(test_client.BaseClientTestCase):
|
|||||||
profile_dicts.append({'resource_type': profile_id['key'],
|
profile_dicts.append({'resource_type': profile_id['key'],
|
||||||
'id': profile_id['value']})
|
'id': profile_id['value']})
|
||||||
|
|
||||||
|
# Reload resources because resources.LogicalPort.create is overridden
|
||||||
|
# by tests/unit/nsx_v3/test_plugin.py. This is only needed when running
|
||||||
|
# tox on multiple tests.
|
||||||
|
reload(resources)
|
||||||
result = resources.LogicalPort(client.NSX3Client()).create(
|
result = resources.LogicalPort(client.NSX3Client()).create(
|
||||||
fake_port['logical_switch_id'],
|
fake_port['logical_switch_id'],
|
||||||
fake_port['attachment']['id'],
|
fake_port['attachment']['id'],
|
||||||
@ -201,6 +205,10 @@ class LogicalPortTestCase(test_client.BaseClientTestCase):
|
|||||||
mock_post.return_value = mocks.MockRequestsResponse(
|
mock_post.return_value = mocks.MockRequestsResponse(
|
||||||
200, jsonutils.dumps(fake_port))
|
200, jsonutils.dumps(fake_port))
|
||||||
|
|
||||||
|
# Reload resources because resources.LogicalPort.create is overridden
|
||||||
|
# by tests/unit/nsx_v3/test_plugin.py. This is only needed when running
|
||||||
|
# tox on multiple tests.
|
||||||
|
reload(resources)
|
||||||
result = resources.LogicalPort(client.NSX3Client()).create(
|
result = resources.LogicalPort(client.NSX3Client()).create(
|
||||||
test_constants_v3.FAKE_PORT['logical_switch_id'],
|
test_constants_v3.FAKE_PORT['logical_switch_id'],
|
||||||
test_constants_v3.FAKE_PORT['attachment']['id'],
|
test_constants_v3.FAKE_PORT['attachment']['id'],
|
||||||
@ -218,6 +226,10 @@ class LogicalPortTestCase(test_client.BaseClientTestCase):
|
|||||||
200, None)
|
200, None)
|
||||||
|
|
||||||
uuid = test_constants_v3.FAKE_PORT['id']
|
uuid = test_constants_v3.FAKE_PORT['id']
|
||||||
|
# Reload resources because resources.LogicalPort.delete is overridden
|
||||||
|
# by tests/unit/nsx_v3/test_plugin.py. This is only needed when running
|
||||||
|
# tox on multiple tests.
|
||||||
|
reload(resources)
|
||||||
result = resources.LogicalPort(client.NSX3Client()).delete(uuid)
|
result = resources.LogicalPort(client.NSX3Client()).delete(uuid)
|
||||||
self.assertIsNone(result.content)
|
self.assertIsNone(result.content)
|
||||||
test_client.assert_session_call(
|
test_client.assert_session_call(
|
@ -21,11 +21,17 @@ from oslo_utils import uuidutils
|
|||||||
|
|
||||||
from vmware_nsx.common import nsx_constants
|
from vmware_nsx.common import nsx_constants
|
||||||
from vmware_nsx.nsxlib import v3 as nsxlib
|
from vmware_nsx.nsxlib import v3 as nsxlib
|
||||||
from vmware_nsx.tests.unit.vmware import nsx_v3_mocks
|
from vmware_nsx.tests.unit.nsx_v3 import mocks as nsx_v3_mocks
|
||||||
from vmware_nsx.tests.unit.vmware.nsxlib.v3 import nsxlib_testcase
|
from vmware_nsx.tests.unit.nsxlib.v3 import nsxlib_testcase
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
# Cache the pointers to those functions because they are overridden
|
||||||
|
# by tests/unit/nsx_v3/test_plugin.py. This is only needed when running
|
||||||
|
# tox on multiple tests.
|
||||||
|
nsxlib_create_logical_switch = nsxlib.create_logical_switch
|
||||||
|
nsxlib_delete_logical_switch = nsxlib.delete_logical_switch
|
||||||
|
|
||||||
|
|
||||||
class NsxLibSwitchTestCase(nsxlib_testcase.NsxLibTestCase):
|
class NsxLibSwitchTestCase(nsxlib_testcase.NsxLibTestCase):
|
||||||
|
|
||||||
@ -39,7 +45,7 @@ class NsxLibSwitchTestCase(nsxlib_testcase.NsxLibTestCase):
|
|||||||
fake_switch = nsx_v3_mocks.make_fake_switch(tz_uuid=tz_uuid)
|
fake_switch = nsx_v3_mocks.make_fake_switch(tz_uuid=tz_uuid)
|
||||||
mock_create_resource.return_value = fake_switch
|
mock_create_resource.return_value = fake_switch
|
||||||
|
|
||||||
result = nsxlib.create_logical_switch(nsx_v3_mocks.FAKE_NAME, tz_uuid,
|
result = nsxlib_create_logical_switch(nsx_v3_mocks.FAKE_NAME, tz_uuid,
|
||||||
[])
|
[])
|
||||||
self.assertEqual(fake_switch, result)
|
self.assertEqual(fake_switch, result)
|
||||||
|
|
||||||
@ -54,7 +60,7 @@ class NsxLibSwitchTestCase(nsxlib_testcase.NsxLibTestCase):
|
|||||||
fake_switch['admin_state'] = nsx_constants.ADMIN_STATE_DOWN
|
fake_switch['admin_state'] = nsx_constants.ADMIN_STATE_DOWN
|
||||||
mock_create_resource.return_value = fake_switch
|
mock_create_resource.return_value = fake_switch
|
||||||
|
|
||||||
result = nsxlib.create_logical_switch(nsx_v3_mocks.FAKE_NAME, tz_uuid,
|
result = nsxlib_create_logical_switch(nsx_v3_mocks.FAKE_NAME, tz_uuid,
|
||||||
[], admin_state=False)
|
[], admin_state=False)
|
||||||
self.assertEqual(fake_switch, result)
|
self.assertEqual(fake_switch, result)
|
||||||
|
|
||||||
@ -69,7 +75,7 @@ class NsxLibSwitchTestCase(nsxlib_testcase.NsxLibTestCase):
|
|||||||
fake_switch['vlan_id'] = '123'
|
fake_switch['vlan_id'] = '123'
|
||||||
mock_create_resource.return_value = fake_switch
|
mock_create_resource.return_value = fake_switch
|
||||||
|
|
||||||
result = nsxlib.create_logical_switch(nsx_v3_mocks.FAKE_NAME, tz_uuid,
|
result = nsxlib_create_logical_switch(nsx_v3_mocks.FAKE_NAME, tz_uuid,
|
||||||
[])
|
[])
|
||||||
self.assertEqual(fake_switch, result)
|
self.assertEqual(fake_switch, result)
|
||||||
|
|
||||||
@ -82,5 +88,5 @@ class NsxLibSwitchTestCase(nsxlib_testcase.NsxLibTestCase):
|
|||||||
mock_delete_resource.return_value = None
|
mock_delete_resource.return_value = None
|
||||||
|
|
||||||
fake_switch = nsx_v3_mocks.make_fake_switch()
|
fake_switch = nsx_v3_mocks.make_fake_switch()
|
||||||
result = nsxlib.delete_logical_switch(fake_switch['id'])
|
result = nsxlib_delete_logical_switch(fake_switch['id'])
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
0
vmware_nsx/tests/unit/services/__init__.py
Normal file
0
vmware_nsx/tests/unit/services/__init__.py
Normal file
@ -29,8 +29,8 @@ from vmware_nsx.common import nsx_constants
|
|||||||
from vmware_nsx.nsxlib import v3 as nsxlib
|
from vmware_nsx.nsxlib import v3 as nsxlib
|
||||||
from vmware_nsx.services.l2gateway.common import plugin as l2gw_plugin
|
from vmware_nsx.services.l2gateway.common import plugin as l2gw_plugin
|
||||||
from vmware_nsx.services.l2gateway.nsx_v3 import driver as nsx_v3_driver
|
from vmware_nsx.services.l2gateway.nsx_v3 import driver as nsx_v3_driver
|
||||||
from vmware_nsx.tests.unit.vmware import nsx_v3_mocks
|
from vmware_nsx.tests.unit.nsx_v3 import mocks as nsx_v3_mocks
|
||||||
from vmware_nsx.tests.unit.vmware import test_nsx_v3_plugin
|
from vmware_nsx.tests.unit.nsx_v3 import test_plugin as test_nsx_v3_plugin
|
||||||
|
|
||||||
NSX_V3_PLUGIN_CLASS = ('vmware_nsx.plugins.nsx_v3.plugin.NsxV3Plugin')
|
NSX_V3_PLUGIN_CLASS = ('vmware_nsx.plugins.nsx_v3.plugin.NsxV3Plugin')
|
||||||
NSX_V3_L2GW_DRIVER_CLASS_PATH = ('vmware_nsx.services.l2gateway.'
|
NSX_V3_L2GW_DRIVER_CLASS_PATH = ('vmware_nsx.services.l2gateway.'
|
@ -1,58 +0,0 @@
|
|||||||
# Copyright 2013 OpenStack Foundation.
|
|
||||||
#
|
|
||||||
# All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from networking_l2gw.db.l2gateway import l2gateway_models # noqa
|
|
||||||
|
|
||||||
from vmware_nsx.api_client import client as nsx_client
|
|
||||||
from vmware_nsx.api_client import eventlet_client
|
|
||||||
from vmware_nsx import extensions
|
|
||||||
import vmware_nsx.plugin as neutron_plugin
|
|
||||||
from vmware_nsx.plugins.nsx_v.vshield.common import (
|
|
||||||
VcnsApiClient as vcnsapi)
|
|
||||||
from vmware_nsx.plugins.nsx_v.vshield import edge_utils
|
|
||||||
from vmware_nsx.plugins.nsx_v.vshield import vcns
|
|
||||||
import vmware_nsx.plugins.nsx_v.vshield.vcns_driver as vcnsdriver
|
|
||||||
|
|
||||||
|
|
||||||
plugin = neutron_plugin.NsxPlugin
|
|
||||||
api_client = nsx_client.NsxApiClient
|
|
||||||
evt_client = eventlet_client.EventletApiClient
|
|
||||||
vcns_class = vcns.Vcns
|
|
||||||
vcns_driver = vcnsdriver.VcnsDriver
|
|
||||||
vcns_api_helper = vcnsapi.VcnsApiHelper
|
|
||||||
edge_manage_class = edge_utils.EdgeManager
|
|
||||||
|
|
||||||
STUBS_PATH = os.path.join(os.path.dirname(__file__), 'etc')
|
|
||||||
NSXEXT_PATH = os.path.dirname(extensions.__file__)
|
|
||||||
NSXAPI_NAME = '%s.%s' % (api_client.__module__, api_client.__name__)
|
|
||||||
PLUGIN_NAME = '%s.%s' % (plugin.__module__, plugin.__name__)
|
|
||||||
CLIENT_NAME = '%s.%s' % (evt_client.__module__, evt_client.__name__)
|
|
||||||
VCNS_NAME = '%s.%s' % (vcns_class.__module__, vcns_class.__name__)
|
|
||||||
VCNS_DRIVER_NAME = '%s.%s' % (vcns_driver.__module__, vcns_driver.__name__)
|
|
||||||
VCNSAPI_NAME = '%s.%s' % (vcns_api_helper.__module__, vcns_api_helper.__name__)
|
|
||||||
EDGE_MANAGE_NAME = '%s.%s' % (edge_manage_class.__module__,
|
|
||||||
edge_manage_class.__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def get_fake_conf(filename):
|
|
||||||
return os.path.join(STUBS_PATH, filename)
|
|
||||||
|
|
||||||
|
|
||||||
def nsx_method(method_name, module_name='nsxlib'):
|
|
||||||
return '%s.%s.%s' % ('vmware_nsx', module_name,
|
|
||||||
method_name)
|
|
Loading…
x
Reference in New Issue
Block a user