Use ovo in test_obj_make_compatible()

o.vo has a fixture for testing compatibility routines. This changes the
nova unit tests to use that compatibility testing on all objects. In the
original nova test, the versions tested were from 1.0 to 1.(x-1), where
1.x is the current version. o.vo's fixture tests from 1.0 to 1.x, which
should be a no-op, but is also a good thing to test (if we can't convert
1.x to 1.x, that's a bad thing).

o.vo also had an enhancement where it passed args and kwargs to __init__
in the different objects, which was a bug in nova, but using that
fixture allows us to also close the nova bug. This change in o.vo was
I62646b99adca47a9c9fe0f466f7a23ac8fa4553e.

Change-Id: Ie127f55f2e5bcd383796ff51253cf1091be16c98
Closes-Bug: #1537882
This commit is contained in:
Ryan Rossiter 2016-01-25 22:01:27 +00:00
parent 2d551ce83d
commit e36bc6ee35
1 changed files with 12 additions and 12 deletions

View File

@ -23,7 +23,6 @@ import fixtures
import mock
from oslo_log import log
from oslo_utils import timeutils
from oslo_utils import versionutils
from oslo_versionedobjects import base as ovo_base
from oslo_versionedobjects import exception as ovo_exc
from oslo_versionedobjects import fixture
@ -1235,17 +1234,18 @@ class TestObjectVersions(test.NoDBTestCase):
# This doesn't actually test the data conversions, but it at least
# makes sure the method doesn't blow up on something basic like
# expecting the wrong version format.
obj_classes = base.NovaObjectRegistry.obj_classes()
for obj_name in obj_classes:
versions = ovo_base.obj_tree_get_versions(obj_name)
obj_class = obj_classes[obj_name][0]
version = versionutils.convert_version_to_tuple(obj_class.VERSION)
for n in range(version[1]):
test_version = '%d.%d' % (version[0], n)
LOG.info('testing obj: %s version: %s' %
(obj_name, test_version))
obj_class().obj_to_primitive(target_version=test_version,
version_manifest=versions)
# Hold a dictionary of args/kwargs that need to get passed into
# __init__() for specific classes. The key in the dictionary is
# the obj_class that needs the init args/kwargs.
init_args = {}
init_kwargs = {}
checker = fixture.ObjectVersionChecker(
base.NovaObjectRegistry.obj_classes())
checker.test_compatibility_routines(use_manifest=True,
init_args=init_args,
init_kwargs=init_kwargs)
def test_list_obj_make_compatible(self):
@base.NovaObjectRegistry.register_if(False)