Follow up on reconstructor handoffs_only

This is a follow-up for https://review.openstack.org/#/c/425493
This patch includes:

- Add more tests on the configuration with handoffs_first and
  handoffs_only
- Remove unnecessary space in a warning log line. (2 places)
- Change test conf from True/False to "True"/"False" (string) because in
  the conf dict, those value should be string.

Co-Authored-By: Janie Richling <jrichli@us.ibm.com>

Change-Id: Ida90c32d16481a15fa68c9fdb380932526c366f6
This commit is contained in:
Kota Tsuyuzaki 2017-02-14 17:54:48 -08:00
parent da557011ec
commit 600db4841e
2 changed files with 75 additions and 10 deletions

View File

@ -1184,15 +1184,15 @@ class TestObjectReconstructor(unittest.TestCase):
def test_handoffs_only_default(self): def test_handoffs_only_default(self):
# sanity neither option added to default conf # sanity neither option added to default conf
self.conf.pop('handoffs_only', None)
self.conf.pop('handoffs_first', None) self.conf.pop('handoffs_first', None)
self.conf.pop('handoffs_only', None)
self.reconstructor = object_reconstructor.ObjectReconstructor( self.reconstructor = object_reconstructor.ObjectReconstructor(
self.conf, logger=self.logger) self.conf, logger=self.logger)
self.assertFalse(self.reconstructor.handoffs_only) self.assertFalse(self.reconstructor.handoffs_only)
def test_handoffs_first_enables_handoffs_only(self): def test_handoffs_first_enables_handoffs_only(self):
self.conf['handoffs_first'] = "True"
self.conf.pop('handoffs_only', None) # sanity self.conf.pop('handoffs_only', None) # sanity
self.conf['handoffs_first'] = True
self.reconstructor = object_reconstructor.ObjectReconstructor( self.reconstructor = object_reconstructor.ObjectReconstructor(
self.conf, logger=self.logger) self.conf, logger=self.logger)
self.assertTrue(self.reconstructor.handoffs_only) self.assertTrue(self.reconstructor.handoffs_only)
@ -1207,8 +1207,8 @@ class TestObjectReconstructor(unittest.TestCase):
self.assertEqual(expected, warnings) self.assertEqual(expected, warnings)
def test_handoffs_only_ignores_handoffs_first(self): def test_handoffs_only_ignores_handoffs_first(self):
self.conf['handoffs_first'] = True self.conf['handoffs_first'] = "True"
self.conf['handoffs_only'] = False self.conf['handoffs_only'] = "False"
self.reconstructor = object_reconstructor.ObjectReconstructor( self.reconstructor = object_reconstructor.ObjectReconstructor(
self.conf, logger=self.logger) self.conf, logger=self.logger)
self.assertFalse(self.reconstructor.handoffs_only) self.assertFalse(self.reconstructor.handoffs_only)
@ -1222,7 +1222,7 @@ class TestObjectReconstructor(unittest.TestCase):
def test_handoffs_only_enabled(self): def test_handoffs_only_enabled(self):
self.conf.pop('handoffs_first', None) # sanity self.conf.pop('handoffs_first', None) # sanity
self.conf['handoffs_only'] = True self.conf['handoffs_only'] = "True"
self.reconstructor = object_reconstructor.ObjectReconstructor( self.reconstructor = object_reconstructor.ObjectReconstructor(
self.conf, logger=self.logger) self.conf, logger=self.logger)
self.assertTrue(self.reconstructor.handoffs_only) self.assertTrue(self.reconstructor.handoffs_only)
@ -1233,6 +1233,71 @@ class TestObjectReconstructor(unittest.TestCase):
] ]
self.assertEqual(expected, warnings) self.assertEqual(expected, warnings)
def test_handoffs_only_true_and_first_true(self):
self.conf['handoffs_first'] = "True"
self.conf['handoffs_only'] = "True"
self.reconstructor = object_reconstructor.ObjectReconstructor(
self.conf, logger=self.logger)
self.assertTrue(self.reconstructor.handoffs_only)
warnings = self.logger.get_lines_for_level('warning')
expected = [
'The handoffs_first option is deprecated in favor of '
'handoffs_only. This option may be ignored in a future release.',
'Handoff only mode is not intended for normal operation, '
'use handoffs_only with care.',
]
self.assertEqual(expected, warnings)
def test_handoffs_only_false_and_first_false(self):
self.conf['handoffs_only'] = "False"
self.conf['handoffs_first'] = "False"
self.reconstructor = object_reconstructor.ObjectReconstructor(
self.conf, logger=self.logger)
self.assertFalse(self.reconstructor.handoffs_only)
warnings = self.logger.get_lines_for_level('warning')
expected = [
'The handoffs_first option is deprecated in favor of '
'handoffs_only. This option may be ignored in a future release.',
]
self.assertEqual(expected, warnings)
def test_handoffs_only_none_and_first_false(self):
self.conf['handoffs_first'] = "False"
self.conf.pop('handoffs_only', None) # sanity
self.reconstructor = object_reconstructor.ObjectReconstructor(
self.conf, logger=self.logger)
self.assertFalse(self.reconstructor.handoffs_only)
warnings = self.logger.get_lines_for_level('warning')
expected = [
'The handoffs_first option is deprecated in favor of '
'handoffs_only. This option may be ignored in a future release.',
]
self.assertEqual(expected, warnings)
def test_handoffs_only_false_and_first_none(self):
self.conf.pop('handoffs_first', None) # sanity
self.conf['handoffs_only'] = "False"
self.reconstructor = object_reconstructor.ObjectReconstructor(
self.conf, logger=self.logger)
self.assertFalse(self.reconstructor.handoffs_only)
warnings = self.logger.get_lines_for_level('warning')
self.assertEqual(len(warnings), 0)
def test_handoffs_only_true_and_first_false(self):
self.conf['handoffs_first'] = "False"
self.conf['handoffs_only'] = "True"
self.reconstructor = object_reconstructor.ObjectReconstructor(
self.conf, logger=self.logger)
self.assertTrue(self.reconstructor.handoffs_only)
warnings = self.logger.get_lines_for_level('warning')
expected = [
'The handoffs_first option is deprecated in favor of '
'handoffs_only. This option may be ignored in a future release.',
'Handoff only mode is not intended for normal operation, '
'use handoffs_only with care.',
]
self.assertEqual(expected, warnings)
def test_two_ec_policies(self): def test_two_ec_policies(self):
with patch_policies([ with patch_policies([
StoragePolicy(0, name='zero', is_deprecated=True), StoragePolicy(0, name='zero', is_deprecated=True),