From: Bradley Jones Date: Wed, 6 Aug 2014 13:16:23 +0000 (+0100) Subject: Do not assume order of device_ids set elements X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=979d8118577c59a2dfe8c3ebd268fb3863aa4b26;p=openstack-build%2Fneutron-build.git Do not assume order of device_ids set elements This fixes the test_ancillary_bridges_multiple unit test that breaks with a randomized PYTHONHASHSEED (see the bug report). The test assumed that the device_ids set had elements in a particular order. Found with PYTHONHASHSEED=2455351445. The fix refactors the pullup_side_effect function so that it checks if the device_id exists before returning the bridge. 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: Ie6b44d1d820ebb186036ffcd04ea2104dd384e94 --- diff --git a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py index de2724437..4887a329d 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py @@ -1405,8 +1405,13 @@ class AncillaryBridgesTest(base.BaseTestCase): device_ids = ancillary[:] def pullup_side_effect(self, *args): - result = device_ids.pop(0) - return result + # Check that the device_id exists, if it does return it + # if it does not return None + try: + device_ids.remove(args[0]) + return args[0] + except Exception: + return None with contextlib.nested( mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'