summaryrefslogtreecommitdiffstats
path: root/openstack/common
diff options
context:
space:
mode:
authorGary Kotton <gkotton@redhat.com>2013-04-22 08:12:38 +0000
committerGary Kotton <gkotton@redhat.com>2013-04-25 16:00:47 +0000
commite79811464cdab63b12e140d4d7a9ec650ddcc3e0 (patch)
treeea86c836b86ea99514cf7534da7c847f1ad9d7c4 /openstack/common
parentae0c3daee1074adaf2f28d4670d03639234ea090 (diff)
downloadoslo-e79811464cdab63b12e140d4d7a9ec650ddcc3e0.tar.gz
oslo-e79811464cdab63b12e140d4d7a9ec650ddcc3e0.tar.xz
oslo-e79811464cdab63b12e140d4d7a9ec650ddcc3e0.zip
Add support to clear DB
Fixes bug 1171740 The method cleanup() can be called when a test is complete, for example in the tearDown method. Change-Id: Id30bcb0d7ef167f6cb3b1bdea06f6421e1234a86
Diffstat (limited to 'openstack/common')
-rw-r--r--openstack/common/db/sqlalchemy/session.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/openstack/common/db/sqlalchemy/session.py b/openstack/common/db/sqlalchemy/session.py
index 99439f4..a19fc01 100644
--- a/openstack/common/db/sqlalchemy/session.py
+++ b/openstack/common/db/sqlalchemy/session.py
@@ -318,6 +318,17 @@ def set_defaults(sql_connection, sqlite_db):
sqlite_db=sqlite_db)
+def cleanup():
+ global _ENGINE, _MAKER
+
+ if _MAKER:
+ _MAKER.close_all()
+ _MAKER = None
+ if _ENGINE:
+ _ENGINE.dispose()
+ _ENGINE = None
+
+
class SqliteForeignKeysListener(PoolListener):
"""
Ensures that the foreign key constraints are enforced in SQLite.