summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-08-31 00:29:48 +0200
committerDamjan Marion <dmarion@me.com>2018-09-02 16:13:57 +0000
commit732021070fa0c731896ab3e29f802d3834c72ab7 (patch)
treed7ecbd4e4c986333b1ba59db931f0e3283da2195 /test
parent855e26868ff8b9e6d00ca4d69ce6c9fdc0f2e121 (diff)
STATS: Python binding to access VPP statistics and counters.
from vpp_papi.vpp_stats import VPPStats s = VPPStats(socketname='/var/run/stats.sock') c = s.ls('/if/rx') counters = s.dump(c) print(s.set_error_str()) Change-Id: I203ebe60b0c9ee5742aadc737c0f29051757959d Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/framework.py6
-rw-r--r--test/test_ipip.py10
2 files changed, 15 insertions, 1 deletions
diff --git a/test/framework.py b/test/framework.py
index f7a155f41cb..789ec1be9b9 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -23,6 +23,7 @@ from vpp_pg_interface import VppPGInterface
from vpp_sub_interface import VppSubInterface
from vpp_lo_interface import VppLoInterface
from vpp_papi_provider import VppPapiProvider
+from vpp_papi.vpp_stats import VPPStats
from log import RED, GREEN, YELLOW, double_line_delim, single_line_delim, \
getLogger, colorize
from vpp_object import VppObjectRegistry
@@ -279,6 +280,8 @@ class VppTestCase(unittest.TestCase):
coredump_size, "}", "api-trace", "{", "on", "}",
"api-segment", "{", "prefix", cls.shm_prefix, "}",
"cpu", "{", "main-core", str(cpu_core_number), "}",
+ "stats", "{", "socket-name",
+ cls.tempdir + "/stats.sock", "}",
"plugins", "{", "plugin", "dpdk_plugin.so", "{",
"disable", "}", "plugin", "unittest_plugin.so",
"{", "enable", "}", "}", ]
@@ -387,6 +390,7 @@ class VppTestCase(unittest.TestCase):
else:
hook = PollHook(cls)
cls.vapi.register_hook(hook)
+ cls.statistics = VPPStats(socketname=cls.tempdir+'/stats.sock')
cls.sleep(0.1, "after vpp startup, before initial poll")
try:
hook.poll_vpp()
@@ -498,7 +502,7 @@ class VppTestCase(unittest.TestCase):
self.logger.debug(self.vapi.cli("show trace"))
self.logger.info(self.vapi.ppcli("show interface"))
self.logger.info(self.vapi.ppcli("show hardware"))
- self.logger.info(self.vapi.ppcli("show error"))
+ self.logger.info(self.statistics.set_errors_str())
self.logger.info(self.vapi.ppcli("show run"))
self.logger.info(self.vapi.ppcli("show log"))
self.registry.remove_vpp_config(self.logger)
diff --git a/test/test_ipip.py b/test/test_ipip.py
index fc74d274b1f..5754bd0366b 100644
--- a/test/test_ipip.py
+++ b/test/test_ipip.py
@@ -144,6 +144,10 @@ class TestIPIP(VppTestCase):
for p in rx:
self.validate(p[1], p4_reply)
+ err = '/err/ipip4-input/packets decapsulated'
+ cnt = self.statistics.dump_str(err)
+ self.assertEqual(cnt[err], 10)
+
# IPv4 tunnel to IPv6
p_ip6 = IPv6(src="1:2:3::4", dst=self.pg0.remote_ip6)
p6 = (p_ether / IP(src=self.pg1.remote_ip4,
@@ -154,6 +158,9 @@ class TestIPIP(VppTestCase):
for p in rx:
self.validate(p[1], p6_reply)
+ cnt = self.statistics.dump_str(err)
+ self.assertEqual(cnt[err], 20)
+
#
# Fragmentation / Reassembly and Re-fragmentation
#
@@ -174,6 +181,9 @@ class TestIPIP(VppTestCase):
for p in rx:
self.validate(p[1], p4_reply)
+ cnt = self.statistics.dump_str(err)
+ self.assertEqual(cnt[err], 1020)
+
f = []
r = []
for i in range(1, 90):