Exemplo n.º 1
0
 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. ")
Exemplo n.º 2
0
 def test_versions(self):
     checker = fixture.ObjectVersionChecker(
         base.CinderObjectRegistry.obj_classes())
     expected, actual = checker.test_hashes(object_data)
     self.assertEqual(expected, actual,
                      "Some objects have changed; please make sure the "
                      "versions have been bumped and backporting "
                      "compatibility code has been added to "
                      "obj_make_compatible if necessary, and then update "
                      "their hashes in the object_data map in this test "
                      "module.  If we don't need to add backporting code "
                      "then it means we also don't need the version bump "
                      "and we just have to change the hash in this module.")
Exemplo n.º 3
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'},
                    objects.Backup: {'context': 'ctxt'},
                    objects.BackupImport: {'context': 'ctxt'}}
     checker = fixture.ObjectVersionChecker(
         base.CinderObjectRegistry.obj_classes())
     checker.test_compatibility_routines(init_args=init_args,
                                         init_kwargs=init_kwargs)
Exemplo n.º 4
0
    def test_versions(self):
        checker = fixture.ObjectVersionChecker(
            obj_base.VersionedObjectRegistry.obj_classes())
        fingerprints = checker.get_hashes()

        if os.getenv('GENERATE_HASHES'):
            with open('object_hashes.txt', 'w') as hashes_file:
                hashes_file.write(pprint.pformat(fingerprints))

        expected, actual = checker.test_hashes(object_data)
        self.assertEqual(expected, actual,
                         'Some objects have changed; please make sure the '
                         'versions have been bumped, and then update their '
                         'hashes in the object_data map in this test module.')
Exemplo n.º 5
0
    def test_versions(self):
        checker = fixture.ObjectVersionChecker(get_masakari_objects())
        fingerprints = checker.get_hashes()

        if os.getenv('GENERATE_HASHES'):
            open('object_hashes.txt', 'w').write(pprint.pformat(fingerprints))
            raise test.TestingException(
                'Generated hashes in object_hashes.txt')

        expected, actual = checker.test_hashes(object_data)
        self.assertEqual(
            expected, actual,
            'Some objects have changed; please make sure the '
            'versions have been bumped, and then update their '
            'hashes here.')
Exemplo n.º 6
0
    def test_versions(self):
        # Test the versions of current objects with the static tree above.
        # This ensures that any incompatible object changes require a version
        # bump.
        classes = base.MagnumObjectRegistry.obj_classes()
        checker = fixture.ObjectVersionChecker(obj_classes=classes)

        expected, actual = checker.test_hashes(object_data)
        self.assertEqual(expected, actual,
                         "Fields or remotable methods in some objects have "
                         "changed. Make sure the versions of the objects has "
                         "been bumped, and update the hashes in the static "
                         "fingerprints tree (object_data). For more "
                         "information, read http://docs.openstack.org/"
                         "developer/magnum/objects.html.")
Exemplo n.º 7
0
 def test_object_version_check(self):
     classes = base.MoganObjectRegistry.obj_classes()
     # We will test the notification objects specifically, here
     # we only test the versioned objects.
     for noti_cls in base.MoganObjectRegistry.notification_classes:
         classes.pop(noti_cls.__name__, None)
     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. ")
Exemplo n.º 8
0
    def test_versions(self):
        """Test Versions

        Ensures that modified objects had their versions bumped
        """

        checker = fixture.ObjectVersionChecker(get_kuryr_objects())
        expected, actual = checker.test_hashes(object_data)
        self.assertEqual(
            expected, actual,
            """Some objects have changed; please make sure the
                         versions have been bumped and backporting
                         compatibility code has been added to
                         obj_make_compatible if necessary, and then update
                         their hashes in the object_data map in this test
                         module. If we don't need to add backporting code then
                         it means we also don't need the version bump and we
                         just have to change the hash in this module.""")
Exemplo n.º 9
0
    def test_obj_make_compatible(self):
        base.MasakariObjectRegistry.register(segment.FailoverSegment)

        # 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
        # makes sure the method doesn't blow up on something basic like
        # expecting the wrong version format.

        # 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 = fake_args.init_args
        init_kwargs = fake_args.init_kwargs

        checker = fixture.ObjectVersionChecker(
            base.MasakariObjectRegistry.obj_classes())
        checker.test_compatibility_routines(use_manifest=True,
                                            init_args=init_args,
                                            init_kwargs=init_kwargs)
Exemplo n.º 10
0
    def test_versions(self):
        # Test the versions of current objects with the static tree above.
        # This ensures that any incompatible object changes require a version
        # bump.
        all_classes = base.ZunObjectRegistry.obj_classes()
        zun_classes = {}
        for name in all_classes:
            objclasses = all_classes[name]
            if (objclasses[0].OBJ_PROJECT_NAMESPACE ==
                    base.ZunObject.OBJ_PROJECT_NAMESPACE):
                zun_classes[name] = objclasses
        checker = fixture.ObjectVersionChecker(obj_classes=zun_classes)

        expected, actual = checker.test_hashes(object_data)
        self.assertEqual(expected, actual,
                         "Fields or remotable methods in some objects have "
                         "changed. Make sure the versions of the objects has "
                         "been bumped, and update the hashes in the static "
                         "fingerprints tree (object_data). For more "
                         "information, read https://docs.openstack.org/"
                         "zun/latest/contributor/objects.html.")
Exemplo n.º 11
0
    def test_notification_payload_version_depends_on_the_schema(self):
        @base.NovaObjectRegistry.register_if(False)
        class TestNotificationPayload(notification.NotificationPayloadBase):
            VERSION = '1.0'

            SCHEMA = {
                'field_1': ('source_field', 'field_1'),
                'field_2': ('source_field', 'field_2'),
            }

            fields = {
                'extra_field': fields.StringField(),  # filled by ctor
                'field_1': fields.StringField(),  # filled by the schema
                'field_2': fields.IntegerField(),  # filled by the schema
            }

        checker = fixture.ObjectVersionChecker(
            {'TestNotificationPayload': (TestNotificationPayload, )})

        old_hash = checker.get_hashes(extra_data_func=get_extra_data)
        TestNotificationPayload.SCHEMA['field_3'] = ('source_field', 'field_3')
        new_hash = checker.get_hashes(extra_data_func=get_extra_data)

        self.assertNotEqual(old_hash, new_hash)