]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Do not assume order of device_ids set elements
authorBradley Jones <jones.bradley@me.com>
Wed, 6 Aug 2014 13:16:23 +0000 (14:16 +0100)
committerBradley Jones <jones.bradley@me.com>
Thu, 18 Sep 2014 23:38:52 +0000 (23:38 +0000)
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

neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py

index de2724437175034fcf909610019e149700481695..4887a329dac9ce1670116164da01b819c28989c7 100644 (file)
@@ -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.'