Cinder objects tests fail with PYTHONHASHSEED != 0

Bug #1434154 reported by Eric Harney
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Medium
Thang Pham

Bug Description

There are a number of failures in Cinder when we let Python randomize hash seeds, but I wanted to call this one out in particular since it's new code and could indicate a meaningful/tricky bug in objects. (I don't really know.)

See bug 1348818 for the general effort of allowing a random PYTHONHASHSEED.

To reproduce, set PYTHONHASHSEED=33 in tox.ini and run
$ tox -e py27 cinder.tests.objects

cinder.tests.objects.test_objects.TestObject.test_base_attributes
-----------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "cinder/tests/objects/test_objects.py", line 589, in test_base_attributes
        self.assertEqual(obj.obj_to_primitive(), expected)
      File "/home/eharney/src/cinder-trunk4/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 350, in assertEqual
        self.assertThat(observed, matcher, message)
      File "/home/eharney/src/cinder-trunk4/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 435, in assertThat
        raise mismatch_error
    testtools.matchers._impl.MismatchError: !=:
    reference = {'cinder_object.changes': ['created_at',
                               'deleted_at',
                               'updated_at',
                               'deleted'],
     'cinder_object.data': {'created_at': '1955-11-05T00:00:00Z',
                            'deleted': False,
                            'deleted_at': None,
                            'updated_at': '1955-11-05T00:00:00Z'},
     'cinder_object.name': 'MyObj',
     'cinder_object.namespace': 'cinder',
     'cinder_object.version': '1.6'}
    actual = {'cinder_object.changes': ['deleted',
                               'created_at',
                               'deleted_at',
                               'updated_at'],
     'cinder_object.data': {'created_at': '1955-11-05T00:00:00Z',
                            'deleted': False,
                            'deleted_at': None,
                            'updated_at': '1955-11-05T00:00:00Z'},
     'cinder_object.name': 'MyObj',
     'cinder_object.namespace': 'cinder',
     'cinder_object.version': '1.6'}

Ivan Kolodyazhny (e0ne)
Changed in cinder:
status: New → Confirmed
importance: Undecided → Medium
Thang Pham (thang-pham)
Changed in cinder:
assignee: nobody → Thang Pham (thang-pham)
Revision history for this message
Thang Pham (thang-pham) wrote :

I am not sure this is really a bug, but the source of it is https://github.com/openstack/cinder/blob/master/cinder/objects/base.py#L485

'cinder_object.changes' are unsorted list. If we sort it during obj_to_primitive(), then this should fix the problem. Once we move to oslo_versionedobjects, this test case and a large portion of the objects base code will be removed.

Mike Perez (thingee)
Changed in cinder:
milestone: none → kilo-rc1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/167632

Changed in cinder:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/167632
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=32d70f493a42bb0525113bcbe88c1ecf96a24cea
Submitter: Jenkins
Branch: master

commit 32d70f493a42bb0525113bcbe88c1ecf96a24cea
Author: Thang Pham <email address hidden>
Date: Wed Mar 25 10:54:23 2015 -0400

    Sort list of cinder_object.changes

    If PYTHONHASHSEED is set to a non-zero value,
    test_objects.TestObject.test_base_attributes unit test
    fails. This is because 'cinder_object.changes' key is
    an unsorted list when the object is converted to a
    primitive. The following patch fixes this by sorting
    cinder_object.changes.

    Change-Id: I3a80396c5c897de26e982fa6426e7720a09c1375
    Closes-Bug: #1434154

Changed in cinder:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in cinder:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: kilo-rc1 → 2015.1.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.