Minor cleanup handoff mode warnings
* message is a little clearer * test is a little stronger Change-Id: I745cde7f4a46dafc80ab42d39e6ccc92aa3b746e
This commit is contained in:
parent
ab163702de
commit
8b1df9918b
@ -100,8 +100,9 @@ class ObjectReplicator(Daemon):
|
|||||||
self.handoff_delete = config_auto_int_value(
|
self.handoff_delete = config_auto_int_value(
|
||||||
conf.get('handoff_delete', 'auto'), 0)
|
conf.get('handoff_delete', 'auto'), 0)
|
||||||
if any((self.handoff_delete, self.handoffs_first)):
|
if any((self.handoff_delete, self.handoffs_first)):
|
||||||
self.logger.warn('handoffs_first and handoff_delete should be'
|
self.logger.warn('Handoff only mode is not intended for normal '
|
||||||
' changed back to the default before the next'
|
'operation, please disable handoffs_first and '
|
||||||
|
'handoff_delete before the next '
|
||||||
'normal rebalance')
|
'normal rebalance')
|
||||||
self._diskfile_mgr = DiskFileManager(conf, self.logger)
|
self._diskfile_mgr = DiskFileManager(conf, self.logger)
|
||||||
|
|
||||||
|
@ -510,6 +510,8 @@ class FakeLogger(logging.Logger, object):
|
|||||||
self.lines_dict = {'critical': [], 'error': [], 'info': [],
|
self.lines_dict = {'critical': [], 'error': [], 'info': [],
|
||||||
'warning': [], 'debug': [], 'notice': []}
|
'warning': [], 'debug': [], 'notice': []}
|
||||||
|
|
||||||
|
clear = _clear # this is a public interface
|
||||||
|
|
||||||
def get_lines_for_level(self, level):
|
def get_lines_for_level(self, level):
|
||||||
if level not in self.lines_dict:
|
if level not in self.lines_dict:
|
||||||
raise KeyError(
|
raise KeyError(
|
||||||
|
@ -185,21 +185,32 @@ class TestObjectReplicator(unittest.TestCase):
|
|||||||
rmtree(self.testdir, ignore_errors=1)
|
rmtree(self.testdir, ignore_errors=1)
|
||||||
|
|
||||||
def test_handoff_replication_setting_warnings(self):
|
def test_handoff_replication_setting_warnings(self):
|
||||||
conf = {'handoffs_first': 'true'}
|
conf_tests = [
|
||||||
replicator = object_replicator.ObjectReplicator(
|
# (config, expected_warning)
|
||||||
conf, logger=self.logger)
|
({}, False),
|
||||||
self.assertTrue(replicator.handoffs_first)
|
({'handoff_delete': 'auto'}, False),
|
||||||
log_message = 'handoffs_first and handoff_delete should'\
|
({'handoffs_first': 'no'}, False),
|
||||||
' be changed back to the default before the'\
|
({'handoff_delete': '2'}, True),
|
||||||
' next normal rebalance'
|
({'handoffs_first': 'yes'}, True),
|
||||||
expected = [log_message]
|
({'handoff_delete': '1', 'handoffs_first': 'yes'}, True),
|
||||||
self.assertEqual(self.logger.get_lines_for_level('warning'), expected)
|
]
|
||||||
conf = {'handoff_delete': '2'}
|
log_message = 'Handoff only mode is not intended for normal ' \
|
||||||
replicator = object_replicator.ObjectReplicator(
|
'operation, please disable handoffs_first and ' \
|
||||||
conf, logger=self.logger)
|
'handoff_delete before the next normal rebalance'
|
||||||
self.assertEqual(replicator.handoff_delete, 2)
|
for config, expected_warning in conf_tests:
|
||||||
expected.append(log_message)
|
self.logger.clear()
|
||||||
self.assertEqual(self.logger.get_lines_for_level('warning'), expected)
|
object_replicator.ObjectReplicator(config, logger=self.logger)
|
||||||
|
warning_log_lines = self.logger.get_lines_for_level('warning')
|
||||||
|
if expected_warning:
|
||||||
|
expected_log_lines = [log_message]
|
||||||
|
else:
|
||||||
|
expected_log_lines = []
|
||||||
|
self.assertEqual(expected_log_lines, warning_log_lines,
|
||||||
|
'expected %s != %s for config %r' % (
|
||||||
|
expected_log_lines,
|
||||||
|
warning_log_lines,
|
||||||
|
config,
|
||||||
|
))
|
||||||
|
|
||||||
def _write_disk_data(self, disk_name):
|
def _write_disk_data(self, disk_name):
|
||||||
os.mkdir(os.path.join(self.devices, disk_name))
|
os.mkdir(os.path.join(self.devices, disk_name))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user