Merge "Fix mongodb database create"

This commit is contained in:
Zuul 2018-01-14 03:30:17 +00:00 committed by Gerrit Code Review
commit b672ceab43
2 changed files with 10 additions and 4 deletions

View File

@ -699,8 +699,11 @@ class MongoDBAdmin(object):
schema.check_create()
LOG.debug('Creating MongoDB database %s', schema.name)
db = admin_client[schema.name]
db[tmp].insert({'dummy': True})
db.drop_collection(tmp)
# FIXME(songjian):can not create database with null content,
# so create a collection
# db[tmp].insert({'dummy': True})
# db.drop_collection(tmp)
db.create_collection(tmp)
def delete_database(self, database):
"""Deletes the database."""

View File

@ -332,8 +332,11 @@ class GuestAgentMongoDBManagerTest(DatastoreManagerTest):
self.manager.create_database(self.context, [schema])
db_client['dummy'].insert.assert_called_with({'dummy': True})
db_client.drop_collection.assert_called_with('dummy')
# FIXME(songjian):can not create database with null content,
# so create a collection
# db_client['dummy'].insert.assert_called_with({'dummy': True})
# db_client.drop_collection.assert_called_with('dummy')
db_client.create_collection.assert_called_with('dummy')
@mock.patch.object(service, 'MongoDBClient')
@mock.patch.object(service.MongoDBAdmin, '_admin_user')