aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2021-04-19 12:22:20 +0000
committerPeter Mikus <pmikus@cisco.com>2021-05-28 05:51:32 +0000
commitd255d2545ee6cdc871bc35314fad72c3c48b225b (patch)
treef4a0a6462ec9cc856829caa0641e87bcaf37cc4c /resources/libraries/python
parent82863d5b8422b1b817d86bd6b1829a06a49feb02 (diff)
Framework: Telemetry retake
Signed-off-by: pmikus <pmikus@cisco.com> Change-Id: I2f019a083916aec9f7816266f6ad5b92dcc31fa0
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/Constants.py20
-rw-r--r--resources/libraries/python/ContainerUtils.py3
-rw-r--r--resources/libraries/python/TelemetryUtil.py (renamed from resources/libraries/python/PerfUtil.py)60
3 files changed, 72 insertions, 11 deletions
diff --git a/resources/libraries/python/Constants.py b/resources/libraries/python/Constants.py
index be9fe34915..f6e4f58006 100644
--- a/resources/libraries/python/Constants.py
+++ b/resources/libraries/python/Constants.py
@@ -133,24 +133,30 @@ class Constants:
# python scripts location
RESOURCES_LIB_PY = u"resources/libraries/python"
+ # shell scripts location
+ RESOURCES_TOOLS = u"resources/tools"
+
# Python API provider location
RESOURCES_PAPI_PROVIDER = u"resources/tools/papi/vpp_papi_provider.py"
+ # Templates location
+ RESOURCES_TPL = u"resources/templates"
+
# vat templates location
RESOURCES_TPL_VAT = u"resources/templates/vat"
# Kubernetes templates location
RESOURCES_TPL_K8S = u"resources/templates/kubernetes"
- # Templates location
- RESOURCES_TPL = u"resources/templates"
-
# Container templates location
RESOURCES_TPL_CONTAINER = u"resources/templates/container"
# VPP Communications Library templates location
RESOURCES_TPL_VCL = u"resources/templates/vcl"
+ # VPP Communications Library templates location
+ RESOURCES_TPL_TELEMETRY = u"resources/templates/telemetry"
+
# VPP Communications Library LD_PRELOAD library
VCL_LDPRELOAD_LIBRARY = u"/usr/lib/x86_64-linux-gnu/libvcl_ldpreload.so"
@@ -202,8 +208,12 @@ class Constants:
# TRex set number of RX/TX descriptors
# Set to 0 to use default values
- TREX_TX_DESCRIPTORS_COUNT = get_int_from_env(u"TREX_TX_DESCRIPTORS_COUNT", 0)
- TREX_RX_DESCRIPTORS_COUNT = get_int_from_env(u"TREX_RX_DESCRIPTORS_COUNT", 0)
+ TREX_TX_DESCRIPTORS_COUNT = get_int_from_env(
+ u"TREX_TX_DESCRIPTORS_COUNT", 0
+ )
+ TREX_RX_DESCRIPTORS_COUNT = get_int_from_env(
+ u"TREX_RX_DESCRIPTORS_COUNT", 0
+ )
# Trex force start regardless ports state
TREX_SEND_FORCE = get_pessimistic_bool_from_env(u"TREX_SEND_FORCE")
diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py
index f3b92a8b1f..75acf0027a 100644
--- a/resources/libraries/python/ContainerUtils.py
+++ b/resources/libraries/python/ContainerUtils.py
@@ -700,6 +700,7 @@ class ContainerEngine:
vpp_config.add_buffers_per_numa(215040)
vpp_config.add_plugin(u"disable", u"default")
vpp_config.add_plugin(u"enable", u"memif_plugin.so")
+ vpp_config.add_plugin(u"enable", u"perfmon_plugin.so")
vpp_config.add_main_heap_size(u"2G")
vpp_config.add_main_heap_page_size(u"2M")
vpp_config.add_statseg_size(u"2G")
@@ -736,6 +737,7 @@ class ContainerEngine:
vpp_config.add_dpdk_no_tx_checksum_offload()
vpp_config.add_dpdk_dev_default_rxq(rxq)
vpp_config.add_plugin(u"enable", u"dpdk_plugin.so")
+ vpp_config.add_plugin(u"enable", u"perfmon_plugin.so")
# Apply configuration
self.execute(u"mkdir -p /etc/vpp/")
@@ -753,6 +755,7 @@ class ContainerEngine:
vpp_config.add_plugin(u"enable", u"crypto_native_plugin.so")
vpp_config.add_plugin(u"enable", u"crypto_ipsecmb_plugin.so")
vpp_config.add_plugin(u"enable", u"crypto_openssl_plugin.so")
+ vpp_config.add_plugin(u"enable", u"perfmon_plugin.so")
# Apply configuration
self.execute(u"mkdir -p /etc/vpp/")
diff --git a/resources/libraries/python/PerfUtil.py b/resources/libraries/python/TelemetryUtil.py
index 6444cc595f..3031647915 100644
--- a/resources/libraries/python/PerfUtil.py
+++ b/resources/libraries/python/TelemetryUtil.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -15,14 +15,14 @@
from resources.libraries.python.Constants import Constants
from resources.libraries.python.OptionString import OptionString
-from resources.libraries.python.ssh import exec_cmd
+from resources.libraries.python.ssh import exec_cmd, exec_cmd_no_error
from resources.libraries.python.topology import NodeType
-__all__ = [u"PerfUtil"]
+__all__ = [u"TelemetryUtil"]
-class PerfUtil:
- """Class contains methods for perf utility."""
+class TelemetryUtil:
+ """Class contains methods for telemetry utility."""
@staticmethod
def perf_stat(node, cpu_list=None, duration=1):
@@ -79,4 +79,52 @@ class PerfUtil:
"""
for node in nodes.values():
if node[u"type"] == NodeType.DUT:
- PerfUtil.perf_stat(node, cpu_list=cpu_list, duration=duration)
+ TelemetryUtil.perf_stat(
+ node, cpu_list=cpu_list, duration=duration
+ )
+
+ @staticmethod
+ def run_telemetry(node, profile, hook=None):
+ """Get telemetry stat read for duration.
+
+ :param node: Node in the topology.
+ :param profile: Telemetry configuration profile.
+ :param hook: Process ID or socket path (optional).
+ :type node: dict
+ :type profile: str
+ :type hook: str
+ """
+ config = u""
+ config += f"{Constants.REMOTE_FW_DIR}/"
+ config += f"{Constants.RESOURCES_TPL_TELEMETRY}/"
+ config += f"{profile}"
+
+ cd_cmd = u""
+ cd_cmd += f"sh -c \"cd {Constants.REMOTE_FW_DIR}/"
+ cd_cmd += f"{Constants.RESOURCES_TOOLS}"
+
+ bin_cmd = f"python3 -m telemetry --config {config} --hook {hook}\""
+
+ exec_cmd_no_error(node, f"{cd_cmd} && {bin_cmd}", sudo=True)
+ exec_cmd_no_error(node, f"cat /tmp/metric.prom", sudo=True)
+
+ @staticmethod
+ def run_telemetry_on_all_duts(nodes, profile):
+ """Get telemetry stat read on all DUTs.
+
+ :param nodes: Nodes in the topology.
+ :param profile: Telemetry configuration profile.
+ :param hooks: Dict of Process IDs or socket paths (optional).
+ :type nodes: dict
+ :type profile: str
+ :type hooks: dict
+ """
+ for node in nodes.values():
+ if node[u"type"] == NodeType.DUT:
+ try:
+ for socket in node[u"sockets"][u"PAPI"].values():
+ TelemetryUtil.run_telemetry(
+ node, profile=profile, hook=socket
+ )
+ except IndexError:
+ pass