Apply workaround to host_info serialization test

Random failures started appearing in the gate with the following
pattern:

    testtools.matchers._impl.MismatchError: !=:
    reference = HostInfo(plugin_info=[HostPluginInfo,HostPluginInfo])
    actual    = HostInfo(plugin_info=[HostPluginInfo,HostPluginInfo])

This change attempts to work around the issue by adopting the same
workaround as implemented in the VIF tests.

Note that the host_info class is currently largely stub code for an
unimplemented negotiation interface.

Change-Id: I1fff71ec6793e009cbee9da0656b77915591dec4
Signed-off-by: Jan Gutter <jan.gutter@netronome.com>
This commit is contained in:
Jan Gutter 2019-01-16 11:36:57 +02:00
parent 91382aa943
commit e562dd19eb

View File

@ -56,11 +56,26 @@ class TestHostInfo(base.TestCase):
),
])
])
# https://bugs.launchpad.net/oslo.versionedobjects/+bug/1563787
self.host_info.obj_reset_changes(recursive=True)
def test_serialization(self):
json = self.host_info.obj_to_primitive()
self.assertEqual("os_vif", json["versioned_object.namespace"])
host_info = objects.host_info.HostInfo.obj_from_primitive(json)
# Copied from test_vif.py:
#
# The __eq__ function works by using obj_to_primitive()
# and this includes a list of changed fields. Very
# occassionally the ordering of the list of changes
# varies, causing bogus equality failures. This is
# arguably a bug in oslo.versionedobjects since the
# set of changes fields should not affect equality
# comparisons. Remove this hack once this is fixed:
#
# https://bugs.launchpad.net/oslo.versionedobjects/+bug/1563787
host_info.obj_reset_changes(recursive=True)
self.assertEqual(self.host_info, host_info)