]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Force order of dhcp.needs_resync_reasons dictionary elements
authorCedric Brandily <zzelle@gmail.com>
Tue, 26 May 2015 13:14:11 +0000 (13:14 +0000)
committerCedric Brandily <zzelle@gmail.com>
Tue, 26 May 2015 13:40:42 +0000 (13:40 +0000)
This fixes the test_periodoc_resync_helper unit test that breaks with
a randomized PYTHONHASHSEED (see the bug report).

The test assumed that the dhcp.needs_resync_reasons dictionary from
neutron.agent.dhcp.agent had elements in a particular order. Found with
PYTHONHASHSEED=2.

The fix refactors the test case to force a sorted dhcp.needs_resync_reasons
dictionary.

Partial-bug: #1348818

Note: There are several other unrelated unit tests that also break with
a randomized PYTHONHASHSEED, but they are not addressed here. They will
be addressed in separate patches.

Change-Id: Ia7fc2c3e605d92d8497d44e28054bdda613cebf2

neutron/tests/unit/agent/dhcp/test_agent.py

index afc7cf7d258628d5348e0381833560d23be22482..ebbcca29780682571c1ed2f1921f02bea66a8768 100644 (file)
@@ -13,6 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import collections
 import copy
 import sys
 import uuid
@@ -404,7 +405,8 @@ class TestDhcpAgent(base.BaseTestCase):
     def test_periodoc_resync_helper(self):
         with mock.patch.object(dhcp_agent.eventlet, 'sleep') as sleep:
             dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
-            dhcp.needs_resync_reasons = {'a': 'reason1', 'b': 'reason2'}
+            dhcp.needs_resync_reasons = collections.OrderedDict(
+                (('a', 'reason1'), ('b', 'reason2')))
             with mock.patch.object(dhcp, 'sync_state') as sync_state:
                 sync_state.side_effect = RuntimeError
                 with testtools.ExpectedException(RuntimeError):