vmware-nsx/quantum/tests/unit/nicira/test_nicira_plugin.py
Salvatore Orlando 652477b765 Use sqlite db on file for unit tests
bug 1054387

So far unit tests were executed using an in-memory database.
Memory was not being freed thus causing oom frequently due to
the increased number of unit tests.
Since sqlite in memory db do not work very well anyway with nose,
we are moving to file-based databases; slower, but safer.

Also, this patch removes a bunch of unit tests which do not add
anything to code coverage or number or test cases exercised.

Change-Id: Ib853727a5268643fbe8a99f6ebd0fc10aca6a43a
2012-09-23 05:51:50 -07:00

70 lines
2.3 KiB
Python

# Copyright (c) 2012 OpenStack, LLC.
#
# 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 mock
import quantum.common.test_lib as test_lib
from quantum.tests.unit.nicira import fake_nvpapiclient
import quantum.tests.unit.test_db_plugin as test_plugin
NICIRA_PKG_PATH = 'quantum.plugins.nicira.nicira_nvp_plugin'
class NiciraPluginV2TestCase(test_plugin.QuantumDbPluginV2TestCase):
_plugin_name = ('%s.QuantumPlugin.NvpPluginV2' % NICIRA_PKG_PATH)
def setUp(self):
etc_path = os.path.join(os.path.dirname(__file__), 'etc')
test_lib.test_config['config_files'] = [os.path.join(etc_path,
'nvp.ini.test')]
# mock nvp api client
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 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()
class TestNiciraBasicGet(test_plugin.TestBasicGet, NiciraPluginV2TestCase):
pass
class TestNiciraV2HTTPResponse(test_plugin.TestV2HTTPResponse,
NiciraPluginV2TestCase):
pass
class TestNiciraPortsV2(test_plugin.TestPortsV2, NiciraPluginV2TestCase):
pass
class TestNiciraNetworksV2(test_plugin.TestNetworksV2,
NiciraPluginV2TestCase):
pass