Exemple #1
0
    def setUp(self):
        # mock api client
        self.fc = fake.FakeClient(vmware.STUBS_PATH)
        mock_api = mock.patch(vmware.NSXAPI_NAME, autospec=True)
        # Avoid runs of the synchronizer looping call
        # These unit tests will excplicitly invoke synchronization
        patch_sync = mock.patch.object(sync, '_start_loopingcall')
        self.mock_api = mock_api.start()
        patch_sync.start()
        self.mock_api.return_value.login.return_value = "the_cookie"
        # Emulate tests against NSX 3.x
        self.mock_api.return_value.get_version.return_value = (
            version.Version("3.1"))

        self.mock_api.return_value.request.side_effect = self.fc.fake_request
        self.fake_cluster = cluster.NSXCluster(name='fake-cluster',
                                               nsx_controllers=['1.1.1.1:999'],
                                               default_tz_uuid=_uuid(),
                                               nsx_user='******',
                                               nsx_password='******')
        self.fake_cluster.api_client = client.NsxApiClient(
            ('1.1.1.1', '999', True),
            self.fake_cluster.nsx_user,
            self.fake_cluster.nsx_password,
            http_timeout=self.fake_cluster.http_timeout,
            retries=self.fake_cluster.retries,
            redirects=self.fake_cluster.redirects)
        # Instantiate Neutron plugin
        # and setup needed config variables
        args = [
            '--config-file',
            vmware.get_fake_conf('neutron.conf.test'), '--config-file',
            vmware.get_fake_conf('nsx.ini.test')
        ]
        self.config_parse(args=args)
        cfg.CONF.set_override('allow_overlapping_ips', True)
        self._plugin = plugin.NsxPlugin()
        # Mock neutron manager plugin load functions to speed up tests
        mock_nm_get_plugin = mock.patch('neutron.manager.NeutronManager.'
                                        'get_plugin')
        mock_nm_get_service_plugins = mock.patch(
            'neutron.manager.NeutronManager.get_service_plugins')
        self.mock_nm_get_plugin = mock_nm_get_plugin.start()
        self.mock_nm_get_plugin.return_value = self._plugin
        mock_nm_get_service_plugins.start()
        super(SyncTestCase, self).setUp()
        self.addCleanup(self.fc.reset_all)
Exemple #2
0
    def setUp(self):
        # mock api client
        self.fc = fake.FakeClient(vmware.STUBS_PATH)
        mock_api = mock.patch(vmware.NSXAPI_NAME, autospec=True)
        # Avoid runs of the synchronizer looping call
        # These unit tests will excplicitly invoke synchronization
        patch_sync = mock.patch.object(sync, '_start_loopingcall')
        self.mock_api = mock_api.start()
        patch_sync.start()
        self.mock_api.return_value.login.return_value = "the_cookie"
        # Emulate tests against NSX 3.x
        self.mock_api.return_value.get_version.return_value = (
            version.Version("3.1"))

        self.mock_api.return_value.request.side_effect = self.fc.fake_request
        self.fake_cluster = cluster.NSXCluster(
            name='fake-cluster', nsx_controllers=['1.1.1.1:999'],
            default_tz_uuid=_uuid(), nsx_user='******', nsx_password='******')
        self.fake_cluster.api_client = client.NsxApiClient(
            ('1.1.1.1', '999', True),
            self.fake_cluster.nsx_user, self.fake_cluster.nsx_password,
            http_timeout=self.fake_cluster.http_timeout,
            retries=self.fake_cluster.retries,
            redirects=self.fake_cluster.redirects)
        # Instantiate Neutron plugin
        # and setup needed config variables
        args = ['--config-file', vmware.get_fake_conf('neutron.conf.test'),
                '--config-file', vmware.get_fake_conf('nsx.ini.test')]
        self.config_parse(args=args)
        cfg.CONF.set_override('allow_overlapping_ips', True)

        with mock.patch("neutron_lib.rpc.Connection"):
            self._plugin = plugin.NsxPlugin()

        mock_nm_get_plugin = mock.patch(
            "neutron_lib.plugins.directory.get_plugin")
        self.mock_nm_get_plugin = mock_nm_get_plugin.start()
        self.mock_nm_get_plugin.return_value = self._plugin

        super(SyncTestCase, self).setUp()
        self.addCleanup(self.fc.reset_all)
Exemple #3
0
from oslo_config import cfg
import six

from vmware_nsx.common import exceptions as nsxv_exc
from vmware_nsx.plugins.nsx_v import availability_zones as nsx_az
from vmware_nsx.plugins.nsx_v.vshield.common import (
    constants as vcns_const)
from vmware_nsx.plugins.nsx_v.vshield import edge_appliance_driver as e_drv
from vmware_nsx.plugins.nsx_v.vshield.tasks import (
    constants as ts_const)
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.tests import unit as vmware
from vmware_nsx.tests.unit.nsx_v.vshield import fake_vcns

VCNS_CONFIG_FILE = vmware.get_fake_conf("vcns.ini.test")

ts.TaskManager.set_default_interval(100)


class VcnsDriverTaskManagerTestCase(base.BaseTestCase):

    def setUp(self):
        super(VcnsDriverTaskManagerTestCase, self).setUp()
        self.manager = ts.TaskManager()
        self.manager.start(100)

    def tearDown(self):
        self.manager.stop()
        # Task manager should not leave running threads around
        # if _thread is None it means it was killed in stop()
Exemple #4
0
from neutron_lib.callbacks import registry

from vmware_nsx._i18n import _
from vmware_nsx.common import config  # noqa
from vmware_nsx.db import nsxv_db
from vmware_nsx.dvs import dvs_utils
from vmware_nsx.shell.admin.plugins.nsxv.resources import utils as nsxv_utils
from vmware_nsx.shell.admin.plugins.nsxv3.resources import utils as nsxv3_utils
from vmware_nsx.shell import resources
from vmware_nsx.tests import unit as vmware
from vmware_nsx.tests.unit.nsx_v import test_plugin as test_v_plugin
from vmware_nsx.tests.unit.nsx_v3 import test_plugin as test_v3_plugin
from vmware_nsxlib.v3 import resources as nsx_v3_resources

LOG = logging.getLogger(__name__)
NSX_INI_PATH = vmware.get_fake_conf('nsx.ini.test')
BASE_CONF_PATH = vmware.get_fake_conf('neutron.conf.test')


@six.add_metaclass(abc.ABCMeta)
class AbstractTestAdminUtils(base.BaseTestCase):
    def setUp(self):
        cfg.CONF.unregister_opts(_options.common_cli_opts)
        cfg.CONF.register_cli_opts(resources.cli_opts)

        super(AbstractTestAdminUtils, self).setUp()

        # remove resource registration conflicts
        resource_registry.unregister_all_resources()

        # Init the neutron config
from eventlet import greenthread
import mock

from neutron.tests import base
import six

from vmware_nsx.plugins.nsx_v.vshield.common import (
    constants as vcns_const)
from vmware_nsx.plugins.nsx_v.vshield.tasks import (
    constants as ts_const)
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.tests import unit as vmware
from vmware_nsx.tests.unit.nsx_v.vshield import fake_vcns

VCNS_CONFIG_FILE = vmware.get_fake_conf("vcns.ini.test")

ts.TaskManager.set_default_interval(100)


class VcnsDriverTaskManagerTestCase(base.BaseTestCase):

    def setUp(self):
        super(VcnsDriverTaskManagerTestCase, self).setUp()
        self.manager = ts.TaskManager()
        self.manager.start(100)

    def tearDown(self):
        self.manager.stop()
        # Task manager should not leave running threads around
        # if _thread is None it means it was killed in stop()
Exemple #6
0
from neutron.tests import base
from oslo_config import cfg
from oslo_utils import uuidutils
import six

from vmware_nsx.api_client import client
from vmware_nsx.api_client import version
from vmware_nsx.common import config  # noqa
from vmware_nsx.common import exceptions
from vmware_nsx.common import sync
from vmware_nsx import nsx_cluster
from vmware_nsx.nsxlib.mh import lsn as lsnlib
from vmware_nsx import plugin as mh_plugin
from vmware_nsx.tests import unit as vmware

BASE_CONF_PATH = vmware.get_fake_conf('neutron.conf.test')
NSX_INI_PATH = vmware.get_fake_conf('nsx.ini.basic.test')
NSX_INI_FULL_PATH = vmware.get_fake_conf('nsx.ini.full.test')
NSX_INI_AGENTLESS_PATH = vmware.get_fake_conf('nsx.ini.agentless.test')
NSX_INI_COMBINED_PATH = vmware.get_fake_conf('nsx.ini.combined.test')
NVP_INI_DEPR_PATH = vmware.get_fake_conf('nvp.ini.full.test')


class NSXClusterTest(base.BaseTestCase):

    cluster_opts = {
        'default_tz_uuid': uuidutils.generate_uuid(),
        'default_l2_gw_service_uuid': uuidutils.generate_uuid(),
        'default_l2_gw_service_uuid': uuidutils.generate_uuid(),
        'nsx_user': '******',
        'nsx_password': '******',
Exemple #7
0
from neutron import manager
from neutron.tests import base
from oslo_config import cfg
from oslo_utils import uuidutils
import six

from vmware_nsx.api_client import client
from vmware_nsx.api_client import version
from vmware_nsx.common import config  # noqa
from vmware_nsx.common import exceptions
from vmware_nsx.common import sync
from vmware_nsx import nsx_cluster
from vmware_nsx.nsxlib.mh import lsn as lsnlib
from vmware_nsx.tests import unit as vmware

BASE_CONF_PATH = vmware.get_fake_conf('neutron.conf.test')
NSX_INI_PATH = vmware.get_fake_conf('nsx.ini.basic.test')
NSX_INI_FULL_PATH = vmware.get_fake_conf('nsx.ini.full.test')
NSX_INI_AGENTLESS_PATH = vmware.get_fake_conf('nsx.ini.agentless.test')
NSX_INI_COMBINED_PATH = vmware.get_fake_conf('nsx.ini.combined.test')
NVP_INI_DEPR_PATH = vmware.get_fake_conf('nvp.ini.full.test')


class NSXClusterTest(base.BaseTestCase):

    cluster_opts = {'default_tz_uuid': uuidutils.generate_uuid(),
                    'default_l2_gw_service_uuid': uuidutils.generate_uuid(),
                    'default_l2_gw_service_uuid': uuidutils.generate_uuid(),
                    'nsx_user': '******',
                    'nsx_password': '******',
                    'http_timeout': 25,