From: Cedric Brandily Date: Tue, 26 May 2015 17:54:22 +0000 (+0200) Subject: Do not assume order of iptables_firewall method responses X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=e9d17b8bfff31072a3d017ce64e36ac99007a052;p=openstack-build%2Fneutron-build.git Do not assume order of iptables_firewall method responses This fixes the iptables_firewall group unit tests[1] that breaks with a randomized PYTHONHASHSEED (see the bug report). The test assumed that the _get_remote_sg_ids and _determine_remote_sgs_to_remove methods from neutron.agent.linux.iptables_firewall returned elements in a particular order. Found with PYTHONHASHSEED=1. The fix refactors the test case to handle unsorted responses from _get_remote_sg_ids and _determine_remote_sgs_to_remove. [1] neutron.tests.unit.agent.linux.test_iptables_firewall: test_prepare_port_filter_with_new_members test_prepare_port_filter_with_sg_no_member test_remove_port_filter_with_destroy_ipset_chain 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: I19e51452a2bde0721559df746047239f68614336 --- diff --git a/neutron/tests/unit/agent/linux/test_iptables_firewall.py b/neutron/tests/unit/agent/linux/test_iptables_firewall.py index 77d98e8b1..077cc5092 100644 --- a/neutron/tests/unit/agent/linux/test_iptables_firewall.py +++ b/neutron/tests/unit/agent/linux/test_iptables_firewall.py @@ -1465,7 +1465,7 @@ class IptablesFirewallEnhancedIpsetTestCase(BaseIptablesFirewallTestCase): mock.call.set_members('fake_sgid', 'IPv6', ['fe80::1']) ] - self.firewall.ipset.assert_has_calls(calls) + self.firewall.ipset.assert_has_calls(calls, any_order=True) def _setup_fake_firewall_members_and_rules(self, firewall): firewall.sg_rules = self._fake_sg_rules() @@ -1615,7 +1615,7 @@ class IptablesFirewallEnhancedIpsetTestCase(BaseIptablesFirewallTestCase): mock.call.destroy('fake_sgid', 'IPv4'), mock.call.destroy('fake_sgid', 'IPv6')] - self.firewall.ipset.assert_has_calls(calls) + self.firewall.ipset.assert_has_calls(calls, any_order=True) def test_prepare_port_filter_with_sg_no_member(self): self.firewall.sg_rules = self._fake_sg_rules() @@ -1633,7 +1633,7 @@ class IptablesFirewallEnhancedIpsetTestCase(BaseIptablesFirewallTestCase): ['10.0.0.1', '10.0.0.2']), mock.call.set_members('fake_sgid', 'IPv6', ['fe80::1'])] - self.firewall.ipset.assert_has_calls(calls) + self.firewall.ipset.assert_has_calls(calls, any_order=True) def test_filter_defer_apply_off_with_sg_only_ipv6_rule(self): self.firewall.sg_rules = self._fake_sg_rules()