Merge "Close backend connections in tests"
This commit is contained in:
commit
b09a6414bd
@ -128,6 +128,11 @@ class DataDriverBase(DriverBase):
|
|||||||
"""Return the health status based on different backends."""
|
"""Return the health status based on different backends."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def close(self):
|
||||||
|
"""Close connections to the backend."""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def _get_operation_status(self):
|
def _get_operation_status(self):
|
||||||
op_status = {}
|
op_status = {}
|
||||||
status_template = lambda s, t, r: {'succeeded': s,
|
status_template = lambda s, t, r: {'succeeded': s,
|
||||||
@ -276,6 +281,11 @@ class ControlDriverBase(DriverBase):
|
|||||||
"""Returns the driver's queue controller."""
|
"""Returns the driver's queue controller."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def close(self):
|
||||||
|
"""Close connections to the backend."""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
class ControllerBase(object):
|
class ControllerBase(object):
|
||||||
"""Top-level class for controllers.
|
"""Top-level class for controllers.
|
||||||
|
@ -123,6 +123,9 @@ class DataDriver(storage.DataDriverBase):
|
|||||||
except pymongo.errors.PyMongoError:
|
except pymongo.errors.PyMongoError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.connection.close()
|
||||||
|
|
||||||
def _health(self):
|
def _health(self):
|
||||||
KPI = {}
|
KPI = {}
|
||||||
KPI['storage_reachable'] = self.is_alive()
|
KPI['storage_reachable'] = self.is_alive()
|
||||||
@ -212,6 +215,9 @@ class ControlDriver(storage.ControlDriverBase):
|
|||||||
|
|
||||||
self.mongodb_conf = self.conf[options.MANAGEMENT_MONGODB_GROUP]
|
self.mongodb_conf = self.conf[options.MANAGEMENT_MONGODB_GROUP]
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.connection.close()
|
||||||
|
|
||||||
@decorators.lazy_property(write=False)
|
@decorators.lazy_property(write=False)
|
||||||
def connection(self):
|
def connection(self):
|
||||||
"""MongoDB client connection instance."""
|
"""MongoDB client connection instance."""
|
||||||
|
@ -126,6 +126,9 @@ class DataDriver(base.DataDriverBase):
|
|||||||
def capabilities(self):
|
def capabilities(self):
|
||||||
return self._storage.capabilities()
|
return self._storage.capabilities()
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self._storage.close()
|
||||||
|
|
||||||
def is_alive(self):
|
def is_alive(self):
|
||||||
return self._storage.is_alive()
|
return self._storage.is_alive()
|
||||||
|
|
||||||
|
@ -86,6 +86,13 @@ class DataDriver(storage.DataDriverBase):
|
|||||||
# is neither used for pools creation nor flavor creation.
|
# is neither used for pools creation nor flavor creation.
|
||||||
return self.BASE_CAPABILITIES
|
return self.BASE_CAPABILITIES
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
cursor = self._pool_catalog._pools_ctrl.list(limit=0)
|
||||||
|
# Messages of each pool
|
||||||
|
for pool in next(cursor):
|
||||||
|
driver = self._pool_catalog.get_driver(pool['name'])
|
||||||
|
driver.close()
|
||||||
|
|
||||||
def is_alive(self):
|
def is_alive(self):
|
||||||
cursor = self._pool_catalog._pools_ctrl.list(limit=0)
|
cursor = self._pool_catalog._pools_ctrl.list(limit=0)
|
||||||
pools = next(cursor)
|
pools = next(cursor)
|
||||||
|
@ -174,6 +174,9 @@ class DataDriver(storage.DataDriverBase):
|
|||||||
except redis.exceptions.ConnectionError:
|
except redis.exceptions.ConnectionError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.connection.close()
|
||||||
|
|
||||||
def _health(self):
|
def _health(self):
|
||||||
KPI = {}
|
KPI = {}
|
||||||
KPI['storage_reachable'] = self.is_alive()
|
KPI['storage_reachable'] = self.is_alive()
|
||||||
@ -218,6 +221,9 @@ class ControlDriver(storage.ControlDriverBase):
|
|||||||
|
|
||||||
self.redis_conf = self.conf[options.MANAGEMENT_REDIS_GROUP]
|
self.redis_conf = self.conf[options.MANAGEMENT_REDIS_GROUP]
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.connection.close()
|
||||||
|
|
||||||
@decorators.lazy_property(write=False)
|
@decorators.lazy_property(write=False)
|
||||||
def connection(self):
|
def connection(self):
|
||||||
"""Redis client connection instance."""
|
"""Redis client connection instance."""
|
||||||
|
@ -75,7 +75,7 @@ class ControlDriver(storage.ControlDriverBase):
|
|||||||
def run(self, *args, **kwargs):
|
def run(self, *args, **kwargs):
|
||||||
return self.connection.execute(*args, **kwargs)
|
return self.connection.execute(*args, **kwargs)
|
||||||
|
|
||||||
def close_connection(self):
|
def close(self):
|
||||||
self.connection.close()
|
self.connection.close()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -28,6 +28,9 @@ class DataDriver(storage.DataDriverBase):
|
|||||||
def __init__(self, conf, cache, control_driver):
|
def __init__(self, conf, cache, control_driver):
|
||||||
super(DataDriver, self).__init__(conf, cache, control_driver)
|
super(DataDriver, self).__init__(conf, cache, control_driver)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def default_options(self):
|
def default_options(self):
|
||||||
return {}
|
return {}
|
||||||
@ -64,6 +67,9 @@ class ControlDriver(storage.ControlDriverBase):
|
|||||||
def __init__(self, conf, cache):
|
def __init__(self, conf, cache):
|
||||||
super(ControlDriver, self).__init__(conf, cache)
|
super(ControlDriver, self).__init__(conf, cache)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def queue_controller(self):
|
def queue_controller(self):
|
||||||
return QueueController(self)
|
return QueueController(self)
|
||||||
|
@ -92,8 +92,10 @@ class FunctionalTestBase(testing.TestBase):
|
|||||||
self.mconf.pooling = True
|
self.mconf.pooling = True
|
||||||
self.mconf.admin_mode = True
|
self.mconf.admin_mode = True
|
||||||
|
|
||||||
self.client = http.WSGIClient(
|
boot = bootstrap.Bootstrap(self.mconf)
|
||||||
bootstrap.Bootstrap(self.mconf).transport.app)
|
self.addCleanup(boot.storage.close)
|
||||||
|
self.addCleanup(boot.control.close)
|
||||||
|
self.client = http.WSGIClient(boot.transport.app)
|
||||||
|
|
||||||
self.headers = helpers.create_zaqar_headers(self.cfg)
|
self.headers = helpers.create_zaqar_headers(self.cfg)
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ class TestBase(testing.TestBase):
|
|||||||
self.conf.unreliable = True
|
self.conf.unreliable = True
|
||||||
self.conf.admin_mode = True
|
self.conf.admin_mode = True
|
||||||
self.boot = bootstrap.Bootstrap(self.conf)
|
self.boot = bootstrap.Bootstrap(self.conf)
|
||||||
|
self.addCleanup(self.boot.storage.close)
|
||||||
|
self.addCleanup(self.boot.control.close)
|
||||||
|
|
||||||
self.transport = self.boot.transport
|
self.transport = self.boot.transport
|
||||||
self.api = self.boot.api
|
self.api = self.boot.api
|
||||||
|
@ -46,6 +46,8 @@ class TestBase(testing.TestBase):
|
|||||||
self.conf.unreliable = True
|
self.conf.unreliable = True
|
||||||
self.conf.admin_mode = True
|
self.conf.admin_mode = True
|
||||||
self.boot = bootstrap.Bootstrap(self.conf)
|
self.boot = bootstrap.Bootstrap(self.conf)
|
||||||
|
self.addCleanup(self.boot.storage.close)
|
||||||
|
self.addCleanup(self.boot.control.close)
|
||||||
|
|
||||||
self.app = self.boot.transport.app
|
self.app = self.boot.transport.app
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user