Merge "Fix sort issue in test_dhcp_agent_scheduler.test_filter_bindings" into stable/queens

This commit is contained in:
Zuul 2019-08-13 22:23:27 +00:00 committed by Gerrit Code Review
commit cf60191de6
1 changed files with 5 additions and 3 deletions

View File

@ -14,6 +14,7 @@
# limitations under the License. # limitations under the License.
import datetime import datetime
from operator import attrgetter
import random import random
import mock import mock
@ -500,7 +501,7 @@ class TestNetworksFailover(TestDhcpSchedulerBaseTestCase,
def test_filter_bindings(self): def test_filter_bindings(self):
self.ctx = context.get_admin_context() self.ctx = context.get_admin_context()
dhcp_agt_ids = self._create_dhcp_agents() dhcp_agt_ids = self._create_dhcp_agents()
network_ids = self._create_test_networks(num_net=4) network_ids = sorted(self._create_test_networks(num_net=4))
ndab_obj1 = network_obj.NetworkDhcpAgentBinding(self.ctx, ndab_obj1 = network_obj.NetworkDhcpAgentBinding(self.ctx,
network_id=network_ids[0], dhcp_agent_id=dhcp_agt_ids[0]) network_id=network_ids[0], dhcp_agent_id=dhcp_agt_ids[0])
ndab_obj1.create() ndab_obj1.create()
@ -513,8 +514,9 @@ class TestNetworksFailover(TestDhcpSchedulerBaseTestCase,
ndab_obj4 = network_obj.NetworkDhcpAgentBinding(self.ctx, ndab_obj4 = network_obj.NetworkDhcpAgentBinding(self.ctx,
network_id=network_ids[3], dhcp_agent_id=dhcp_agt_ids[1]) network_id=network_ids[3], dhcp_agent_id=dhcp_agt_ids[1])
ndab_obj4.create() ndab_obj4.create()
bindings_objs = network_obj.NetworkDhcpAgentBinding.get_objects( bindings_objs = sorted(network_obj.NetworkDhcpAgentBinding.get_objects(
self.ctx) self.ctx), key=attrgetter('network_id'))
with mock.patch.object(self, 'agent_starting_up', with mock.patch.object(self, 'agent_starting_up',
side_effect=[True, False]): side_effect=[True, False]):
res = [b for b in self._filter_bindings(None, bindings_objs)] res = [b for b in self._filter_bindings(None, bindings_objs)]