From 36a1d14b58028d0294e67786129a2a09ce393cde Mon Sep 17 00:00:00 2001 From: Cedric Brandily Date: Wed, 27 May 2015 20:30:28 +0200 Subject: [PATCH] Do not assume order of security group rules This fixes the unit tests[1] that breaks with a randomized PYTHONHASHSEED (see the bug report). The test assumed that the security_group_rules_for_devices method from neutron.agent.securitygroups_rpc returned security group rules in a particular order. Found with PYTHONHASHSEED=2. The fix refactors the test case to handle unsorted security group rules. [1] neutron.tests.unit.plugins.ml2.test_security_group.\ TestMl2SGServerRpcCallBack.\ test_security_group_rules_for_devices_ipv4_ingress_addr_pair 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: I1b2bd4100c19004f12822c414aefc86aae9849db --- neutron/tests/unit/agent/test_securitygroups_rpc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/neutron/tests/unit/agent/test_securitygroups_rpc.py b/neutron/tests/unit/agent/test_securitygroups_rpc.py index 5fd97ba14..7b6c8ee40 100644 --- a/neutron/tests/unit/agent/test_securitygroups_rpc.py +++ b/neutron/tests/unit/agent/test_securitygroups_rpc.py @@ -36,6 +36,7 @@ from neutron.extensions import securitygroup as ext_sg from neutron import manager from neutron.plugins.openvswitch.agent import ovs_neutron_agent from neutron.tests import base +from neutron.tests import tools from neutron.tests.unit.extensions import test_securitygroup as test_sg FAKE_PREFIX = {const.IPv4: '10.0.0.0/24', @@ -321,6 +322,7 @@ class SGServerRpcCallBackTestCase(test_sg.SecurityGroupDBTestCase): 'port_range_min': 23, 'source_ip_prefix': fake_prefix}, ] + expected = tools.UnorderedList(expected) self.assertEqual(expected, port_rpc['security_group_rules']) self.assertEqual(port['port']['allowed_address_pairs'], -- 2.45.2