Add a test to enforce object version bump correctly

Add a test to help developers to check if the change of objects
need a version bump.

Any changes of object fields or remotable methods need to bump
its version. Use oslo_versionobjects to generate the hashes and
compare with a pre-define hash map.

Change-Id: I5c12ab72937f05ba46eb58d049f9b7fc7c806218
Closes-Bug: 1502895
Implements: blueprint online-upgrade-support
This commit is contained in:
Lin Tan 2015-11-25 15:49:05 +08:00
parent 8558c3094b
commit 74bd3b1865
1 changed files with 28 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import mock
from oslo_context import context
from oslo_versionedobjects import base as object_base
from oslo_versionedobjects import exception as object_exception
from oslo_versionedobjects import fixture as object_fixture
import six
from ironic.objects import base
@ -416,6 +417,33 @@ class TestObject(_LocalTest, _TestObject):
pass
# The hashes are help developers to check if the change of objects need a
# version bump. It is md5 hash of object fields and remotable methods.
# The fingerprint values should only be changed if there is a version bump.
expected_object_fingerprints = {
'Node': '1.14-9ee8ab283b06398545880dfdedb49891',
'MyObj': '1.5-4f5efe8f0fcaf182bbe1c7fe3ba858db',
'Chassis': '1.3-d656e039fd8ae9f34efc232ab3980905',
'Port': '1.4-f5aa3ff81d1459d6d7e6d9d9dceed351',
'Conductor': '1.0-5091f249719d4a465062a1b3dc7f860d'
}
class TestObjectVersions(test_base.TestCase):
def test_object_version_check(self):
classes = base.IronicObjectRegistry.obj_classes()
checker = object_fixture.ObjectVersionChecker(obj_classes=classes)
# Compute the difference between actual fingerprints and
# expect fingerprints. expect = actual = {} if there is no change.
expect, actual = checker.test_hashes(expected_object_fingerprints)
self.assertEqual(expect, actual,
"Some objects fields or remotable methods have been "
"modified. Please make sure the version of those "
"objects have been bumped and then update "
"expected_object_fingerprints with the new hashes. ")
class TestObjectSerializer(test_base.TestCase):
def test_object_serialization(self):