From: John Davidge Date: Tue, 5 Aug 2014 14:13:03 +0000 (+0100) Subject: Do not assume order of new_peers list elements X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c353a26fb36b97bdc369bd41e0f23a8bbf2a2ea8;p=openstack-build%2Fneutron-build.git Do not assume order of new_peers list elements This fixes the vpn unit test that breaks with a randomized PYTHONHASHSEED (see the bug report). The test assumed that the new_peers list from self.new_update_request had elements in a particular order. Found with PYTHONHASHSEED=2455351445. The fix refactors the test case to handle an unsorted new_peers list by sorting it before running the test. 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: I86e7f84cedbdc8e1d7404363a560fd759d264c49 --- diff --git a/neutron/tests/unit/db/vpn/test_db_vpnaas.py b/neutron/tests/unit/db/vpn/test_db_vpnaas.py index 10c82675f..a12a61335 100644 --- a/neutron/tests/unit/db/vpn/test_db_vpnaas.py +++ b/neutron/tests/unit/db/vpn/test_db_vpnaas.py @@ -1252,9 +1252,13 @@ class TestVpnaas(VPNPluginDbTestCase): self.assertEqual(expected_status_int, res.status_int) if expected_status_int == 200: res_dict = self.deserialize(self.fmt, res) + actual = res_dict['ipsec_site_connection'] for k, v in update.items(): - self.assertEqual( - res_dict['ipsec_site_connection'][k], v) + # Sort lists before checking equality + if isinstance(actual[k], list): + self.assertEqual(v, sorted(actual[k])) + else: + self.assertEqual(v, actual[k]) def test_show_ipsec_site_connection(self): """Test case to show a ipsec_site_connection."""