Merge "Remove db_enforce_mysql_charset option for db_sync of glance-manage"

This commit is contained in:
Jenkins 2014-09-26 22:41:44 +00:00 committed by Gerrit Code Review
commit d659161db4
3 changed files with 14 additions and 102 deletions

View File

@ -566,15 +566,6 @@ scrubber_datadir = /var/lib/glance/scrubber
# Base directory that the Image Cache uses
image_cache_dir = /var/lib/glance/image-cache/
# =============== Manager Options =================================
# DEPRECATED. TO BE REMOVED IN THE JUNO RELEASE.
# Whether or not to enforce that all DB tables have charset utf8.
# If your database tables do not have charset utf8 you will
# need to convert before this option is removed. This option is
# only relevant if your database engine is MySQL.
#db_enforce_mysql_charset = True
# =============== Database Options =================================
[database]

View File

@ -52,12 +52,10 @@ from glance.openstack.common import log
from glance.openstack.common import strutils
CONF = cfg.CONF
LOG = log.getLogger(__name__)
_LW = gettextutils._LW
CONF = cfg.CONF
CONF.import_opt('db_enforce_mysql_charset', 'glance.common.config')
# Decorators for actions
def args(*args, **kwargs):
@ -73,15 +71,6 @@ class DbCommands(object):
def __init__(self):
pass
def _need_sanity_check(self):
if not CONF.db_enforce_mysql_charset:
LOG.warning(_LW('Warning: '
'The db_enforce_mysql_charset option is now '
'deprecated and will be removed in the Juno '
'release. Please migrate DB manually e.g. '
'convert data of all tables to UTF-8 charset.'))
return CONF.db_enforce_mysql_charset
def version(self):
"""Print database's current migration level"""
print(migration.db_version(db_api.get_engine(),
@ -93,16 +82,14 @@ class DbCommands(object):
"""Upgrade the database's migration level"""
migration.db_sync(db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH,
version,
sanity_check=self._need_sanity_check())
version)
@args('--version', metavar='<version>', help='Database version')
def downgrade(self, version=None):
"""Downgrade the database's migration level"""
migration.db_sync(db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH,
version,
sanity_check=self._need_sanity_check())
version)
@args('--version', metavar='<version>', help='Database version')
def version_control(self, version=None):
@ -125,8 +112,7 @@ class DbCommands(object):
version=current_version)
migration.db_sync(db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH,
version,
sanity_check=self._need_sanity_check())
version)
@args('--path', metavar='<path>', help='Path to the directory where '
'json metadata files are stored')

View File

@ -32,7 +32,6 @@ class TestManageBase(testtools.TestCase):
def clear_conf():
manage.CONF.reset()
manage.CONF.unregister_opt(manage.command_opt)
manage.CONF.db_enforce_mysql_charset = True
self.addCleanup(clear_conf)
self.patcher = mock.patch('glance.db.sqlalchemy.api.get_engine')
@ -59,16 +58,14 @@ class TestLegacyManage(TestManageBase):
self._main_test_helper(['glance.cmd.manage', 'db_sync'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, None,
sanity_check=True)
db_migration.MIGRATE_REPO_PATH, None)
@mock.patch.object(migration, 'db_sync')
def test_legacy_db_upgrade(self, db_sync):
self._main_test_helper(['glance.cmd.manage', 'db_upgrade'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, None,
sanity_check=True)
db_migration.MIGRATE_REPO_PATH, None)
@mock.patch.object(migration, 'db_version_control')
def test_legacy_db_version_control(self, db_version_control):
@ -82,51 +79,21 @@ class TestLegacyManage(TestManageBase):
self._main_test_helper(['glance.cmd.manage', 'db_sync', '20'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '20',
sanity_check=True)
db_migration.MIGRATE_REPO_PATH, '20')
@mock.patch.object(migration, 'db_sync')
def test_legacy_db_upgrade_version(self, db_sync):
self._main_test_helper(['glance.cmd.manage', 'db_upgrade', '20'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '20',
sanity_check=True)
db_migration.MIGRATE_REPO_PATH, '20')
@mock.patch.object(migration, 'db_sync')
def test_legacy_db_downgrade_version(self, db_sync):
self._main_test_helper(['glance.cmd.manage', 'db_downgrade', '20'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '20',
sanity_check=True)
@mock.patch.object(migration, 'db_sync')
def test_legacy_db_sync_version_without_sanity_check(self, db_sync):
manage.CONF.db_enforce_mysql_charset = False
self._main_test_helper(['glance.cmd.manage', 'db_sync', '20'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '20',
sanity_check=False)
@mock.patch.object(migration, 'db_sync')
def test_legacy_db_upgrade_version_without_sanity_check(self, db_sync):
manage.CONF.db_enforce_mysql_charset = False
self._main_test_helper(['glance.cmd.manage', 'db_upgrade', '40'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '40',
sanity_check=False)
@mock.patch.object(migration, 'db_sync')
def test_legacy_db_downgrade_version_without_sanity_check(self, db_sync):
manage.CONF.db_enforce_mysql_charset = False
self._main_test_helper(['glance.cmd.manage', 'db_downgrade', '20'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '20',
sanity_check=False)
db_migration.MIGRATE_REPO_PATH, '20')
def test_db_metadefs_unload(self):
db_metadata.db_unload_metadefs = mock.Mock()
@ -179,16 +146,14 @@ class TestManage(TestManageBase):
self._main_test_helper(['glance.cmd.manage', 'db', 'sync'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, None,
sanity_check=True)
db_migration.MIGRATE_REPO_PATH, None)
@mock.patch.object(migration, 'db_sync')
def test_db_upgrade(self, db_sync):
self._main_test_helper(['glance.cmd.manage', 'db', 'upgrade'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, None,
sanity_check=True)
db_migration.MIGRATE_REPO_PATH, None)
@mock.patch.object(migration, 'db_version_control')
def test_db_version_control(self, db_version_control):
@ -202,51 +167,21 @@ class TestManage(TestManageBase):
self._main_test_helper(['glance.cmd.manage', 'db', 'sync', '20'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '20',
sanity_check=True)
db_migration.MIGRATE_REPO_PATH, '20')
@mock.patch.object(migration, 'db_sync')
def test_db_upgrade_version(self, db_sync):
self._main_test_helper(['glance.cmd.manage', 'db', 'upgrade', '20'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '20',
sanity_check=True)
db_migration.MIGRATE_REPO_PATH, '20')
@mock.patch.object(migration, 'db_sync')
def test_db_downgrade_version(self, db_sync):
self._main_test_helper(['glance.cmd.manage', 'db', 'downgrade', '20'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '20',
sanity_check=True)
@mock.patch.object(migration, 'db_sync')
def test_db_sync_version_without_sanity_check(self, db_sync):
manage.CONF.db_enforce_mysql_charset = False
self._main_test_helper(['glance.cmd.manage', 'db', 'sync', '20'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, u'20',
sanity_check=False)
@mock.patch.object(migration, 'db_sync')
def test_db_upgrade_version_without_sanity_check(self, db_sync):
manage.CONF.db_enforce_mysql_charset = False
self._main_test_helper(['glance.cmd.manage', 'db', 'upgrade', '40'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '40',
sanity_check=False)
@mock.patch.object(migration, 'db_sync')
def test_db_downgrade_version_without_sanity_check(self, db_sync):
manage.CONF.db_enforce_mysql_charset = False
self._main_test_helper(['glance.cmd.manage', 'db', 'downgrade', '20'],
migration.db_sync,
db_api.get_engine(),
db_migration.MIGRATE_REPO_PATH, '20',
sanity_check=False)
db_migration.MIGRATE_REPO_PATH, '20')
def test_db_metadefs_unload(self):
db_metadata.db_unload_metadefs = mock.Mock()