From f7a3494676d7ca99bbc48b1ad9936f9c29465c8d Mon Sep 17 00:00:00 2001 From: Ryan Rossiter Date: Thu, 17 Dec 2015 17:09:57 +0000 Subject: [PATCH] Add test for checking object compatibilities oslo.versionedobjects has a fixture test that can check object compatibilities with previous versions of the object. It isn't a catch-all for making sure everything works between the versions, but it will at least check to make sure obj_to_primitive() won't totally blow up when trying to backport to a previous version. Change-Id: I2d3c26357f8ed9104bb9a936273f9cb8031715ca --- cinder/tests/unit/objects/test_objects.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cinder/tests/unit/objects/test_objects.py b/cinder/tests/unit/objects/test_objects.py index c6c74d0d9f4..1413b4e9f44 100644 --- a/cinder/tests/unit/objects/test_objects.py +++ b/cinder/tests/unit/objects/test_objects.py @@ -15,6 +15,7 @@ from oslo_versionedobjects import fixture from cinder import db +from cinder import objects from cinder.objects import base from cinder import test @@ -88,3 +89,15 @@ class TestObjectVersions(test.TestCase): if not issubclass(cls[0], base.ObjectListBase): db_model = db.get_model_for_versioned_object(cls[0]) _check_table_matched(db_model, cls[0]) + + def test_obj_make_compatible(self): + # Go through all of the object classes and run obj_to_primitive() with + # a target version of all previous minor versions. It doesn't test + # the converted data, but at least ensures the method doesn't blow + # up on something simple. + init_args = {} + init_kwargs = {objects.Snapshot: {'context': 'ctxt'}} + checker = fixture.ObjectVersionChecker( + base.CinderObjectRegistry.obj_classes()) + checker.test_compatibility_routines(init_args=init_args, + init_kwargs=init_kwargs)