Merge "Added checking compat using manifest backports"
This commit is contained in:
commit
ad299becec
oslo_versionedobjects
@ -248,15 +248,17 @@ class ObjectVersionChecker(object):
|
||||
|
||||
return expected, actual
|
||||
|
||||
def _test_object_compatibility(self, obj_class):
|
||||
def _test_object_compatibility(self, obj_class, manifest=None):
|
||||
version = vutils.convert_version_to_tuple(obj_class.VERSION)
|
||||
kwargs = {'version_manifest': manifest} if manifest else {}
|
||||
for n in range(version[1] + 1):
|
||||
test_version = '%d.%d' % (version[0], n)
|
||||
LOG.info('testing obj: %s version: %s' %
|
||||
(obj_class.obj_name(), test_version))
|
||||
obj_class().obj_to_primitive(target_version=test_version)
|
||||
kwargs['target_version'] = test_version
|
||||
obj_class().obj_to_primitive(**kwargs)
|
||||
|
||||
def test_compatibility_routines(self):
|
||||
def test_compatibility_routines(self, use_manifest=False):
|
||||
# Iterate all object classes and verify that we can run
|
||||
# obj_make_compatible with every older version than current.
|
||||
# This doesn't actually test the data conversions, but it at least
|
||||
@ -264,8 +266,13 @@ class ObjectVersionChecker(object):
|
||||
# expecting the wrong version format.
|
||||
for obj_name in self.obj_classes:
|
||||
obj_classes = self.obj_classes[obj_name]
|
||||
if use_manifest:
|
||||
manifest = base.obj_tree_get_versions(obj_name)
|
||||
else:
|
||||
manifest = None
|
||||
|
||||
for obj_class in obj_classes:
|
||||
self._test_object_compatibility(obj_class)
|
||||
self._test_object_compatibility(obj_class, manifest=manifest)
|
||||
|
||||
def _test_relationships_in_order(self, obj_class):
|
||||
for field, versions in obj_class.obj_relationships.items():
|
||||
|
@ -257,7 +257,21 @@ class TestObjectVersionChecker(test.TestCase):
|
||||
with mock.patch.object(self.ovc, '_test_object_compatibility') as toc:
|
||||
self.ovc.test_compatibility_routines()
|
||||
|
||||
toc.assert_called_once_with(MyObject)
|
||||
toc.assert_called_once_with(MyObject, manifest=None)
|
||||
|
||||
def test_test_compatibility_routines_with_manifest(self):
|
||||
# Make sure test_compatibility_routines() uses the version manifest
|
||||
del self.ovc.obj_classes[MyObject2.__name__]
|
||||
man = {'who': 'cares'}
|
||||
|
||||
with mock.patch.object(self.ovc, '_test_object_compatibility') as toc:
|
||||
with mock.patch('oslo_versionedobjects.base'
|
||||
'.obj_tree_get_versions') as otgv:
|
||||
otgv.return_value = man
|
||||
self.ovc.test_compatibility_routines(use_manifest=True)
|
||||
|
||||
otgv.assert_called_once_with(MyObject.__name__)
|
||||
toc.assert_called_once_with(MyObject, manifest=man)
|
||||
|
||||
def test_test_relationships_in_order(self):
|
||||
# Make sure test_relationships_in_order() tests the relationships
|
||||
|
@ -639,10 +639,10 @@ class TestFixture(_BaseTestCase):
|
||||
def test(mock_compat):
|
||||
checker.test_compatibility_routines()
|
||||
mock_compat.assert_has_calls(
|
||||
[mock.call(mock.sentinel.impl_one_one),
|
||||
mock.call(mock.sentinel.impl_one_two),
|
||||
mock.call(mock.sentinel.impl_two_one),
|
||||
mock.call(mock.sentinel.impl_two_two)],
|
||||
[mock.call(mock.sentinel.impl_one_one, manifest=None),
|
||||
mock.call(mock.sentinel.impl_one_two, manifest=None),
|
||||
mock.call(mock.sentinel.impl_two_one, manifest=None),
|
||||
mock.call(mock.sentinel.impl_two_two, manifest=None)],
|
||||
any_order=True)
|
||||
test()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user