Share one engine for more than just sqlite in-memory

This fixes both bug 1162857 and bug 1162845.

Change-Id: Ica5155d3ac03779693d2d54d8e02c2a413c3d3ac
This commit is contained in:
Dolph Mathews 2013-04-01 14:41:26 -05:00
parent af31ecd6b7
commit 93b8f2ddf7
2 changed files with 5 additions and 2 deletions

View File

@ -30,7 +30,6 @@ from keystone.common import logging
from keystone import config
from keystone import exception
from keystone.openstack.common import jsonutils
from keystone import exception
CONF = config.CONF
@ -98,7 +97,6 @@ def set_global_engine(engine):
def get_global_engine():
global GLOBAL_ENGINE
return GLOBAL_ENGINE
@ -250,6 +248,8 @@ class Base(object):
# auto-build the db to support wsgi server w/ in-memory backend
if allow_global_engine and CONF.sql.connection == 'sqlite://':
ModelBase.metadata.create_all(bind=engine)
if allow_global_engine:
set_global_engine(engine)
return engine

View File

@ -17,6 +17,7 @@
import os
import shutil
from keystone.common.sql import core
from keystone.common.sql import migration
from keystone import config
@ -38,5 +39,7 @@ def setup_test_database():
def teardown_test_database():
core.set_global_engine(None)
if os.path.exists('test.db.pristine'):
os.unlink('test.db.pristine')