From 654db7f0a84c408c465b08a966fd92b101581226 Mon Sep 17 00:00:00 2001 From: Peter Mikus Date: Mon, 26 May 2025 14:11:41 +0200 Subject: [PATCH] feat(dpdk): Remove installation Signed-off-by: Peter Mikus Change-Id: I5621be663f44a3b4581110dfb20daa985981af9d --- .../roles/docker_images/files/base/Dockerfile | 101 ++++++++++----------- resources/libraries/bash/function/dpdk.sh | 4 +- resources/libraries/bash/function/gather_dpdk.sh | 42 +-------- resources/libraries/python/Constants.py | 2 +- resources/libraries/python/DPDK/DPDKTools.py | 2 +- tests/dpdk/perf/__init__.robot | 3 +- 6 files changed, 55 insertions(+), 99 deletions(-) diff --git a/fdio.infra.ansible/roles/docker_images/files/base/Dockerfile b/fdio.infra.ansible/roles/docker_images/files/base/Dockerfile index a08b82f89b..b66e863aa0 100644 --- a/fdio.infra.ansible/roles/docker_images/files/base/Dockerfile +++ b/fdio.infra.ansible/roles/docker_images/files/base/Dockerfile @@ -1,6 +1,45 @@ # Import necessary base images ARG BASE_IMAGE -FROM ${BASE_IMAGE} +FROM ${BASE_IMAGE:-ubuntu} AS dpdk_stage + +ARG DPDK_VERSION + +RUN apt-get -qq update \ + && apt-get -qq install --no-install-recommends \ + build-essential \ + ca-certificates \ + libnuma-dev \ + python3-all \ + python3-apt \ + python3-dev \ + python3-pip \ + python3-pyelftools \ + python3-setuptools \ + python3-venv \ + python3-virtualenv \ + wget \ + xz-utils \ + && wget --quiet http://fast.dpdk.org/rel/dpdk-$DPDK_VERSION.tar.xz \ + && mkdir --parents /dpdk \ + && tar --extract --file=dpdk-$DPDK_VERSION.tar.xz --directory=/dpdk --strip-components 1 + +# CSIT PIP pre-cache +RUN python3 -m venv venv \ + && venv/bin/pip3 install --upgrade --no-cache-dir pip \ + && venv/bin/pip3 install --upgrade setuptools \ + && venv/bin/pip3 install --upgrade wheel \ + && venv/bin/pip3 install \ + meson==0.64.1 \ + ninja + +ENV PATH="$PATH:/venv/bin" + +# Install DPDK +RUN cd /dpdk \ + && meson setup -Dexamples=l3fwd -Dc_args=-DRTE_LIBRTE_I40E_16BYTE_RX_DESC=y -Dplatform=generic build \ + && ninja -C build + +FROM ${BASE_IMAGE:-ubuntu} AS csit_prod # Setup the environment ENV DEBIAN_FRONTEND=noninteractive @@ -48,16 +87,12 @@ RUN apt-get -q update \ libsctp-dev \ libssl-dev \ net-tools \ - ninja-build \ openssh-server \ pciutils \ python3-all \ python3-apt \ - python3-cffi \ - python3-cffi-backend \ python3-dev \ python3-pip \ - python3-pyelftools \ python3-setuptools \ python3-venv \ python3-virtualenv \ @@ -94,56 +129,12 @@ RUN mkdir -p /tmp/dumps \ # CSIT PIP pre-cache RUN python3 -m venv venv \ - && venv/bin/pip3 install --upgrade --no-cache-dir pip \ - && venv/bin/pip3 install --upgrade setuptools \ - && venv/bin/pip3 install --upgrade wheel \ - && venv/bin/pip3 install \ - ecdsa==0.19.0 \ - paramiko==3.4.1 \ - pycryptodome==3.20.0 \ - python-dateutil==2.9.0 \ - PyYAML==6.0.1 \ - requests==2.32.2 \ - robotframework==7.0.1 \ - scapy==2.4.5 \ - scp==0.15.0 \ - ansible==10.2.0 \ - ansible-core==2.17.2 \ - dill==0.3.8 \ - numpy==2.0.1 \ - scipy==1.14.0 \ - ply==3.11 \ - jsonschema==4.23.0 \ - rfc3339-validator==0.1.4 \ - rfc3987==1.3.8 \ - pylint==3.2.6 \ - astroid==3.2.4 \ - attrs==24.2.0 \ - bcrypt==4.2.0 \ - certifi==2024.7.4 \ - cffi==1.17.0 \ - charset-normalizer==3.3.2 \ - cryptography==43.0.0 \ - idna==3.7 \ - isort==5.13.2 \ - Jinja2==3.1.4 \ - jsonschema-specifications==2023.12.1 \ - MarkupSafe==2.1.5 \ - mccabe==0.7.0 \ - packaging==24.1 \ - platformdirs==4.2.2 \ - ply==3.11 \ - pycparser==2.22 \ - PyNaCl==1.5.0 \ - referencing==0.35.1 \ - resolvelib==1.0.1 \ - rpds-py==0.20.0 \ - six==1.16.0 \ - tomli==2.0.1 \ - tomlkit==0.13.0 \ - typing_extensions==4.12.2 \ - urllib3==2.2.2\ - meson==0.64.1 + && venv/bin/pip3 install --upgrade --no-cache-dir pip \ + && venv/bin/pip3 install --upgrade setuptools \ + && venv/bin/pip3 install --upgrade wheel + +# Extract DPDK from previous image. +COPY --from=dpdk_stage /dpdk /opt/dpdk RUN useradd -rm -d /home/testuser -s /bin/bash -g 1000 -G sudo testuser \ && echo 'testuser:Csit1234' | chpasswd diff --git a/resources/libraries/bash/function/dpdk.sh b/resources/libraries/bash/function/dpdk.sh index 7876eb67b0..9b6b7526a0 100644 --- a/resources/libraries/bash/function/dpdk.sh +++ b/resources/libraries/bash/function/dpdk.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2023 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: @@ -41,7 +41,7 @@ function common_dirs () { die "Readlink failed." } mkdir -p "${CSIT_DIR}/dpdk" || die "Mkdir failed." - DPDK_DIR=$(readlink -e "${CSIT_DIR}/dpdk") || { + DPDK_DIR=$(readlink -e "/opt/dpdk") || { die "Readlink failed." } } diff --git a/resources/libraries/bash/function/gather_dpdk.sh b/resources/libraries/bash/function/gather_dpdk.sh index ead1079e7a..0d8ed3e3fc 100644 --- a/resources/libraries/bash/function/gather_dpdk.sh +++ b/resources/libraries/bash/function/gather_dpdk.sh @@ -20,45 +20,11 @@ set -exuo pipefail function gather_dpdk () { - # Ensure latest DPDK archive is downloaded. - # - # Variables read: - # - TEST_CODE - The test selection string from environment or argument. - # Hardcoded: - # - dpdk archive name to download if TEST_CODE is not time based. - # Directories updated: - # - ./ - Assumed ${DOWNLOAD_DIR}, dpdk-*.tar.xz is downloaded if not there. - # Functions called: - # - die - Print to stderr and exit, defined in common.sh + # This function is required to bypass download dir check. + # Currently it creates empty file in download dir. set -exuo pipefail - dpdk_repo="https://fast.dpdk.org/rel" - # Use downloaded packages with specific version - if [[ "${TEST_CODE}" == *"daily"* ]] || \ - [[ "${TEST_CODE}" == *"weekly"* ]] || \ - [[ "${TEST_CODE}" == *"timed"* ]]; - then - echo "Downloading latest DPDK packages from repo..." - # URL is not in quotes, calling command from variable keeps them. - wget_command=("wget" "--no-check-certificate" "--compression=auto") - wget_command+=("-nv" "-O" "-") - wget_command+=("${dpdk_repo}") - dpdk_stable_ver="$("${wget_command[@]}" | grep -v "2015"\ - | grep -Eo 'dpdk-[^\"]+xz' | tail -1)" || { - die "Composite piped command failed." - } - else - echo "Downloading DPDK package of specific version from repo ..." - # Downloading DPDK version based on what VPP is using. Currently - # it is not easy way to detect from VPP version automatically. - dpdk_stable_ver="$(< "${CSIT_DIR}/DPDK_VPP_VER")".tar.xz || { - die "Failed to read DPDK VPP version!" - } - fi - if [[ ! -f "${dpdk_stable_ver}" ]]; then - wget -nv --no-check-certificate "${dpdk_repo}/${dpdk_stable_ver}" || { - die "Failed to get DPDK package from: ${dpdk_repo}" - } - fi + touch dpdk-download-skipped.txt + } diff --git a/resources/libraries/python/Constants.py b/resources/libraries/python/Constants.py index 9c866149da..900d5b3f67 100644 --- a/resources/libraries/python/Constants.py +++ b/resources/libraries/python/Constants.py @@ -181,7 +181,7 @@ class Constants: QEMU_VM_IMAGE = "/var/lib/vm/image.iso" # QEMU VM DPDK path - QEMU_VM_DPDK = "/opt/dpdk-24.11.1" + QEMU_VM_DPDK = "/opt/dpdk" # Docker container SUT image DOCKER_SUT_IMAGE_UBUNTU = "csit_sut-ubuntu2404:local" diff --git a/resources/libraries/python/DPDK/DPDKTools.py b/resources/libraries/python/DPDK/DPDKTools.py index 12800ba4fc..0063fd4f83 100644 --- a/resources/libraries/python/DPDK/DPDKTools.py +++ b/resources/libraries/python/DPDK/DPDKTools.py @@ -91,7 +91,7 @@ class DPDKTools: :rtype: str :raises RuntimeError: If command returns nonzero return code. """ - command = f"cat {Constants.REMOTE_FW_DIR}/dpdk*/VERSION" + command = f"cat /opt/dpdk/VERSION" message = u"Get DPDK version failed!" stdout, _ = exec_cmd_no_error(node, command, message=message) logger.info(f"DPDK Version: {stdout}") diff --git a/tests/dpdk/perf/__init__.robot b/tests/dpdk/perf/__init__.robot index 2945936116..bb4a1d900b 100644 --- a/tests/dpdk/perf/__init__.robot +++ b/tests/dpdk/perf/__init__.robot @@ -1,4 +1,4 @@ -# Copyright (c) 2021 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: @@ -22,7 +22,6 @@ | Suite Setup | Run Keywords | Start Suite Setup Export | ... | AND | Setup performance global Variables | ... | AND | Setup Framework | ${nodes} -| ... | AND | Install DPDK framework on all DUTs | ${nodes} | ... | AND | Get CPU Info from All Nodes | ${nodes} | ... | AND | Update All Interface Data on All Nodes | ${nodes} | ... | skip_tg=${True} | skip_vpp=${True} -- 2.16.6