GetHostCpusListActionTest fails regularly but isn't deterministic

Bug #1714158 reported by Tony Breeds
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
Fix Released
High
Tony Breeds

Bug Description

tripleo_common.tests.actions.test_derive_params.GetHostCpusListActionTest.test_run_valid_inspect_data will sometimes fail but re-running tox will pass.

An example failure is below:
======================================================================
FAIL: tripleo_common.tests.actions.test_derive_params.GetHostCpusListActionTest.test_run_valid_inspect_data
tags: worker-0
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tripleo_common/tests/actions/test_derive_params.py", line 364, in test_run_valid_inspect_data
    self.assertEqual(result, expected_result)
  File "/home/tony/projects/openstack/openstack/tripleo-common/.tox/pypy/site-packages/testtools/testcase.py", line 411, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/home/tony/projects/openstack/openstack/tripleo-common/.tox/pypy/site-packages/testtools/testcase.py", line 498, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: '25,69,15,59' != '15,59,25,69'
Ran 318 tests in 1.309s (+0.639s)
FAILED (id=11, failures=1)
error: testr failed (1)

This is because we're inserting items into a list based on the order of keys in a dictionary [1] Key order isn't deterministic in that way. The closest I can find to an offical statement on that is "CPython implementation detail: Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary’s history of insertions and deletions."[2]

[1] https://github.com/openstack/tripleo-common/blob/master/tripleo_common/actions/derive_params.py#L256
[2] https://docs.python.org/2/library/stdtypes.html#dict.items

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-common (master)

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

Changed in tripleo:
assignee: nobody → Tony Breeds (o-tony)
status: New → In Progress
Changed in tripleo:
milestone: none → pike-rc2
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-common (master)

Reviewed: https://review.openstack.org/499456
Committed: https://git.openstack.org/cgit/openstack/tripleo-common/commit/?id=f2bad7d90da0f0a5612d2e1bc2b9fa46c2d5e859
Submitter: Jenkins
Branch: master

commit f2bad7d90da0f0a5612d2e1bc2b9fa46c2d5e859
Author: Tony Breeds <email address hidden>
Date: Thu Aug 31 14:39:37 2017 +1000

    Ensure that GetHostCpusListAction.run() returns a deterministic result

    As the return value of keys() isn't guaranteed to be the same between
    different runs sort them so the items we add are in a predictable order

    Change-Id: Ie3106b5a167f59754241e7aaf8ad1944405d5023
    Closes-Bug: 1714158

Changed in tripleo:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-common 8.0.0

This issue was fixed in the openstack/tripleo-common 8.0.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-common (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/615906

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-common (stable/pike)

Reviewed: https://review.openstack.org/615906
Committed: https://git.openstack.org/cgit/openstack/tripleo-common/commit/?id=a652a35c2092b7e2bcabb5ec84bebae9a0bf7a26
Submitter: Zuul
Branch: stable/pike

commit a652a35c2092b7e2bcabb5ec84bebae9a0bf7a26
Author: Tony Breeds <email address hidden>
Date: Thu Aug 31 14:39:37 2017 +1000

    Ensure that GetHostCpusListAction.run() returns a deterministic result

    As the return value of keys() isn't guaranteed to be the same between
    different runs sort them so the items we add are in a predictable order

    Change-Id: Ie3106b5a167f59754241e7aaf8ad1944405d5023
    Closes-Bug: 1714158
    (cherry picked from commit f2bad7d90da0f0a5612d2e1bc2b9fa46c2d5e859)

tags: added: in-stable-pike
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-common 7.6.18

This issue was fixed in the openstack/tripleo-common 7.6.18 release.

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.