fix(hoststack): Base ldpreload path on CPU arch 30/42030/33
authorVratko Polak <vrpolak@cisco.com>
Wed, 5 Feb 2025 13:45:31 +0000 (14:45 +0100)
committerVratko Polak <vrpolak@cisco.com>
Wed, 5 Feb 2025 13:45:31 +0000 (14:45 +0100)
Without this, Nginx drop all packets on 2n-grc.

+ Also fix iperf3, even though we do not have working 3n ARM testbed.
- If something else breaks Nginx, failed requests still count as real.

Change-Id: Ib8d13986d2d58aaf3f63e70152bec45b303475f0
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
resources/libraries/python/Constants.py
resources/libraries/python/HoststackUtil.py
resources/libraries/robot/hoststack/hoststack.robot

index 4646ae3..6a7b81b 100644 (file)
@@ -155,8 +155,9 @@ class Constants:
     # VPP Communications Library templates location
     RESOURCES_TPL_TELEMETRY = "resources/templates/telemetry"
 
-    # VPP Communications Library LD_PRELOAD library
-    VCL_LDPRELOAD_LIBRARY = "/usr/lib/x86_64-linux-gnu/libvcl_ldpreload.so"
+    # VPP Communications Library LD_PRELOAD library.
+    # Set to override, keep empty for autodetection based on architecture.
+    VCL_LDPRELOAD_LIBRARY = ""
 
     # VPP service unit name
     VPP_UNIT = "vpp"
index 4ac73ff..3ada07b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2024 Cisco and/or its affiliates.
+# Copyright (c) 2025 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:
 # limitations under the License.
 
 """Host Stack util library."""
+
 import json
 from time import sleep
+
 from robot.api import logger
 
 from resources.libraries.python.Constants import Constants
@@ -23,10 +25,28 @@ from resources.libraries.python.model.ExportResult import (
 )
 from resources.libraries.python.PapiExecutor import PapiSocketExecutor
 from resources.libraries.python.ssh import exec_cmd, exec_cmd_no_error
+from resources.libraries.python.topology import Topology
 
 class HoststackUtil():
     """Utilities for Host Stack tests."""
 
+    @staticmethod
+    def _get_ldpreload_path(node):
+        """Return the absolute path to VCL LD_PRELOAD library.
+
+        If Constants override the path, return that.
+        Otherwise return the default pattern, with arch value from topology.
+
+        :param node: Topology node to decide architecture.
+        :type node: dict
+        :returns: Path to correct VCL preload library.
+        :rtype: str
+        """
+        if ret := Constants.VCL_LDPRELOAD_LIBRARY:
+            return ret
+        arch = Topology.get_node_arch(node)
+        return f"/usr/lib/{arch}-linux-gnu/libvcl_ldpreload.so"
+
     @staticmethod
     def get_vpp_echo_command(vpp_echo_attributes):
         """Construct the vpp_echo command using the specified attributes.
@@ -64,11 +84,13 @@ class HoststackUtil():
         return vpp_echo_cmd
 
     @staticmethod
-    def get_iperf3_command(iperf3_attributes):
+    def get_iperf3_command(iperf3_attributes, node):
         """Construct the iperf3 command using the specified attributes.
 
         :param iperf3_attributes: iperf3 test program attributes.
+        :param node: Topology node (architecture implies ldpreload path).
         :type iperf3_attributes: dict
+        :type node: dict
         :returns: Command line components of the iperf3 command
             'env_vars' - environment variables
             'name' - program name
@@ -80,8 +102,8 @@ class HoststackUtil():
             f"{Constants.RESOURCES_TPL_VCL}/" \
             f"{iperf3_attributes[u'vcl_config']}"
         if iperf3_attributes[u"ld_preload"]:
-            iperf3_cmd[u"env_vars"] += \
-                f" LD_PRELOAD={Constants.VCL_LDPRELOAD_LIBRARY}"
+            ldpreload = HoststackUtil._get_ldpreload_path(node)
+            iperf3_cmd[u"env_vars"] += f" LD_PRELOAD={ldpreload}"
         if iperf3_attributes[u'transparent_tls']:
             iperf3_cmd[u"env_vars"] += u" LDP_ENV_TLS_TRANS=1"
 
@@ -195,15 +217,17 @@ class HoststackUtil():
         return program_stdout_log, program_stderr_log
 
     @staticmethod
-    def get_nginx_command(nginx_attributes, nginx_version, nginx_ins_dir):
+    def get_nginx_command(nginx_attributes, nginx_version, nginx_ins_dir, node):
         """Construct the NGINX command using the specified attributes.
 
         :param nginx_attributes: NGINX test program attributes.
         :param nginx_version: NGINX version.
         :param nginx_ins_dir: NGINX install dir.
+        :param node: Topology node (architecture implies ldpreload path).
         :type nginx_attributes: dict
         :type nginx_version: str
         :type nginx_ins_dir: str
+        :type node: dict
         :returns: Command line components of the NGINX command
             'env_vars' - environment variables
             'name' - program name
@@ -216,8 +240,8 @@ class HoststackUtil():
                                  f"{Constants.RESOURCES_TPL_VCL}/" \
                                  f"{nginx_attributes[u'vcl_config']}"
         if nginx_attributes[u"ld_preload"]:
-            nginx_cmd[u"env_vars"] += \
-                f" LD_PRELOAD={Constants.VCL_LDPRELOAD_LIBRARY}"
+            ldpreload = HoststackUtil._get_ldpreload_path(node)
+            nginx_cmd[u"env_vars"] += f" LD_PRELOAD={ldpreload}"
         if nginx_attributes[u'transparent_tls']:
             nginx_cmd[u"env_vars"] += u" LDP_ENV_TLS_TRANS=1"
 
index d5cbd0b..643a67c 100644 (file)
 | | Set To Dictionary | ${iperf3_client_attr} | ip_address
 | | ... | ${dut2_if1_ip4_addr}
 | | Configure VPP Hoststack Attributes on all DUTs
-| | ${iperf3_server}= | Get Iperf3 Command | ${iperf3_server_attr}
+| | ${iperf3_server}= | Get Iperf3 Command | ${iperf3_server_attr} | ${dut2}
 | | ${skip_cnt}= | Evaluate
 | | ... | ${CPU_CNT_SYSTEM} + ${CPU_CNT_MAIN} + ${vpp_hoststack_attr}[phy_cores]
 | | ${numa}= | Get interfaces numa node | ${dut2} | ${dut2_if1}
 | | ... | ${dut2} | ${dut2_if1} | ${dut2_if1_ip4_addr} | ${dut2_if1_ip4_prefix}
 | | ... | ${iperf3_server_attr}[namespace] | ${core_list}
 | | ... | ${iperf3_server_attr}[cfg_vpp_feature] | ${iperf3_server}
-| | ${iperf3_client}= | Get Iperf3 Command | ${iperf3_client_attr}
+| | ${iperf3_client}= | Get Iperf3 Command | ${iperf3_client_attr} | ${dut1}
 | | ${numa}= | Get interfaces numa node | ${dut1} | ${dut1_if1}
 | | ${core_list}= | Cpu list per node str | ${dut1} | ${numa}
 | | ... | skip_cnt=${skip_cnt} | cpu_cnt=${iperf3_client_attr}[cpu_cnt]
 | | ${cpu_idle_list}= | Get Slice From List | ${cpu_idle}
 | | ... | ${${skip_cnt} + ${attr}[cpu_cnt]}
 | | ${nginx_server}= | Get Nginx Command | ${attr}
-| | ... | ${nginx_version} | ${packages_dir}
+| | ... | ${nginx_version} | ${packages_dir} | ${DUT1}
 | | Start Hoststack Test Program
 | | ... | ${DUT1} | ${attr}[namespace] | ${core_list}
 | | ... | ${nginx_server}