Merge "Fix cleaning QoS rules for not existing port."

changes/98/489398/4
Jenkins 2017-09-05 18:57:26 +00:00 committed by Gerrit Code Review
commit b0bf8e2c50
2 changed files with 47 additions and 0 deletions

View File

@ -692,6 +692,8 @@ class OVSBridge(BaseOVS):
return max_kbps, max_burst_kbps
def delete_egress_bw_limit_for_port(self, port_name):
if not self.port_exists(port_name):
return
self._set_egress_bw_limit_for_port(
port_name, 0, 0)
@ -781,6 +783,11 @@ class OVSBridge(BaseOVS):
return max_kbps, max_burst_kbit
def delete_ingress_bw_limit_for_port(self, port_name):
if not self.port_exists(port_name):
return
self._delete_ingress_bw_limit_for_port(port_name)
def _delete_ingress_bw_limit_for_port(self, port_name):
qos = self._find_qos(port_name)
queue = self._find_queue(port_name, QOS_DEFAULT_QUEUE)
with self.ovsdb.transaction(check_error=True) as txn:

View File

@ -793,6 +793,46 @@ class OVS_Lib_Test(base.BaseTestCase):
with testtools.ExpectedException(Exception):
self.br.get_local_port_mac()
def test_delete_egress_bw_limit_for_port(self):
with mock.patch.object(
self.br, "_set_egress_bw_limit_for_port"
) as set_egress_mock, mock.patch.object(
self.br, "port_exists", return_value=True
) as port_exists_mock:
self.br.delete_egress_bw_limit_for_port("test_port")
port_exists_mock.assert_called_once_with("test_port")
set_egress_mock.assert_called_once_with("test_port", 0, 0)
def test_delete_egress_bw_limit_for_port_port_not_exists(self):
with mock.patch.object(
self.br, "_set_egress_bw_limit_for_port"
) as set_egress_mock, mock.patch.object(
self.br, "port_exists", return_value=False
) as port_exists_mock:
self.br.delete_egress_bw_limit_for_port("test_port")
port_exists_mock.assert_called_once_with("test_port")
set_egress_mock.assert_not_called()
def test_delete_ingress_bw_limit_for_port(self):
with mock.patch.object(
self.br, "_delete_ingress_bw_limit_for_port"
) as delete_ingress_mock, mock.patch.object(
self.br, "port_exists", return_value=True
) as port_exists_mock:
self.br.delete_ingress_bw_limit_for_port("test_port")
port_exists_mock.assert_called_once_with("test_port")
delete_ingress_mock.assert_called_once_with("test_port")
def test_delete_ingress_bw_limit_for_port_port_not_exists(self):
with mock.patch.object(
self.br, "_delete_ingress_bw_limit_for_port"
) as delete_ingress_mock, mock.patch.object(
self.br, "port_exists", return_value=False
) as port_exists_mock:
self.br.delete_ingress_bw_limit_for_port("test_port")
port_exists_mock.assert_called_once_with("test_port")
delete_ingress_mock.assert_not_called()
def test_get_vifs_by_ids(self):
db_list_res = [
{'name': 'qvo1', 'ofport': 1,