storage: fix clear/upgrade order
With the current order, when using MongoDB, the indexes are created on connection, but clear() drop the database with the indexes just after, meaning we have no indexes! Let's fix that by upgrading (so we're sure we have tables or the like), then clearing data, then upgrading again so we're sure we have our tables or indexes. Change-Id: Ib3550f26ac0507c781a5e82573a789b2513ae04c
This commit is contained in:
parent
3f044dd1ac
commit
3c2475e9dd
@ -286,6 +286,12 @@ class Connection(base.Connection):
|
||||
if 'username' in opts:
|
||||
self.db.authenticate(opts['username'], opts['password'])
|
||||
|
||||
# NOTE(jd) Upgrading is just about creating index, so let's do this
|
||||
# on connection to be sure at least the TTL is correcly updated if
|
||||
# needed.
|
||||
self.upgrade()
|
||||
|
||||
def upgrade(self, version=None):
|
||||
# Establish indexes
|
||||
#
|
||||
# We need variations for user_id vs. project_id because of the
|
||||
@ -341,10 +347,6 @@ class Connection(base.Connection):
|
||||
# Assume is not supported if we can get the version
|
||||
return self.conn.server_info().get('versionArray', []) >= [2, 2]
|
||||
|
||||
@staticmethod
|
||||
def upgrade(version=None):
|
||||
pass
|
||||
|
||||
def clear(self):
|
||||
self.conn.drop_database(self.db)
|
||||
|
||||
|
@ -34,3 +34,4 @@ class TestBase(test_base.TestCase):
|
||||
self.conn = storage.get_connection(cfg.CONF)
|
||||
self.conn.upgrade()
|
||||
self.conn.clear()
|
||||
self.conn.upgrade()
|
||||
|
Loading…
x
Reference in New Issue
Block a user