From ae034f5802626f7b048dd02a9a44e06fe539cb09 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 30 Mar 2016 12:00:17 +0100 Subject: [PATCH] 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 --- os_vif/tests/test_vif.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/os_vif/tests/test_vif.py b/os_vif/tests/test_vif.py index 29e34d58..753dddf4 100644 --- a/os_vif/tests/test_vif.py +++ b/os_vif/tests/test_vif.py @@ -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):