summaryrefslogtreecommitdiffstats
path: root/test/test_policer_input.py
diff options
context:
space:
mode:
authorMaxime Peim <mpeim@cisco.com>2023-01-06 11:57:38 +0000
committerNeale Ranns <neale@graphiant.com>2023-02-02 00:22:06 +0000
commit2d1a62bfddbba92a0aeec5c68e9b0a7903b178da (patch)
treeb5a8306e9d345c18bb45a55b0cfa5786c02258f0 /test/test_policer_input.py
parent3220d9f16b3db05fe9ea8d756395cd8aa7755863 (diff)
policer: API policer selection by index
Policer API calls were only by policer name. It is now possible to select a policer by its index. Some functionalities are also added to allow updating a policer configuration and to refill its token buckets. Some dead codes are being removed, and small fixes made. Type: improvement Signed-off-by: Maxime Peim <mpeim@cisco.com> Change-Id: I4cc8fda0fc7c635a4110da3e757356b150f9b606
Diffstat (limited to 'test/test_policer_input.py')
-rw-r--r--test/test_policer_input.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/test/test_policer_input.py b/test/test_policer_input.py
index 9d44fc1a21c..6b4ab54a37e 100644
--- a/test/test_policer_input.py
+++ b/test/test_policer_input.py
@@ -92,6 +92,85 @@ class TestPolicerInput(VppTestCase):
"""Output Policing"""
self.policer_interface_test(Dir.TX)
+ def test_policer_reset(self):
+ """Policer reset bucket"""
+ pkts = self.pkt * NUM_PKTS
+
+ action_tx = PolicerAction(
+ VppEnum.vl_api_sse2_qos_action_type_t.SSE2_QOS_ACTION_API_TRANSMIT, 0
+ )
+ policer = VppPolicer(
+ self,
+ "pol1",
+ 1,
+ 0,
+ 10000,
+ 0,
+ conform_action=action_tx,
+ exceed_action=action_tx,
+ violate_action=action_tx,
+ )
+ policer.add_vpp_config()
+
+ # Start policing on pg0
+ policer.apply_vpp_config(self.pg0.sw_if_index, Dir.RX, True)
+
+ self.send_and_expect(self.pg0, pkts, self.pg1, worker=0)
+ details = policer.get_details()
+
+ self.assertGreater(details.current_limit, details.current_bucket)
+
+ self.send_and_expect(self.pg0, pkts, self.pg1, worker=0)
+ self.vapi.policer_reset(policer_index=policer.policer_index)
+ details = policer.get_details()
+
+ self.assertEqual(details.current_limit, details.current_bucket)
+
+ policer.apply_vpp_config(self.pg0.sw_if_index, Dir.RX, False)
+
+ policer.remove_vpp_config()
+
+ def test_policer_update(self):
+ """Policer update"""
+ pkts = self.pkt * NUM_PKTS
+
+ action_tx = PolicerAction(
+ VppEnum.vl_api_sse2_qos_action_type_t.SSE2_QOS_ACTION_API_TRANSMIT, 0
+ )
+ policer = VppPolicer(
+ self,
+ "pol1",
+ 1,
+ 0,
+ 10000,
+ 0,
+ conform_action=action_tx,
+ exceed_action=action_tx,
+ violate_action=action_tx,
+ )
+ policer.add_vpp_config()
+
+ # Start policing on pg0
+ policer.apply_vpp_config(self.pg0.sw_if_index, Dir.RX, True)
+
+ self.send_and_expect(self.pg0, pkts, self.pg1, worker=0)
+ details_before = policer.get_details()
+
+ self.assertGreater(details_before.current_limit, details_before.current_bucket)
+
+ policer.cir = 8000
+ policer.commited_burst = 100000
+ policer.update()
+
+ details_after = policer.get_details()
+
+ self.assertGreater(details_after.cir, details_before.cir)
+ self.assertGreater(details_after.cb, details_before.cb)
+
+ policer.apply_vpp_config(self.pg0.sw_if_index, Dir.RX, False)
+
+ policer.remove_vpp_config()
+
def policer_handoff_test(self, dir: Dir):
pkts = self.pkt * NUM_PKTS