Fixing the tests to run again

Also some minor pep8 and pylint fixes.

Change-Id: I22348710a7829197b539830f6acdc92b619bdc0c
This commit is contained in:
Brandon Logan 2014-12-11 23:30:00 -06:00
parent 12a3a2b2da
commit 3028ab0326
34 changed files with 100 additions and 109 deletions

View File

@ -19,9 +19,6 @@ from oslo.db.sqlalchemy import session
import sqlalchemy as sa
from sqlalchemy import event
from neutron.db.migration.models import head # noqa
from neutron.db.migration.cli import * # noqa
MYSQL_ENGINE = None
LBAAS_VERSION_TABLE = 'alembic_version_lbaas'
@ -85,4 +82,4 @@ def run_migrations_online():
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
run_migrations_online()

View File

@ -1,19 +0,0 @@
# Copyright 2011 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.
from oslo.config import cfg
cfg.CONF.use_stderr = False

View File

@ -0,0 +1,26 @@
# Copyright (c) 2014 OpenStack Foundation.
#
# 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
import neutron
from oslo.config import cfg
def override_nvalues():
neutron_path = os.path.abspath(
os.path.join(os.path.dirname(neutron.__file__), os.pardir))
neutron_policy = os.path.join(neutron_path, 'etc/policy.json')
cfg.CONF.set_override('policy_file', neutron_policy)

View File

@ -16,10 +16,7 @@
import contextlib
import mock
from oslo.config import cfg
import testtools
import webob.exc
import neutron
from neutron.api import extensions
from neutron.common import config
from neutron.common import exceptions as n_exc
@ -31,20 +28,25 @@ from neutron import manager
from neutron.plugins.common import constants
from neutron.services import provider_configuration as pconf
from neutron.tests.unit import test_db_plugin
from oslo.config import cfg
import testtools
import webob.exc
from neutron_lbaas.db.loadbalancer import loadbalancer_db as ldb
from neutron_lbaas.services.loadbalancer import (
plugin as loadbalancer_plugin
)
from neutron_lbaas.services.loadbalancer.drivers import abstract_driver
from neutron_lbaas import tests
DB_CORE_PLUGIN_KLASS = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2'
DB_LB_PLUGIN_KLASS = (
"neutron.services.loadbalancer."
"neutron_lbaas.services.loadbalancer."
"plugin.LoadBalancerPlugin"
)
NOOP_DRIVER_KLASS = ('neutron.tests.unit.db.loadbalancer.test_db_loadbalancer.'
'NoopLbaaSDriver')
NOOP_DRIVER_KLASS = ('neutron_lbaas.tests.unit.db.loadbalancer.'
'test_db_loadbalancer.NoopLbaaSDriver')
extensions_path = ':'.join(neutron.extensions.__path__)
@ -301,6 +303,7 @@ class LoadBalancerPluginDbTestCase(LoadBalancerTestMixin,
test_db_plugin.NeutronDbPluginV2TestCase):
def setUp(self, core_plugin=None, lb_plugin=None, lbaas_provider=None,
ext_mgr=None):
tests.override_nvalues()
service_plugins = {'lb_plugin_name': DB_LB_PLUGIN_KLASS}
if not lbaas_provider:
lbaas_provider = (
@ -316,7 +319,6 @@ class LoadBalancerPluginDbTestCase(LoadBalancerTestMixin,
ext_mgr=ext_mgr,
service_plugins=service_plugins
)
if not ext_mgr:
self.plugin = loadbalancer_plugin.LoadBalancerPlugin()
ext_mgr = extensions.PluginAwareExtensionManager(
@ -327,7 +329,7 @@ class LoadBalancerPluginDbTestCase(LoadBalancerTestMixin,
self.ext_api = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr)
get_lbaas_agent_patcher = mock.patch(
'neutron.services.loadbalancer.agent_scheduler'
'neutron_lbaas.services.loadbalancer.agent_scheduler'
'.LbaasAgentSchedulerDbMixin.get_lbaas_agent_hosting_pool')
mock_lbaas_agent = mock.MagicMock()
get_lbaas_agent_patcher.start().return_value = mock_lbaas_agent
@ -639,7 +641,7 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
prov1 = (constants.LOADBALANCER +
':lbaas:' + NOOP_DRIVER_KLASS)
prov2 = (constants.LOADBALANCER +
':haproxy:neutron.services.loadbalancer.'
':haproxy:neutron_lbaas.services.loadbalancer.'
'drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver'
':default')
cfg.CONF.set_override('service_provider',

View File

@ -14,9 +14,9 @@
import contextlib
import mock
from neutron.tests import base
from oslo.config import cfg
from neutron.tests import base
from neutron_lbaas.services.loadbalancer.agent import agent

View File

@ -15,9 +15,9 @@
import contextlib
import mock
from neutron.plugins.common import constants
from neutron.tests import base
from neutron_lbaas.services.loadbalancer.agent import agent_manager as manager
@ -31,7 +31,7 @@ class TestManager(base.BaseTestCase):
self.mock_importer = mock.patch.object(manager, 'importutils').start()
rpc_mock_cls = mock.patch(
'neutron.services.loadbalancer.agent.agent_api.LbaasAgentApi'
'neutron_lbaas.services.loadbalancer.agent.agent_api.LbaasAgentApi'
).start()
# disable setting up periodic state reporting

View File

@ -15,8 +15,8 @@
import contextlib
import copy
import mock
from neutron.tests import base
from neutron_lbaas.services.loadbalancer.agent import agent_api as api

View File

@ -15,10 +15,10 @@
import sys
import mock
from neutron import context
from neutron.tests.unit.db.loadbalancer import test_db_loadbalancer
from neutron_lbaas.db.loadbalancer import loadbalancer_db as lb_db
from neutron_lbaas.tests.unit.db.loadbalancer import test_db_loadbalancer
with mock.patch.dict(sys.modules, {'a10_neutron_lbaas': mock.Mock()}):
from neutron_lbaas.services.loadbalancer.drivers.a10networks \
import driver_v1

View File

@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.tests import base
from oslo.config import cfg
from neutron.tests import base
from neutron_lbaas.services.loadbalancer.drivers.embrane import config # noqa

View File

@ -16,11 +16,11 @@
import sys
import mock
from neutron import context
from oslo.config import cfg
from oslo.db import exception as n_exc
from neutron import context
from neutron.tests.unit.db.loadbalancer import test_db_loadbalancer
from neutron_lbaas.tests.unit.db.loadbalancer import test_db_loadbalancer
HELEOSAPIMOCK = mock.Mock()
sys.modules["heleosapi"] = HELEOSAPIMOCK
@ -31,7 +31,7 @@ from neutron_lbaas.services.loadbalancer.drivers.embrane import db as h_db
# Stop the mock from persisting indefinitely in the global modules space
del sys.modules["heleosapi"]
EMBRANE_PROVIDER = ('LOADBALANCER:lbaas:neutron.services.'
EMBRANE_PROVIDER = ('LOADBALANCER:lbaas:neutron_lbaas.services.'
'loadbalancer.drivers.embrane.driver.'
'EmbraneLbaas:default')

View File

@ -16,21 +16,21 @@
import contextlib
import mock
from neutron.tests import base
from neutron_lbaas.services.loadbalancer.drivers.haproxy import cfg
class TestHaproxyCfg(base.BaseTestCase):
def test_save_config(self):
with contextlib.nested(
mock.patch('neutron.services.loadbalancer.'
mock.patch('neutron_lbaas.services.loadbalancer.'
'drivers.haproxy.cfg._build_global'),
mock.patch('neutron.services.loadbalancer.'
mock.patch('neutron_lbaas.services.loadbalancer.'
'drivers.haproxy.cfg._build_defaults'),
mock.patch('neutron.services.loadbalancer.'
mock.patch('neutron_lbaas.services.loadbalancer.'
'drivers.haproxy.cfg._build_frontend'),
mock.patch('neutron.services.loadbalancer.'
mock.patch('neutron_lbaas.services.loadbalancer.'
'drivers.haproxy.cfg._build_backend'),
mock.patch('neutron.agent.linux.utils.replace_file')
) as (b_g, b_d, b_f, b_b, replace):

View File

@ -15,9 +15,9 @@
import contextlib
import mock
from neutron.common import exceptions
from neutron.tests import base
from neutron_lbaas.services.loadbalancer.drivers.haproxy \
import namespace_driver

View File

@ -13,12 +13,13 @@
# under the License.
import mock
from neutron import context
from neutron.tests.unit.db.loadbalancer import test_db_loadbalancer
from neutron_lbaas.services.loadbalancer.drivers.logging_noop import driver
log_path = 'neutron.services.loadbalancer.drivers.logging_noop.driver.LOG'
from neutron_lbaas.services.loadbalancer.drivers.logging_noop import driver
from neutron_lbaas.tests.unit.db.loadbalancer import test_db_loadbalancer
log_path = ('neutron_lbaas.services.loadbalancer.drivers.'
'logging_noop.driver.LOG')
class FakeModel(object):

View File

@ -13,14 +13,14 @@
# under the License.
import mock
from neutron.tests.unit import testlib_api
import requests
from neutron.tests.unit import testlib_api
from neutron_lbaas.services.loadbalancer.drivers.netscaler import ncc_client
from neutron_lbaas.services.loadbalancer.drivers.netscaler \
import netscaler_driver
NCC_CLIENT_CLASS = ('neutron.services.loadbalancer.drivers'
NCC_CLIENT_CLASS = ('neutron_lbaas.services.loadbalancer.drivers'
'.netscaler.ncc_client.NSClient')
TESTURI_SCHEME = 'http'

View File

@ -15,23 +15,23 @@
import contextlib
import mock
from neutron.common import exceptions
from neutron import context
from neutron import manager
from neutron.plugins.common import constants
from neutron.tests.unit.db.loadbalancer import test_db_loadbalancer
from neutron_lbaas.db.loadbalancer import loadbalancer_db
from neutron_lbaas.services.loadbalancer.drivers.netscaler import ncc_client
from neutron_lbaas.services.loadbalancer.drivers.netscaler \
import netscaler_driver
from neutron_lbaas.tests.unit.db.loadbalancer import test_db_loadbalancer
LBAAS_DRIVER_CLASS = ('neutron.services.loadbalancer.drivers'
LBAAS_DRIVER_CLASS = ('neutron_lbaas.services.loadbalancer.drivers'
'.netscaler.netscaler_driver'
'.NetScalerPluginDriver')
NCC_CLIENT_CLASS = ('neutron.services.loadbalancer.drivers'
NCC_CLIENT_CLASS = ('neutron_lbaas.services.loadbalancer.drivers'
'.netscaler.ncc_client'
'.NSClient')

View File

@ -16,19 +16,19 @@ import re
import contextlib
import mock
from oslo.config import cfg
from oslo.serialization import jsonutils
from six.moves import queue as Queue
from neutron.api.v2 import attributes
from neutron import context
from neutron.extensions import loadbalancer
from neutron import manager
from neutron.plugins.common import constants
from neutron.tests.unit.db.loadbalancer import test_db_loadbalancer
from oslo.config import cfg
from oslo.serialization import jsonutils
from six.moves import queue as Queue
from neutron_lbaas.services.loadbalancer.drivers.radware import driver
from neutron_lbaas.services.loadbalancer.drivers.radware \
import exceptions as r_exc
from neutron_lbaas.tests.unit.db.loadbalancer import test_db_loadbalancer
GET_200 = ('/api/workflow/', '/api/service/', '/api/workflowTemplate')
SERVER_DOWN_CODES = (-1, 301, 307)
@ -96,7 +96,7 @@ def _post_handler(resource, binary):
else:
return 202, '', '', ''
RADWARE_PROVIDER = ('LOADBALANCER:radware:neutron.services.'
RADWARE_PROVIDER = ('LOADBALANCER:radware:neutron_lbaas.services.'
'loadbalancer.drivers.radware.driver.'
'LoadBalancerDriver:default')

View File

@ -15,9 +15,6 @@
import contextlib
import mock
from six import moves
from webob import exc
from neutron import context
from neutron.db import servicetype_db as st_db
from neutron.extensions import loadbalancer
@ -26,11 +23,14 @@ from neutron import manager
from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants
from neutron.tests import base
from neutron.tests.unit.db.loadbalancer import test_db_loadbalancer
from neutron.tests.unit import testlib_api
from six import moves
from webob import exc
from neutron_lbaas.db.loadbalancer import loadbalancer_db as ldb
from neutron_lbaas.services.loadbalancer.drivers.common \
import agent_driver_base
from neutron_lbaas.tests.unit.db.loadbalancer import test_db_loadbalancer
class TestLoadBalancerPluginBase(
@ -48,7 +48,7 @@ class TestLoadBalancerPluginBase(
st_db.ServiceTypeManager._instance = None
agent_driver_base.AgentDriverBase.device_driver = 'dummy'
super(TestLoadBalancerPluginBase, self).setUp(
lbaas_provider=('LOADBALANCER:lbaas:neutron.services.'
lbaas_provider=('LOADBALANCER:lbaas:neutron_lbaas.services.'
'loadbalancer.drivers.common.agent_driver_base.'
'AgentDriverBase:default'))
@ -66,14 +66,14 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase):
self.plugin_instance
)
get_lbaas_agents_patcher = mock.patch(
'neutron.services.loadbalancer.agent_scheduler'
'neutron_lbaas.services.loadbalancer.agent_scheduler'
'.LbaasAgentSchedulerDbMixin.get_lbaas_agents')
get_lbaas_agents_patcher.start()
def test_get_ready_devices(self):
with self.vip() as vip:
with mock.patch('neutron.services.loadbalancer.agent_scheduler'
'.LbaasAgentSchedulerDbMixin.'
with mock.patch('neutron_lbaas.services.loadbalancer.'
'agent_scheduler.LbaasAgentSchedulerDbMixin.'
'list_pools_on_lbaas_agent') as mock_agent_pools:
mock_agent_pools.return_value = {
'pools': [{'id': vip['vip']['pool_id']}]}
@ -121,7 +121,7 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase):
self.assertEqual(ctx.session.query(ldb.Pool).count(), 3)
self.assertEqual(ctx.session.query(ldb.Vip).count(), 2)
with mock.patch('neutron.services.loadbalancer.agent_scheduler'
with mock.patch('neutron_lbaas.services.loadbalancer.agent_scheduler'
'.LbaasAgentSchedulerDbMixin'
'.list_pools_on_lbaas_agent') as mock_agent_pools:
mock_agent_pools.return_value = {'pools': [{'id': pools[0].id},
@ -146,8 +146,8 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase):
vip['vip']['id'],
{'vip': {'status': constants.INACTIVE}}
)
with mock.patch('neutron.services.loadbalancer.agent_scheduler'
'.LbaasAgentSchedulerDbMixin.'
with mock.patch('neutron_lbaas.services.loadbalancer.'
'agent_scheduler.LbaasAgentSchedulerDbMixin.'
'list_pools_on_lbaas_agent') as mock_agent_pools:
mock_agent_pools.return_value = {
'pools': [{'id': vip['vip']['pool_id']}]}
@ -166,8 +166,8 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase):
vip['vip']['pool_id'],
{'pool': {'status': constants.INACTIVE}}
)
with mock.patch('neutron.services.loadbalancer.agent_scheduler'
'.LbaasAgentSchedulerDbMixin.'
with mock.patch('neutron_lbaas.services.loadbalancer.'
'agent_scheduler.LbaasAgentSchedulerDbMixin.'
'list_pools_on_lbaas_agent') as mock_agent_pools:
mock_agent_pools.return_value = {
'pools': [{'id': vip['vip']['pool_id']}]}

View File

@ -14,9 +14,6 @@
# limitations under the License.
import mock
from oslo.config import cfg
from webob import exc
from neutron.api import extensions
from neutron.api.v2 import attributes
from neutron.common import constants
@ -27,11 +24,15 @@ from neutron.extensions import lbaas_agentscheduler
from neutron.extensions import loadbalancer
from neutron import manager
from neutron.plugins.common import constants as plugin_const
from neutron.tests.unit.db.loadbalancer import test_db_loadbalancer
from neutron.tests.unit.openvswitch import test_agent_scheduler
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 oslo.config import cfg
from webob import exc
from neutron_lbaas import tests
from neutron_lbaas.tests.unit.db.loadbalancer import test_db_loadbalancer
LBAAS_HOSTA = 'hosta'
@ -65,6 +66,7 @@ class LBaaSAgentSchedulerTestCase(test_agent_ext_plugin.AgentDBTestMixIn,
def setUp(self):
# Save the global RESOURCE_ATTRIBUTE_MAP
tests.override_nvalues()
self.saved_attr_map = {}
for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
self.saved_attr_map[resource] = attrs.copy()
@ -74,7 +76,7 @@ class LBaaSAgentSchedulerTestCase(test_agent_ext_plugin.AgentDBTestMixIn,
#default provider should support agent scheduling
cfg.CONF.set_override(
'service_provider',
[('LOADBALANCER:lbaas:neutron.services.'
[('LOADBALANCER:lbaas:neutron_lbaas.services.'
'loadbalancer.drivers.haproxy.plugin_driver.'
'HaproxyOnHostPluginDriver:default')],
'service_providers')

View File

@ -16,14 +16,15 @@
import copy
import mock
from webob import exc
from neutron.api.v2 import attributes as attr
from neutron.extensions import loadbalancer
from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants
from neutron.tests.unit import test_api_v2
from neutron.tests.unit import test_api_v2_extension
from webob import exc
from neutron_lbaas import tests
_uuid = uuidutils.generate_uuid
@ -35,6 +36,7 @@ class LoadBalancerExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
def setUp(self):
super(LoadBalancerExtensionTestCase, self).setUp()
tests.override_nvalues()
self._setUpExtension(
'neutron.extensions.loadbalancer.LoadBalancerPluginBase',
constants.LOADBALANCER, loadbalancer.RESOURCE_ATTRIBUTE_MAP,

View File

@ -13,12 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
from neutron import context
from neutron import quota
from neutron.tests.unit import test_api_v2
from neutron.tests.unit import test_quota_ext
from oslo.config import cfg
from neutron_lbaas import tests
_get_path = test_api_v2._get_path
@ -28,6 +29,7 @@ class LBaaSQuotaExtensionTestCase(
def setUp(self):
super(LBaaSQuotaExtensionTestCase, self).setUp()
tests.override_nvalues()
cfg.CONF.set_override(
'quota_items',
['vip', 'pool', 'member', 'health_monitor', 'extra1'],

View File

@ -1,22 +0,0 @@
# Copyright 2012 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 unittest
class FakeTest(unittest.TestCase):
def test_true(self):
self.assertTrue(True)