From 3f68ec9f201745eeef71229891dfa45de77cee75 Mon Sep 17 00:00:00 2001 From: Mehul Jindal <88073743+mehul-jindal-wavelabs@users.noreply.github.com> Date: Tue, 29 Aug 2023 16:05:09 +0530 Subject: [PATCH] fix(pipelined): QOS test cases pertaining to bitrate units (#15291) Signed-off-by: mehul-jindal-wavelabs --- .../magma/pipelined/qos/qos_meter_impl.py | 2 +- .../magma/pipelined/qos/tc_ops_pyroute2.py | 5 ++-- .../python/magma/pipelined/tests/test_qos.py | 30 ++++++++++--------- .../pipelined/tests/test_qos_pyroute2.py | 17 +++++++---- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/lte/gateway/python/magma/pipelined/qos/qos_meter_impl.py b/lte/gateway/python/magma/pipelined/qos/qos_meter_impl.py index fab7fc058e9c..91ba90d028a1 100644 --- a/lte/gateway/python/magma/pipelined/qos/qos_meter_impl.py +++ b/lte/gateway/python/magma/pipelined/qos/qos_meter_impl.py @@ -63,7 +63,7 @@ def get_action_instruction(self, meter_id: int): # pylint:disable=unused-argument def add_qos( - self, _, qos_info: QosInfo, cleanup_rule, + self, _, qos_info: QosInfo, cleanup_rule, units='', parent=None, skip_filter=False, ) -> int: if self._qos_impl_broken: diff --git a/lte/gateway/python/magma/pipelined/qos/tc_ops_pyroute2.py b/lte/gateway/python/magma/pipelined/qos/tc_ops_pyroute2.py index ae649afe94ba..b2911d7a21ae 100644 --- a/lte/gateway/python/magma/pipelined/qos/tc_ops_pyroute2.py +++ b/lte/gateway/python/magma/pipelined/qos/tc_ops_pyroute2.py @@ -49,6 +49,7 @@ def create_htb( qid: qid number. max_bw: ceiling in bits per sec. rate: rate limiting. + units: bit/kbit parent_qid: HTB parent queue. Returns: @@ -139,10 +140,10 @@ def del_filter(self, iface: str, mark: str, qid: str, proto: int = PROTOCOL) -> return 0 def create( - self, iface: str, qid: str, max_bw: int, rate=None, + self, iface: str, qid: str, max_bw: int, units: str, rate=None, parent_qid: Optional[str] = None, proto=PROTOCOL, ) -> int: - err = self.create_htb(iface, qid, max_bw, rate, parent_qid) + err = self.create_htb(iface, qid, max_bw, rate, units, parent_qid) if err: return err err = self.create_filter(iface, qid, qid, proto) diff --git a/lte/gateway/python/magma/pipelined/tests/test_qos.py b/lte/gateway/python/magma/pipelined/tests/test_qos.py index 61c84e89ad7d..527becd50a1e 100644 --- a/lte/gateway/python/magma/pipelined/tests/test_qos.py +++ b/lte/gateway/python/magma/pipelined/tests/test_qos.py @@ -198,8 +198,8 @@ def _testSanity( imsi, ip_addr, rule_num, qos_info = "1234", '1.1.1.1', 0, QosInfo(100000, 100000) # add new subscriber qos queue - qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, rule_num, FlowMatch.UPLINK, qos_info) - qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, rule_num, FlowMatch.DOWNLINK, qos_info) + qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, 'bit', rule_num, FlowMatch.UPLINK, qos_info) + qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, 'bit', rule_num, FlowMatch.DOWNLINK, qos_info) k1 = get_key_json(get_subscriber_key(imsi, ip_addr, rule_num, FlowMatch.UPLINK)) k2 = get_key_json(get_subscriber_key(imsi, ip_addr, rule_num, FlowMatch.DOWNLINK)) @@ -215,8 +215,9 @@ def _testSanity( # add the same subscriber and ensure that we didn't create another # qos config for the subscriber - qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, rule_num, FlowMatch.UPLINK, qos_info) - qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, rule_num, FlowMatch.DOWNLINK, qos_info) + + qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, 'bit', rule_num, FlowMatch.UPLINK, qos_info) + qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, 'bit', rule_num, FlowMatch.DOWNLINK, qos_info) self.assertTrue(qos_mgr._subscriber_state[imsi].rules[rule_num][0] == (0, ul_qid_info)) self.assertTrue(qos_mgr._subscriber_state[imsi].rules[rule_num][1] == (1, dl_qid_info)) @@ -324,7 +325,7 @@ def _testMultipleSubscribers( # add new subscriber qos queues for i, (imsi, rule_num, d) in enumerate(rule_list1): - qos_mgr.add_subscriber_qos(imsi, '', 0, rule_num, d, qos_info) + qos_mgr.add_subscriber_qos(imsi, '', 0, 'bit', rule_num, d, qos_info) exp_id = id_list[i] k = get_key_json(get_subscriber_key(imsi, '', rule_num, d)) @@ -409,7 +410,7 @@ def _testMultipleSubscribers( # add new subscriber qos queues for i, (imsi, rule_num, d) in enumerate(rule_list2): - qos_mgr.add_subscriber_qos(imsi, '', 0, rule_num, d, qos_info) + qos_mgr.add_subscriber_qos(imsi, '', 0, 'bit', rule_num, d, qos_info) exp_id = id_list[i] qid_info = get_data_json(get_subscriber_data(exp_id, 0, 0)) @@ -516,7 +517,7 @@ def tc_read(intf): # add a new rule to the qos_mgr and check if it is assigned right id imsi, rule_num, d, qos_info = "3", 0, 0, QosInfo(100000, 100000) qos_mgr.impl.get_action_instruction = MagicMock - qos_mgr.add_subscriber_qos(imsi, '', 0, rule_num, d, qos_info) + qos_mgr.add_subscriber_qos(imsi, '', 0, 'bit', rule_num, d, qos_info) k = get_key_json(get_subscriber_key(imsi, '', rule_num, d)) exp_id = 3 # since start_idx 2 is already used @@ -669,7 +670,7 @@ def tc_read(intf): # add a new rule to the qos_mgr and check if it is assigned right id imsi, rule_num, d, qos_info = "3", 0, 0, QosInfo(100000, 100000) qos_mgr.impl.get_action_instruction = MagicMock - qos_mgr.add_subscriber_qos(imsi, '', 10, rule_num, d, qos_info) + qos_mgr.add_subscriber_qos(imsi, '', 10, 'bit', rule_num, d, qos_info) k = get_key_json(get_subscriber_key(imsi, '', rule_num, d)) exp_id = 3 # since start_idx 2 is already used @@ -789,10 +790,11 @@ def testApnAmbrSanity( qos_mgr._setupInternal() ambr_ul, ambr_dl = 250000, 500000 imsi, ip_addr, rule_num, qos_info = ("1234", '1.1.1.1', 1, QosInfo(50000, 100000)) + units = 'bit' # add new subscriber qos queue - qos_mgr.add_subscriber_qos(imsi, ip_addr, ambr_ul, rule_num, FlowMatch.UPLINK, qos_info) - qos_mgr.add_subscriber_qos(imsi, ip_addr, ambr_dl, rule_num, FlowMatch.DOWNLINK, qos_info) + qos_mgr.add_subscriber_qos(imsi, ip_addr, ambr_ul, units, rule_num, FlowMatch.UPLINK, qos_info) + qos_mgr.add_subscriber_qos(imsi, ip_addr, ambr_dl, units, rule_num, FlowMatch.DOWNLINK, qos_info) k1 = get_key_json(get_subscriber_key(imsi, ip_addr, rule_num, FlowMatch.UPLINK)) k2 = get_key_json(get_subscriber_key(imsi, ip_addr, rule_num, FlowMatch.DOWNLINK)) @@ -817,8 +819,8 @@ def testApnAmbrSanity( # add the same subscriber and ensure that we didn't create another # qos config for the subscriber - qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, rule_num, FlowMatch.UPLINK, qos_info) - qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, rule_num, FlowMatch.DOWNLINK, qos_info) + qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, units, rule_num, FlowMatch.UPLINK, qos_info) + qos_mgr.add_subscriber_qos(imsi, ip_addr, 0, units, rule_num, FlowMatch.DOWNLINK, qos_info) self.assertTrue(qos_mgr._subscriber_state[imsi].rules[rule_num][0] == (0, get_data_json(qid_info_ul))) self.assertTrue(qos_mgr._subscriber_state[imsi].rules[rule_num][1] == (1, get_data_json(qid_info_dl))) @@ -906,11 +908,11 @@ def testSanityTrafficClass(self): TrafficClass.init_qdisc(intf, show_error=False) # create APN level ambr - TrafficClass.create_class(intf, qid=parent_qid, max_bw=apn_ambr) + TrafficClass.create_class(intf, qid=parent_qid, units='bit', max_bw=apn_ambr) # create child queue TrafficClass.create_class( - intf, qid=qid, rate=bearer_gbr, max_bw=bearer_mbr, + intf, qid=qid, rate=bearer_gbr, units='bit', max_bw=bearer_mbr, parent_qid=parent_qid, ) diff --git a/lte/gateway/python/magma/pipelined/tests/test_qos_pyroute2.py b/lte/gateway/python/magma/pipelined/tests/test_qos_pyroute2.py index efb7ced752c5..413ddf8ad9a8 100755 --- a/lte/gateway/python/magma/pipelined/tests/test_qos_pyroute2.py +++ b/lte/gateway/python/magma/pipelined/tests/test_qos_pyroute2.py @@ -63,10 +63,11 @@ def test_basic(self): iface = cls.IFACE qid = "0xae" max_bw = 10000 + units = 'bit' rate = 1000 parent_qid = '1:fffe' - err1 = t1.create(iface, qid, max_bw, rate, parent_qid) + err1 = t1.create(iface, qid, max_bw, units, rate, parent_qid) self.assertTrue(self.check_qid_in_tc(qid)) err = t1.delete(iface, qid) self.assertFalse(self.check_qid_in_tc(qid)) @@ -79,10 +80,11 @@ def test_basic6(self): iface = cls.IFACE qid = "0xae" max_bw = 10000 + units = 'bit' rate = 1000 parent_qid = '1:fffe' - err1 = t1.create(iface, qid, max_bw, rate, parent_qid, proto=0x86DD) + err1 = t1.create(iface, qid, max_bw, units, rate, parent_qid, proto=0x86DD) self.assertTrue(self.check_qid_in_tc(qid)) err = t1.delete(iface, qid, proto=0x86DD) self.assertFalse(self.check_qid_in_tc(qid)) @@ -97,10 +99,11 @@ def test_hierarchy(self): iface1 = cls.IFACE qid1 = "0xae" max_bw = 10000 + units = 'bit' rate = 1000 parent_qid1 = '1:fffe' - err1 = t1.create(iface1, qid1, max_bw, rate, parent_qid1) + err1 = t1.create(iface1, qid1, max_bw, units, rate, parent_qid1) self.assertTrue(self.check_qid_in_tc(qid1)) # Second queue @@ -110,7 +113,7 @@ def test_hierarchy(self): rate = 1000 parent_qid2 = '1:' + qid1 - err1 = t1.create(iface1, qid2, max_bw, rate, parent_qid2) + err1 = t1.create(iface1, qid2, max_bw, units, rate, parent_qid2) self.assertTrue(self.check_qid_in_tc(qid2)) # t1._print_classes(iface1) # t1._print_filters(iface1) @@ -132,10 +135,11 @@ def test_mix1(self): iface = cls.IFACE qid = "0xae" max_bw = 10000 + units = 'bit' rate = 1000 parent_qid = '1:fffe' - err1 = t1.create(iface, qid, max_bw, rate, parent_qid) + err1 = t1.create(iface, qid, max_bw, units, rate, parent_qid) self.assertTrue(self.check_qid_in_tc(qid)) err = t2.del_filter(iface, qid, qid) @@ -155,9 +159,10 @@ def test_mix2(self): qid = "0xae" max_bw = 10000 rate = 1000 + unit = 'bit' parent_qid = '1:fffe' - err1 = t2.create_htb(iface, qid, max_bw, rate, parent_qid) + err1 = t2.create_htb(iface, qid, max_bw, rate, unit, parent_qid) self.assertEqual(err1, 0) err1 = t2.create_filter(iface, qid, qid) self.assertEqual(err1, 0)