test: add workaround for non-deterministic ovo object comparison

The ComparableVersionedObject impl of the __eq__ method incorrectly
checks the list of changed fields in an object. The ordering of
this list depends on the python hash seed, which causes the test
to randomly fail. Reset the list of changes as a workaround until
the ovo bug is fixed.

Change-Id: I438b4038308ad5f4af3c9055cda593f21ad7b654
This commit is contained in:
Daniel P. Berrange 2016-03-30 12:00:17 +01:00
parent 9686110d53
commit ae034f5802
1 changed files with 12 additions and 0 deletions

View File

@ -32,6 +32,18 @@ class TestVIFS(base.TestCase):
self.assertEqual("os_vif", prim["versioned_object.namespace"])
vif2 = objects.vif.VIFBase.obj_from_primitive(prim)
# 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
vif.obj_reset_changes(recursive=True)
vif2.obj_reset_changes(recursive=True)
self.assertEqual(vif, vif2)
def test_vif_generic(self):