Improve unit test times
Revert the change using a temporary file for the database. The sqlalchemy version is updated to >=0.7.8 (this includes fixes for memory leaks). Change-Id: Ib5d128edfef0f8e0afebaf408f7834fa3de2481a
This commit is contained in:
parent
8eb7ca51c0
commit
9aac057efd
@ -33,7 +33,6 @@ from quantum import quantum_plugin_base_v2
|
|||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
TEST_DB = "quantum.test.db"
|
|
||||||
|
|
||||||
AGENT_OWNER_PREFIX = 'network:'
|
AGENT_OWNER_PREFIX = 'network:'
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
# must override __init__ and setup the database
|
# must override __init__ and setup the database
|
||||||
# and not call into this class's __init__.
|
# and not call into this class's __init__.
|
||||||
# This connection is setup as memory for the tests.
|
# This connection is setup as memory for the tests.
|
||||||
db.configure_db({'sql_connection': "sqlite:///%s" % TEST_DB,
|
db.configure_db({'sql_connection': "sqlite:///:memory:",
|
||||||
'base': models_v2.model_base.BASEV2})
|
'base': models_v2.model_base.BASEV2})
|
||||||
|
|
||||||
def _get_tenant_id_for_create(self, context, resource):
|
def _get_tenant_id_for_create(self, context, resource):
|
||||||
|
@ -21,4 +21,4 @@ api_paste_config = api-paste.ini.test
|
|||||||
rpc_backend = quantum.openstack.common.rpc.impl_fake
|
rpc_backend = quantum.openstack.common.rpc.impl_fake
|
||||||
|
|
||||||
[DATABASE]
|
[DATABASE]
|
||||||
sql_connection = 'sqlite:///quantum.test.db'
|
sql_connection = 'sqlite:///:memory:'
|
||||||
|
@ -42,7 +42,7 @@ class CiscoNetworkPluginV2TestCase(test_db_plugin.QuantumDbPluginV2TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
def new_init():
|
def new_init():
|
||||||
db.configure_db({'sql_connection': 'sqlite:///quantum.test.db',
|
db.configure_db({'sql_connection': 'sqlite:///:memory:',
|
||||||
'base': network_models_v2.model_base.BASEV2})
|
'base': network_models_v2.model_base.BASEV2})
|
||||||
|
|
||||||
with mock.patch.object(network_db_v2,
|
with mock.patch.object(network_db_v2,
|
||||||
|
@ -28,7 +28,7 @@ from quantum.plugins.ryu import ofp_service_type
|
|||||||
|
|
||||||
class RyuDBTest(unittest2.TestCase):
|
class RyuDBTest(unittest2.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
options = {"sql_connection": 'sqlite:///quantum.test.db'}
|
options = {"sql_connection": 'sqlite:///:memory:'}
|
||||||
options.update({'base': models_v2.model_base.BASEV2})
|
options.update({'base': models_v2.model_base.BASEV2})
|
||||||
reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
|
reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
|
||||||
options.update({"reconnect_interval": reconnect_interval})
|
options.update({"reconnect_interval": reconnect_interval})
|
||||||
|
@ -119,9 +119,6 @@ class QuantumDbPluginV2TestCase(unittest2.TestCase):
|
|||||||
cfg.CONF.reset()
|
cfg.CONF.reset()
|
||||||
# Restore the original attribute map
|
# Restore the original attribute map
|
||||||
attributes.RESOURCE_ATTRIBUTE_MAP = self._attribute_map_bk
|
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',
|
def _req(self, method, resource, data=None, fmt='json',
|
||||||
id=None, params=None, action=None):
|
id=None, params=None, action=None):
|
||||||
|
@ -12,5 +12,5 @@ lxml
|
|||||||
netaddr
|
netaddr
|
||||||
python-quantumclient>=2.0
|
python-quantumclient>=2.0
|
||||||
pyudev
|
pyudev
|
||||||
sqlalchemy>0.6.4
|
sqlalchemy>=0.7.8
|
||||||
webob==1.0.8
|
webob==1.0.8
|
||||||
|
Loading…
x
Reference in New Issue
Block a user