diff --git a/quantum/db/db_base_plugin_v2.py b/quantum/db/db_base_plugin_v2.py index 5940487652..9cc2b4f78d 100644 --- a/quantum/db/db_base_plugin_v2.py +++ b/quantum/db/db_base_plugin_v2.py @@ -33,6 +33,7 @@ from quantum import quantum_plugin_base_v2 LOG = logging.getLogger(__name__) +TEST_DB = "quantum.test.db" AGENT_OWNER_PREFIX = 'network:' @@ -71,8 +72,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2): # must override __init__ and setup the database # and not call into this class's __init__. # This connection is setup as memory for the tests. - sql_connection = 'sqlite:///:memory:' - db.configure_db({'sql_connection': sql_connection, + db.configure_db({'sql_connection': "sqlite:///%s" % TEST_DB, 'base': models_v2.model_base.BASEV2}) def _get_tenant_id_for_create(self, context, resource): diff --git a/quantum/tests/etc/quantum.conf.test b/quantum/tests/etc/quantum.conf.test index 961af50420..2bf73d06c8 100644 --- a/quantum/tests/etc/quantum.conf.test +++ b/quantum/tests/etc/quantum.conf.test @@ -19,3 +19,6 @@ api_paste_config = api-paste.ini.test # The messaging module to use, defaults to kombu. rpc_backend = quantum.openstack.common.rpc.impl_fake + +[DATABASE] +sql_connection = 'sqlite:///quantum.test.db' \ No newline at end of file diff --git a/quantum/tests/unit/cisco/test_network_plugin.py b/quantum/tests/unit/cisco/test_network_plugin.py index 00f7448fb4..d4cfa5dd2d 100644 --- a/quantum/tests/unit/cisco/test_network_plugin.py +++ b/quantum/tests/unit/cisco/test_network_plugin.py @@ -42,7 +42,7 @@ class CiscoNetworkPluginV2TestCase(test_db_plugin.QuantumDbPluginV2TestCase): def setUp(self): def new_init(): - db.configure_db({'sql_connection': 'sqlite://', + db.configure_db({'sql_connection': 'sqlite:///quantum.test.db', 'base': network_models_v2.model_base.BASEV2}) with mock.patch.object(network_db_v2, diff --git a/quantum/tests/unit/linuxbridge/test_linuxbridge_plugin.py b/quantum/tests/unit/linuxbridge/test_linuxbridge_plugin.py index 03d3546be5..3a2c0b7c2d 100644 --- a/quantum/tests/unit/linuxbridge/test_linuxbridge_plugin.py +++ b/quantum/tests/unit/linuxbridge/test_linuxbridge_plugin.py @@ -43,8 +43,3 @@ class TestLinuxBridgePortsV2(test_plugin.TestPortsV2, class TestLinuxBridgeNetworksV2(test_plugin.TestNetworksV2, LinuxBridgePluginV2TestCase): pass - - -class TestLinuxBridgeSubnetsV2(test_plugin.TestSubnetsV2, - LinuxBridgePluginV2TestCase): - pass diff --git a/quantum/tests/unit/nec/test_nec_plugin.py b/quantum/tests/unit/nec/test_nec_plugin.py index ec7e197252..1d1aebdf51 100644 --- a/quantum/tests/unit/nec/test_nec_plugin.py +++ b/quantum/tests/unit/nec/test_nec_plugin.py @@ -39,7 +39,3 @@ class TestNecPortsV2(test_plugin.TestPortsV2, NecPluginV2TestCase): class TestNecNetworksV2(test_plugin.TestNetworksV2, NecPluginV2TestCase): pass - - -class TestNecSubnetsV2(test_plugin.TestSubnetsV2, NecPluginV2TestCase): - pass diff --git a/quantum/tests/unit/nec/test_nec_plugin_v2.py b/quantum/tests/unit/nec/test_nec_plugin_v2.py deleted file mode 100644 index 0f5c086862..0000000000 --- a/quantum/tests/unit/nec/test_nec_plugin_v2.py +++ /dev/null @@ -1,49 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# -# Copyright 2012 NEC Corporation. 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. -# @author: Ryota MIBU - -from quantum.plugins.nec.common import config -from quantum.tests.unit import test_db_plugin - - -class NECPluginTestBase(object): - - def setUp(self): - # Make sure at each test a new instance of the plugin is returned - test_db_plugin.QuantumManager._instance = None - - self._tenant_id = 'test-tenant' - - json_deserializer = test_db_plugin.JSONDeserializer() - self._deserializers = { - 'application/json': json_deserializer, - } - - plugin = 'quantum.plugins.nec.nec_plugin.NECPluginV2' - config.CONF.set_override('core_plugin', plugin) - driver = "quantum.tests.unit.nec.stub_ofc_driver.StubOFCDriver" - config.CONF.set_override('driver', driver, 'OFC') - config.CONF.set_override('rpc_backend', - 'quantum.openstack.common.rpc.impl_fake') - self.api = test_db_plugin.APIRouter() - self._skip_native_bulk = False - super(NECPluginTestBase, self).setUp(plugin) - - -# TODO(r-mibu): write UT for packet_filters. -class TestPacketFiltersV2(NECPluginTestBase, - test_db_plugin.QuantumDbPluginV2TestCase): - pass diff --git a/quantum/tests/unit/nicira/etc/nvp.ini.test b/quantum/tests/unit/nicira/etc/nvp.ini.test index 8167078751..d7452d5975 100644 --- a/quantum/tests/unit/nicira/etc/nvp.ini.test +++ b/quantum/tests/unit/nicira/etc/nvp.ini.test @@ -1,8 +1,5 @@ [DEFAULT] -[DATABASE] -sql_connection = sqlite:// - [CLUSTER:fake] default_tz_uuid = fake_tz_uuid nova_zone_id = whatever diff --git a/quantum/tests/unit/nicira/fake_nvpapiclient.py b/quantum/tests/unit/nicira/fake_nvpapiclient.py index 9b79254989..5338ca6931 100644 --- a/quantum/tests/unit/nicira/fake_nvpapiclient.py +++ b/quantum/tests/unit/nicira/fake_nvpapiclient.py @@ -232,3 +232,8 @@ class FakeClient: method = args[0] handler = getattr(self, "handle_%s" % method.lower()) return handler(*args[1:]) + + def reset_all(self): + self._fake_lswitch_dict.clear() + self._fake_lport_dict.clear() + self._fake_lportstatus_dict.clear() diff --git a/quantum/tests/unit/nicira/test_nicira_plugin.py b/quantum/tests/unit/nicira/test_nicira_plugin.py index dce5985662..c6e11881b2 100644 --- a/quantum/tests/unit/nicira/test_nicira_plugin.py +++ b/quantum/tests/unit/nicira/test_nicira_plugin.py @@ -33,19 +33,20 @@ class NiciraPluginV2TestCase(test_plugin.QuantumDbPluginV2TestCase): test_lib.test_config['config_files'] = [os.path.join(etc_path, 'nvp.ini.test')] # mock nvp api client - fc = fake_nvpapiclient.FakeClient(etc_path) + self.fc = fake_nvpapiclient.FakeClient(etc_path) self.mock_nvpapi = mock.patch('%s.NvpApiClient.NVPApiHelper' % NICIRA_PKG_PATH, autospec=True) instance = self.mock_nvpapi.start() instance.return_value.login.return_value = "the_cookie" def _fake_request(*args, **kwargs): - return fc.fake_request(*args, **kwargs) + return self.fc.fake_request(*args, **kwargs) instance.return_value.request.side_effect = _fake_request super(NiciraPluginV2TestCase, self).setUp(self._plugin_name) def tearDown(self): + self.fc.reset_all() super(NiciraPluginV2TestCase, self).tearDown() self.mock_nvpapi.stop() @@ -66,7 +67,3 @@ class TestNiciraPortsV2(test_plugin.TestPortsV2, NiciraPluginV2TestCase): class TestNiciraNetworksV2(test_plugin.TestNetworksV2, NiciraPluginV2TestCase): pass - - -class TestNiciraSubnetsV2(test_plugin.TestSubnetsV2, NiciraPluginV2TestCase): - pass diff --git a/quantum/tests/unit/openvswitch/test_openvswitch_plugin.py b/quantum/tests/unit/openvswitch/test_openvswitch_plugin.py index df65a209fc..6727d92210 100644 --- a/quantum/tests/unit/openvswitch/test_openvswitch_plugin.py +++ b/quantum/tests/unit/openvswitch/test_openvswitch_plugin.py @@ -43,8 +43,3 @@ class TestOpenvswitchPortsV2(test_plugin.TestPortsV2, class TestOpenvswitchNetworksV2(test_plugin.TestNetworksV2, OpenvswitchPluginV2TestCase): pass - - -class TestOpenvswitchSubnetsV2(test_plugin.TestSubnetsV2, - OpenvswitchPluginV2TestCase): - pass diff --git a/quantum/tests/unit/ryu/test_ryu_db.py b/quantum/tests/unit/ryu/test_ryu_db.py index c12849c042..f7b4e93478 100644 --- a/quantum/tests/unit/ryu/test_ryu_db.py +++ b/quantum/tests/unit/ryu/test_ryu_db.py @@ -15,6 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. +import os import unittest2 from quantum.db import api as db @@ -27,7 +28,7 @@ from quantum.plugins.ryu import ofp_service_type class RyuDBTest(unittest2.TestCase): def setUp(self): - options = {"sql_connection": cfg.CONF.DATABASE.sql_connection} + options = {"sql_connection": 'sqlite:///quantum.test.db'} options.update({'base': models_v2.model_base.BASEV2}) reconnect_interval = cfg.CONF.DATABASE.reconnect_interval options.update({"reconnect_interval": reconnect_interval}) diff --git a/quantum/tests/unit/ryu/test_ryu_plugin.py b/quantum/tests/unit/ryu/test_ryu_plugin.py index f5e2c233a2..fb508aa34a 100644 --- a/quantum/tests/unit/ryu/test_ryu_plugin.py +++ b/quantum/tests/unit/ryu/test_ryu_plugin.py @@ -56,7 +56,3 @@ class TestRyuPortsV2(test_plugin.TestPortsV2, RyuPluginV2TestCase): class TestRyuNetworksV2(test_plugin.TestNetworksV2, RyuPluginV2TestCase): pass - - -class TestRyuSubnetsV2(test_plugin.TestSubnetsV2, RyuPluginV2TestCase): - pass diff --git a/quantum/tests/unit/test_db_plugin.py b/quantum/tests/unit/test_db_plugin.py index 4fb3897ceb..e4655e2772 100644 --- a/quantum/tests/unit/test_db_plugin.py +++ b/quantum/tests/unit/test_db_plugin.py @@ -119,6 +119,9 @@ class QuantumDbPluginV2TestCase(unittest2.TestCase): cfg.CONF.reset() # Restore the original attribute map attributes.RESOURCE_ATTRIBUTE_MAP = self._attribute_map_bk + # Remove test database + if os.path.exists(db_base_plugin_v2.TEST_DB): + os.remove('quantum.test.db') def _req(self, method, resource, data=None, fmt='json', id=None, params=None, action=None):