aboutsummaryrefslogtreecommitdiffstats
path: root/test/vpp_policer.py
diff options
context:
space:
mode:
authorBrian Russell <brian@graphiant.com>2021-01-27 14:45:22 +0000
committerNeale Ranns <neale@graphiant.com>2021-02-02 15:05:44 +0000
commite988726cbfb1b1f618c4034aa16e41364f9c48a2 (patch)
treed1e2846e60281d0e06b2dfa666c0aa5b2e213d3c /test/vpp_policer.py
parenta71ed7869fa59884a61356a997cea81344c19dde (diff)
tests: verify policer stats in punt tests
Add verification of policer stats in the IP[46] punt paths. Type: test Signed-off-by: Brian Russell <brian@graphiant.com> Change-Id: I8b1035afc2d3abe4e98bdb3a76e87a0dd131ef4b
Diffstat (limited to 'test/vpp_policer.py')
-rw-r--r--test/vpp_policer.py21
1 files changed, 21 insertions, 0 deletions
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