Commit 92516cc4 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki

pithos: Destroy test database after test execution

:
Pithos uses a pool for the backend objects.
Pooled backend objects override the default close behavior
and return the object to the pool instead.
Therefore, django was unable to destroy the database
since there were active connections.
Therefore, we force the pool to shutdown before
the django attempts to destroy it.
parent 55388042
......@@ -144,6 +144,12 @@ class PithosTestSuiteRunner(DjangoTestSuiteRunner):
prepate_db_connection()
return old_names, mirrors
def teardown_databases(self, old_config, **kwargs):
from pithos.api.util import _pithos_backend_pool
_pithos_backend_pool.shutdown()
super(PithosTestSuiteRunner, self).teardown_databases(old_config,
**kwargs)
class PithosAPITest(TestCase):
def setUp(self):
......
......@@ -64,6 +64,7 @@ class DBWrapper(object):
def close(self):
self.conn.close()
self.conn = None
def execute(self):
self.trans = self.conn.begin()
......
......@@ -151,6 +151,14 @@ class PithosBackendPool(ObjectPool):
backend.messages = []
return False
def shutdown(self):
while True:
backend = self.pool_get(create=False)
if backend is None:
break
self.pool_put(None)
backend._real_close()
def _pooled_backend_close(backend):
backend._pool.pool_put(backend)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment