From: Peter Mikus Date: Tue, 24 Jun 2025 12:16:22 +0000 (+0200) Subject: fix(tests): L3fwd X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F84%2F43284%2F2;p=csit.git fix(tests): L3fwd Signed-off-by: Peter Mikus Change-Id: I5d77c44d54c5fd9d3e8afa78069cc7279a082936 --- diff --git a/resources/libraries/bash/entry/patch_l3fwd.sh b/resources/libraries/bash/entry/patch_l3fwd.sh deleted file mode 100755 index 88597f1da0..0000000000 --- a/resources/libraries/bash/entry/patch_l3fwd.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -# 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: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Recompile DPDK l3fwd sample app with patching. - -set -exuo pipefail - -# Assumptions: -# + There is a directory holding CSIT code to use (this script is there). -# + At least one of the following is true: -# ++ JOB_NAME environment variable is set, -# ++ or this entry script has access to arguments. -# Consequences (and specific assumptions) are multiple, -# examine tree of functions for current description. - -# FIXME: Define API contract (as opposed to just help) for bootstrap. - -# "set -eu" handles failures from the following two lines. -BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" -BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")" -source "${BASH_FUNCTION_DIR}/common.sh" || { - echo "Source failed." >&2 - exit 1 -} -source "${BASH_FUNCTION_DIR}/dpdk.sh" || die "Source failed." -common_dirs || die -dpdk_l3fwd_compile "${@}" || die diff --git a/resources/libraries/bash/entry/patch_l3fwd_flip_routes b/resources/libraries/bash/entry/patch_l3fwd_flip_routes deleted file mode 100755 index c5eff5d3ca..0000000000 --- a/resources/libraries/bash/entry/patch_l3fwd_flip_routes +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -patch --ignore-whitespace --forward main.c <<"_EOF" -204,205c204,205 -< {RTE_IPV4(198, 18, 0, 0), 24, 0}, -< {RTE_IPV4(198, 18, 1, 0), 24, 1}, ---- -> {RTE_IPV4(198, 18, 0, 0), 24, 1}, -> {RTE_IPV4(198, 18, 1, 0), 24, 0}, -_EOF diff --git a/resources/libraries/python/DPDK/L3fwdTest.py b/resources/libraries/python/DPDK/L3fwdTest.py index 6ffae63bc0..a95012d64c 100644 --- a/resources/libraries/python/DPDK/L3fwdTest.py +++ b/resources/libraries/python/DPDK/L3fwdTest.py @@ -19,7 +19,7 @@ from robot.libraries.BuiltIn import BuiltIn from resources.libraries.python.Constants import Constants from resources.libraries.python.CpuUtils import CpuUtils from resources.libraries.python.DpdkUtil import DpdkUtil -from resources.libraries.python.ssh import exec_cmd_no_error, exec_cmd +from resources.libraries.python.ssh import exec_cmd_no_error from resources.libraries.python.topology import NodeType, Topology NB_PORTS = 2 @@ -173,7 +173,8 @@ class L3fwdTest: ) command = f"{Constants.REMOTE_FW_DIR}/{Constants.RESOURCES_LIB_SH}"\ - f"/entry/run_l3fwd.sh \"{l3fwd_args} -P -L -p 0x3\"" + f"/entry/run_l3fwd.sh \"{l3fwd_args} -P -L -p 0x3"\ + f" --rule_ipv4={Constants.REMOTE_FW_DIR}/rule_ipv4.cfg\"" message = f"Failed to execute l3fwd test at node {node['host']}" exec_cmd_no_error(node, command, timeout=1800, message=message) @@ -227,13 +228,16 @@ class L3fwdTest: # If DUT and TG not reordered -> flip # Detect which is the port 0. + direction = 0 dut_flip = if_pci0 > if_pci1 if dut_flip: if_key0, if_key1 = if_key1, if_key0 if tg_flip: - L3fwdTest.patch_l3fwd(node, "patch_l3fwd_flip_routes") + direction = 1 elif not tg_flip: - L3fwdTest.patch_l3fwd(node, "patch_l3fwd_flip_routes") + direction = 1 + + L3fwdTest.create_routes(node, direction=direction) adj_node0, adj_if_key0 = Topology.get_adjacent_node_and_interface( nodes, node, if_key0 @@ -249,21 +253,28 @@ class L3fwdTest: return adj_mac0, adj_mac1, if_pci0, if_pci1 @staticmethod - def patch_l3fwd(node, patch): + def create_routes(node, direction=0): """ - Patch l3fwd application and recompile. + Create route file for l3fwd application. + + R :param node: DUT node. - :param patch: Patch to apply. + :param direction: Route appearence order. :type node: dict - :type patch: str - :raises RuntimeError: Patching of l3fwd failed. + :type direction: str + :raises RuntimeError: Create route file failed. """ - command = f"{Constants.REMOTE_FW_DIR}/{Constants.RESOURCES_LIB_SH}"\ - f"/entry/patch_l3fwd.sh " \ - f"{Constants.REMOTE_FW_DIR}/{Constants.RESOURCES_LIB_SH}"\ - f"/entry/{patch}" - message = f"Failed to patch l3fwd at node {node['host']}" - ret_code, stdout, _ = exec_cmd(node, command, timeout=1800) - if ret_code != 0 and "Skipping patch." not in stdout: - raise RuntimeError(message) + filename = f"{Constants.REMOTE_FW_DIR}/rule_ipv4.cfg" + if not direction: + rule_ipv4 = ( + "R198.18.0.0/24 0\n" + "R198.18.1.0/24 1\n" + ) + else: + rule_ipv4 = ( + "R198.18.0.0/24 1\n" + "R198.18.1.0/24 0\n" + ) + cmd = f"echo \"{rule_ipv4}\" | sudo tee {filename}" + exec_cmd_no_error(node, cmd, message="Writing config file failed!") \ No newline at end of file