Merge "Add upgrade checker for backup driver path"

This commit is contained in:
Zuul 2019-04-04 07:14:21 +00:00 committed by Gerrit Code Review
commit 06ab31adce
5 changed files with 78 additions and 5 deletions

View File

@ -20,6 +20,9 @@ import sys
from oslo_config import cfg
from oslo_upgradecheck import upgradecheck as uc
import cinder.service # noqa
CONF = cfg.CONF
SUCCESS = uc.Code.SUCCESS
@ -30,12 +33,30 @@ WARNING = uc.Code.WARNING
class Checks(uc.UpgradeCommands):
"""Upgrade checks to run."""
def _check_placeholder(self):
"""This is just a placeholder to test the test framework."""
return uc.Result(SUCCESS, 'Some details')
def _check_backup_module(self):
"""Checks for the use of backup driver module paths.
The use of backup modules for setting backup_driver was deprecated and
we now only allow the full driver path. This checks that there are not
any remaining settings using the old method.
"""
# We import here to avoid conf loading order issues with cinder.service
# above.
import cinder.backup.manager # noqa
backup_driver = CONF.backup_driver
# Easy check in that a class name will have mixed casing
if backup_driver == backup_driver.lower():
return uc.Result(
FAILURE,
'Backup driver configuration requires the full path to the '
'driver, but current setting is using only the module path.')
return uc.Result(SUCCESS)
_upgrade_checks = (
('Placeholder', _check_placeholder),
('Backup Driver Path', _check_backup_module),
)

View File

View File

@ -0,0 +1,45 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Unit tests for the cinder-status CLI interfaces."""
from oslo_config import cfg
from oslo_upgradecheck import upgradecheck as uc
import testtools
from cinder.cmd import status
CONF = cfg.CONF
class TestCinderStatus(testtools.TestCase):
"""Test cases for the cinder-status upgrade check command."""
def setUp(self):
super(TestCinderStatus, self).setUp()
self.checks = status.Checks()
def _set_backup_driver(self, driver_path):
CONF.set_override('backup_driver', driver_path)
self.addCleanup(CONF.clear_override, 'backup_driver')
def test_check_backup_module(self):
self._set_backup_driver(
'cinder.backup.drivers.swift.SwiftBackupDriver')
result = self.checks._check_backup_module()
self.assertEqual(uc.Code.SUCCESS, result.code)
def test_check_backup_module_not_class(self):
self._set_backup_driver('cinder.backup.drivers.swift')
result = self.checks._check_backup_module()
self.assertEqual(uc.Code.FAILURE, result.code)
self.assertIn('requires the full path', result.details)

View File

@ -85,7 +85,8 @@ Upgrade
**14.0.0 (Stein)**
* Placeholder to be filled in with checks as they are added in Stein.
* Check added to ensure the backup_driver setting is using the full driver
class path and not just the module path.
See Also
========

View File

@ -0,0 +1,6 @@
---
upgrade:
- |
A new check is added to the ``cinder-status upgrade check`` CLI to check
for the use of backup driver module path instead of full driver class path
in the ``backup_driver`` configuration setting.