]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Predictable field and filter ordering
authorSam Betts <sam@code-smash.net>
Tue, 5 Aug 2014 23:05:05 +0000 (00:05 +0100)
committerSam Betts <sam@code-smash.net>
Mon, 11 Aug 2014 16:33:24 +0000 (17:33 +0100)
commitf103ce48ca60e12952be7aa6d5183f64ef826370
tree0d5052dbd02bace25ed2647df9b6c9a6e9470928
parentec3f1761791c998a89a85d8c8b45cbfba9d54a47
Predictable field and filter ordering

This fixes the fields and filters units tests that break with a
randomized PYTHONHASHSEED (see the bug report).

The RESOURCE_ATTRIBUTE_MAP is stored as a dict leading to an
unpredictable output order. Values in kvp strings are being stored as
sets underpinned by dicts when converted, leading to unpredictable
ordering of values when read.

Discovered with PYTHONHASHSEED = 2455351445 on these tests:
test_api_v2.APIv2TestCase.test_fields
test_api_v2.APIv2TestCase.test_fields_multiple
test_api_v2.FiltersTestCase.test_attr_info_with_convert_list_to
test_api_v2.APIv2TestCase.test_filters_with_fields
test_api_v2.APIv2TestCase.test_fields_multiple_with_empty

There are 3 parts to this fix:
1. Update the APIv2TestCase _do_field_list function to construct
field list in the same order as the controller constructs its list.
2. Ensure the APIv2TestCase _get_collection_kwargs maintains order
throughout.
3. Use new assertOrderedEqual function to sort values before assertion
in test_attr_info_with_convert_list_to

Change-Id: I547cfa80cf83b0340b459279df9283443562326b
Partial-bug: #1348818
neutron/tests/base.py
neutron/tests/unit/test_api_v2.py