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