Merge "Reduce qos rpc times on the ovs-agent side"

This commit is contained in:
Zuul 2018-08-29 20:15:47 +00:00 committed by Gerrit Code Review
commit d64fd191df
2 changed files with 24 additions and 1 deletions

View File

@ -257,7 +257,8 @@ class QosAgentExtension(l2_extension.L2AgentExtension):
if not self.policy_map.has_policy_changed(port, qos_policy_id):
return
qos_policy = self.resource_rpc.pull(
qos_policy = self.policy_map.get_policy(
qos_policy_id) or self.resource_rpc.pull(
context, resources.QOS_POLICY, qos_policy_id)
if qos_policy is None:
LOG.info("QoS policy %(qos_policy_id)s applied to port "

View File

@ -291,6 +291,28 @@ class QosExtensionRpcTestCase(QosExtensionBaseTestCase):
self.context, resources.QOS_POLICY,
port['qos_policy_id'])
def test_handle_diff_ports_same_policy_id(self):
port_obj1 = self._create_test_port_dict()
port_obj2 = self._create_test_port_dict()
self.qos_ext.handle_port(self.context, port_obj1)
self.pull_mock.assert_called_once_with(
self.context, resources.QOS_POLICY,
port_obj1['qos_policy_id'])
self.assertIsNotNone(
self.qos_ext.policy_map.get_port_policy(port_obj1))
self.assertIsNone(
self.qos_ext.policy_map.get_port_policy(port_obj2))
self.qos_ext.resource_rpc.pull.reset_mock()
self.qos_ext.handle_port(self.context, port_obj2)
self.assertFalse(self.pull_mock.called)
self.assertIsNotNone(
self.qos_ext.policy_map.get_port_policy(port_obj2))
self.assertEqual(
self.qos_ext.policy_map.get_port_policy(port_obj1),
self.qos_ext.policy_map.get_port_policy(port_obj2))
def test_delete_known_port(self):
port = self._create_test_port_dict()
self.qos_ext.handle_port(self.context, port)