Restore and fix vmware unit tests
This patch actually restores vmware unit tests, by adding back
the __init__.py file which was renamed during the advanced
service spinoff and not reinstated when fixing vmware code to
comply with the spinoff.
Furthermore, this patch also fixes a minor issue with context
usage in vmware unit tests which is triggering failures because
of the new database constraint introduced with the commit
79c97120de
Finally, flake8 tests on vmware directories are also restored
with this patch.
Change-Id: Ib63463fca28bbb4a1eb60b8f5f4b63b3d3367c9e
Closes-Bug: #1416593
Closes-Bug: #1416596
This commit is contained in:
parent
38f2704a85
commit
568f3562ae
|
@ -0,0 +1,44 @@
|
|||
# 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 neutron.plugins.vmware.api_client import client as nsx_client
|
||||
from neutron.plugins.vmware.api_client import eventlet_client
|
||||
from neutron.plugins.vmware import extensions
|
||||
import neutron.plugins.vmware.plugin as neutron_plugin
|
||||
from neutron.plugins.vmware.vshield import vcns
|
||||
|
||||
|
||||
plugin = neutron_plugin.NsxPlugin
|
||||
api_client = nsx_client.NsxApiClient
|
||||
evt_client = eventlet_client.EventletApiClient
|
||||
vcns_class = vcns.Vcns
|
||||
|
||||
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__)
|
||||
|
||||
|
||||
def get_fake_conf(filename):
|
||||
return os.path.join(STUBS_PATH, filename)
|
||||
|
||||
|
||||
def nsx_method(method_name, module_name='nsxlib'):
|
||||
return '%s.%s.%s' % ('neutron.plugins.vmware', module_name, method_name)
|
|
@ -34,7 +34,7 @@ def _validate_resource(body):
|
|||
_validate_name(body.get('display_name'))
|
||||
|
||||
|
||||
class FakeClient:
|
||||
class FakeClient(object):
|
||||
|
||||
LSWITCH_RESOURCE = 'lswitch'
|
||||
LPORT_RESOURCE = 'lport'
|
||||
|
|
|
@ -18,6 +18,7 @@ from sqlalchemy import orm
|
|||
from neutron import context
|
||||
from neutron.plugins.vmware.common import exceptions as p_exc
|
||||
from neutron.plugins.vmware.dbexts import lsn_db
|
||||
from neutron.plugins.vmware.dbexts import nsx_models
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
||||
|
@ -34,20 +35,22 @@ class LSNTestCase(testlib_api.SqlTestCase):
|
|||
|
||||
def test_lsn_add(self):
|
||||
lsn_db.lsn_add(self.ctx, self.net_id, self.lsn_id)
|
||||
lsn = (self.ctx.session.query(lsn_db.Lsn).
|
||||
lsn = (self.ctx.session.query(nsx_models.Lsn).
|
||||
filter_by(lsn_id=self.lsn_id).one())
|
||||
self.assertEqual(self.lsn_id, lsn.lsn_id)
|
||||
|
||||
def test_lsn_remove(self):
|
||||
lsn_db.lsn_add(self.ctx, self.net_id, self.lsn_id)
|
||||
lsn_db.lsn_remove(self.ctx, self.lsn_id)
|
||||
q = self.ctx.session.query(lsn_db.Lsn).filter_by(lsn_id=self.lsn_id)
|
||||
q = self.ctx.session.query(nsx_models.Lsn).filter_by(
|
||||
lsn_id=self.lsn_id)
|
||||
self.assertRaises(orm.exc.NoResultFound, q.one)
|
||||
|
||||
def test_lsn_remove_for_network(self):
|
||||
lsn_db.lsn_add(self.ctx, self.net_id, self.lsn_id)
|
||||
lsn_db.lsn_remove_for_network(self.ctx, self.net_id)
|
||||
q = self.ctx.session.query(lsn_db.Lsn).filter_by(lsn_id=self.lsn_id)
|
||||
q = self.ctx.session.query(nsx_models.Lsn).filter_by(
|
||||
lsn_id=self.lsn_id)
|
||||
self.assertRaises(orm.exc.NoResultFound, q.one)
|
||||
|
||||
def test_lsn_get_for_network(self):
|
||||
|
@ -64,7 +67,7 @@ class LSNTestCase(testlib_api.SqlTestCase):
|
|||
lsn_db.lsn_add(self.ctx, self.net_id, self.lsn_id)
|
||||
lsn_db.lsn_port_add_for_lsn(self.ctx, self.lsn_port_id,
|
||||
self.subnet_id, self.mac_addr, self.lsn_id)
|
||||
result = (self.ctx.session.query(lsn_db.LsnPort).
|
||||
result = (self.ctx.session.query(nsx_models.LsnPort).
|
||||
filter_by(lsn_port_id=self.lsn_port_id).one())
|
||||
self.assertEqual(self.lsn_port_id, result.lsn_port_id)
|
||||
|
||||
|
@ -95,6 +98,6 @@ class LSNTestCase(testlib_api.SqlTestCase):
|
|||
def test_lsn_port_remove(self):
|
||||
lsn_db.lsn_add(self.ctx, self.net_id, self.lsn_id)
|
||||
lsn_db.lsn_port_remove(self.ctx, self.lsn_port_id)
|
||||
q = (self.ctx.session.query(lsn_db.LsnPort).
|
||||
q = (self.ctx.session.query(nsx_models.LsnPort).
|
||||
filter_by(lsn_port_id=self.lsn_port_id))
|
||||
self.assertRaises(orm.exc.NoResultFound, q.one)
|
||||
|
|
|
@ -345,7 +345,7 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxPluginV2TestCase):
|
|||
nsxlib.switch, 'update_lswitch') as update_lswitch_mock:
|
||||
# don't worry about deleting this network, do not use
|
||||
# context manager
|
||||
ctx = context.get_admin_context()
|
||||
ctx = context.Context(user_id=None, tenant_id='gonzalo')
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
net = plugin.create_network(
|
||||
ctx, {'network': {'name': 'xxx',
|
||||
|
|
3
tox.ini
3
tox.ini
|
@ -78,8 +78,7 @@ commands = python setup.py build_sphinx
|
|||
ignore = E125,E126,E128,E129,E265,H305,H404,H405
|
||||
show-source = true
|
||||
builtins = _
|
||||
# TODO(dougw) neutron/tests/unit/vmware exclusion is a temporary services split hack
|
||||
exclude = ./.*,build,dist,neutron/openstack/common/*,neutron/tests/unit/vmware*
|
||||
exclude = ./.*,build,dist,neutron/openstack/common/*
|
||||
|
||||
[testenv:pylint]
|
||||
deps =
|
||||
|
|
Loading…
Reference in New Issue