From 94b40cf43ca3ab7d85fd15c8fda9baf8ed07f8a1 Mon Sep 17 00:00:00 2001 From: Markus Zoeller Date: Fri, 6 May 2016 16:16:54 +0200 Subject: [PATCH] Fix TestNeutronv2.test_deallocate_for_instance_2* race failures The unit tests test_deallocate_for_instance_2_with_requested test_deallocate_for_instance_2 in nova.tests.unit.network.test_neutronv2.TestNeutronv2 fail randomly. An example error looks like this: b'mox3.mox.UnexpectedMethodCallError: Unexpected method call. unexpected:- expected:+' b"- Client.delete_port('my_portid1') -> None" b'? ^' b"+ Client.delete_port('my_portid2') -> None" b'? This is due to the mox record with expected the deletion of multiple ports on an instance in a specific order. This order is not important though and also not the same in each test case execution. To make it explicit in the test case, that the order is *not* important, I've chosen to define that in the mock records with "InAnyOrder()". Another solution could have been to ensure the order of the port IDs through the unit tests, but that could be interpreted as a precondition for the functional code to work correctly, which is a wrong assumption and therefore not chosen for this fix. Closes-Bug: 1521599 Change-Id: I6ee4512d221aed48ee56f6cca19744f20f70cbe0 --- nova/tests/unit/network/test_neutronv2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/unit/network/test_neutronv2.py b/nova/tests/unit/network/test_neutronv2.py index 75d49cf656..cf60331c8f 100644 --- a/nova/tests/unit/network/test_neutronv2.py +++ b/nova/tests/unit/network/test_neutronv2.py @@ -1424,7 +1424,7 @@ class TestNeutronv2(TestNeutronv2Base): for net, fip, port, request_id in requested_networks: self.moxed_client.update_port(port) for port in ports: - self.moxed_client.delete_port(port) + self.moxed_client.delete_port(port).InAnyOrder("delete_port_group") self.mox.StubOutWithMock(api.db, 'instance_info_cache_update') api.db.instance_info_cache_update(self.context,