summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/test_ip4.py26
-rw-r--r--test/test_ip6.py25
-rw-r--r--test/vpp_policer.py21
3 files changed, 72 insertions, 0 deletions
diff --git a/test/test_ip4.py b/test/test_ip4.py
index c99ab63862f..47f0af30452 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -1533,6 +1533,14 @@ class TestIPPunt(IPPuntSetup, VppTestCase):
# but not equal to the number sent, since some were policed
#
rx = self.pg1._get_capture(1)
+
+ stats = policer.get_stats()
+
+ # Single rate policer - expect conform, violate but no exceed
+ self.assertGreater(stats['conform_packets'], 0)
+ self.assertEqual(stats['exceed_packets'], 0)
+ self.assertGreater(stats['violate_packets'], 0)
+
self.assertGreater(len(rx), 0)
self.assertLess(len(rx), len(pkts))
@@ -1636,6 +1644,24 @@ class TestIPPuntHandoff(IPPuntSetup, VppTestCase):
if worker == 0:
self.logger.debug(self.vapi.cli("show trace max 100"))
+ # Combined stats, all threads
+ stats = policer.get_stats()
+
+ # Single rate policer - expect conform, violate but no exceed
+ self.assertGreater(stats['conform_packets'], 0)
+ self.assertEqual(stats['exceed_packets'], 0)
+ self.assertGreater(stats['violate_packets'], 0)
+
+ # Worker 0, should have done all the policing
+ stats0 = policer.get_stats(worker=0)
+ self.assertEqual(stats, stats0)
+
+ # Worker 1, should have handed everything off
+ stats1 = policer.get_stats(worker=1)
+ self.assertEqual(stats1['conform_packets'], 0)
+ self.assertEqual(stats1['exceed_packets'], 0)
+ self.assertEqual(stats1['violate_packets'], 0)
+
#
# Clean up
#
diff --git a/test/test_ip6.py b/test/test_ip6.py
index 2aab4defa64..a3da6650d8b 100644
--- a/test/test_ip6.py
+++ b/test/test_ip6.py
@@ -2248,6 +2248,13 @@ class TestIP6Punt(IP6PuntSetup, VppTestCase):
# but not equal to the number sent, since some were policed
#
rx = self.pg1._get_capture(1)
+ stats = policer.get_stats()
+
+ # Single rate policer - expect conform, violate but no exceed
+ self.assertGreater(stats['conform_packets'], 0)
+ self.assertEqual(stats['exceed_packets'], 0)
+ self.assertGreater(stats['violate_packets'], 0)
+
self.assertGreater(len(rx), 0)
self.assertLess(len(rx), len(pkts))
@@ -2352,6 +2359,24 @@ class TestIP6PuntHandoff(IP6PuntSetup, VppTestCase):
if worker == 0:
self.logger.debug(self.vapi.cli("show trace max 100"))
+ # Combined stats, all threads
+ stats = policer.get_stats()
+
+ # Single rate policer - expect conform, violate but no exceed
+ self.assertGreater(stats['conform_packets'], 0)
+ self.assertEqual(stats['exceed_packets'], 0)
+ self.assertGreater(stats['violate_packets'], 0)
+
+ # Worker 0, should have done all the policing
+ stats0 = policer.get_stats(worker=0)
+ self.assertEqual(stats, stats0)
+
+ # Worker 1, should have handed everything off
+ stats1 = policer.get_stats(worker=1)
+ self.assertEqual(stats1['conform_packets'], 0)
+ self.assertEqual(stats1['exceed_packets'], 0)
+ self.assertEqual(stats1['violate_packets'], 0)
+
#
# Clean up
#
diff --git a/test/vpp_policer.py b/test/vpp_policer.py
index 49d11859646..7f6d8191138 100644
--- a/test/vpp_policer.py
+++ b/test/vpp_policer.py
@@ -67,3 +67,24 @@ class VppPolicer(VppObject):
def object_id(self):
return ("policer-%s" % (self.name))
+
+ def get_stats(self, worker=None):
+ conform = self._test.statistics.get_counter("/net/policer/conform")
+ exceed = self._test.statistics.get_counter("/net/policer/exceed")
+ violate = self._test.statistics.get_counter("/net/policer/violate")
+
+ counters = {"conform": conform, "exceed": exceed, "violate": violate}
+
+ total = {}
+ for name, c in counters.items():
+ total[f'{name}_packets'] = 0
+ total[f'{name}_bytes'] = 0
+ for i in range(len(c)):
+ t = c[i]
+ if worker is not None and i != worker + 1:
+ continue
+ stat_index = self._policer_index
+ total[f'{name}_packets'] += t[stat_index]['packets']
+ total[f'{name}_bytes'] += t[stat_index]['bytes']
+
+ return total