diff --git a/.ci/dockerfiles/Dockerfile.ubuntu22.04 b/.ci/dockerfiles/Dockerfile.ubuntu22.04 new file mode 100644 index 000000000..0288bde24 --- /dev/null +++ b/.ci/dockerfiles/Dockerfile.ubuntu22.04 @@ -0,0 +1,35 @@ +ARG ARCH=x86_64 +FROM harbor.mellanox.com/hpcx/$ARCH/ubuntu22.04/base AS build +FROM build AS tests +RUN apt-get update && \ + apt-get install -y \ + net-tools unzip iproute2 wget \ + && apt-get clean && rm -rf /var/lib/apt/lists/* +FROM tests AS vg +RUN apt-get update && \ + apt-get install -y \ + valgrind \ + && apt-get clean && rm -rf /var/lib/apt/lists/* +FROM tests AS test +RUN apt-get update && \ + apt-get install -y \ + openssh-server psmisc \ + && apt-get clean && rm -rf /var/lib/apt/lists/* +# setup ssh server and passwordless login for root for tests flows (verifyer.pl) +RUN mkdir -p /var/run/sshd ~/.ssh && \ + rm -rf ~/.ssh/id_rsa* && ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa && \ + cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys && \ + sed -i 's|#PermitRootLogin.*|PermitRootLogin without-password|g' /etc/ssh/sshd_config && \ + sed -i 's|#PasswordAuthentication.*|PasswordAuthentication no|g' /etc/ssh/sshd_config && \ + echo "Host *" >> ~/.ssh/config && \ + echo " StrictHostKeyChecking no" >> ~/.ssh/config && \ + echo " UserKnownHostsFile /dev/null" >> ~/.ssh/config && \ + echo " LogLevel ERROR" >> ~/.ssh/config +FROM tests AS gtest +FROM build AS style +RUN apt-get update \ + && apt-get install -y clang-15 clang-format-15 \ + && update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 100 \ + && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100 \ + --slave /usr/bin/clang++ clang++ /usr/bin/clang++-15 \ + && apt-get clean && rm -rf /var/lib/apt/lists/* diff --git a/.ci/matrix_job.yaml b/.ci/matrix_job.yaml index d5f1b1e6b..00d822d17 100644 --- a/.ci/matrix_job.yaml +++ b/.ci/matrix_job.yaml @@ -4,7 +4,8 @@ job: LIBVMA step_allow_single_selector: false registry_host: harbor.mellanox.com -registry_auth: swx-storage +registry_auth: swx-infra_harbor_credentials +registry_path: /swx-infra/media kubernetes: privileged: true @@ -43,9 +44,58 @@ runs_on_dockers: - {name: 'toolbox', url: 'harbor.mellanox.com/hpcx/x86_64/rhel8.6/builder:inbox', category: 'tool', arch: 'x86_64'} - {name: 'blackduck', url: 'harbor.mellanox.com/toolbox/ngci-centos:7.9.2009.2', category: 'tool', arch: 'x86_64'} - {name: 'header-check', url: 'harbor.mellanox.com/toolbox/header_check:0.0.51', category: 'tool', arch: 'x86_64', tag: '0.0.51'} - -runs_on_agents: - - {nodeLabel: 'beni09', category: 'base'} +# tests + - { + file: '.ci/dockerfiles/Dockerfile.ubuntu22.04', + arch: 'x86_64', + name: 'test', + uri: 'vma/$arch/ubuntu22.04/$name', + tag: '20250219', + build_args: '--no-cache --target test', + category: 'tests', + annotations: [{ key: 'k8s.v1.cni.cncf.io/networks', value: 'sriov-cx6dx-p1' }], + limits: '{memory: 10Gi, cpu: 10000m, hugepages-2Mi: 10Gi, mellanox.com/sriov_cx6dx_p1: 1}', + requests: '{memory: 10Gi, cpu: 10000m, hugepages-2Mi: 10Gi, mellanox.com/sriov_cx6dx_p1: 1}', + caps_add: '[ IPC_LOCK, SYS_RESOURCE ]', + runAsUser: '0', + runAsGroup: '0', + cloud: swx-k8s-spray, + namespace: default + } + - { + file: '.ci/dockerfiles/Dockerfile.ubuntu22.04', + arch: 'x86_64', + name: 'vg', + uri: 'vma/$arch/ubuntu22.04/$name', + tag: '20250219', + build_args: '--no-cache --target vg', + category: 'tool', + annotations: [{ key: 'k8s.v1.cni.cncf.io/networks', value: 'sriov-cx6dx-p2' }], + limits: '{memory: 10Gi, cpu: 10000m, hugepages-2Mi: 10Gi, mellanox.com/sriov_cx6dx_p2: 1}', + requests: '{memory: 10Gi, cpu: 10000m, hugepages-2Mi: 10Gi, mellanox.com/sriov_cx6dx_p2: 1}', + caps_add: '[ IPC_LOCK, SYS_RESOURCE ]', + runAsUser: '0', + runAsGroup: '0', + cloud: swx-k8s-spray, + namespace: default + } + - { + file: '.ci/dockerfiles/Dockerfile.ubuntu22.04', + arch: 'x86_64', + name: 'gtest', + uri: 'vma/$arch/ubuntu22.04/$name', + tag: '20250219', + build_args: '--no-cache --target gtest', + category: 'tests', + annotations: [{ key: 'k8s.v1.cni.cncf.io/networks', value: 'sriov-cx6dx-p1@net1,sriov-cx6dx-p2@net2' }], + limits: '{memory: 10Gi, cpu: 10000m, hugepages-2Mi: 8Gi, mellanox.com/sriov_cx6dx_p1: 1, mellanox.com/sriov_cx6dx_p2: 1}', + requests: '{memory: 10Gi, cpu: 10000m, hugepages-2Mi: 8Gi, mellanox.com/sriov_cx6dx_p1: 1, mellanox.com/sriov_cx6dx_p2: 1}', + caps_add: '[ IPC_LOCK, SYS_RESOURCE ]', + runAsUser: '0', + runAsGroup: '0', + cloud: swx-k8s-spray, + namespace: default + } matrix: axes: @@ -62,6 +112,12 @@ env: steps: - name: Setup + containerSelector: + - "{category: 'base'}" + - "{name: 'test', variant:1}" + - "{name: 'gtest', variant:1}" + - "{name: 'vg', variant:1}" + - "{name: 'style'}" run: | set +x echo @@ -90,27 +146,34 @@ steps: - name: Install Doca-host containerSelector: - "{category: 'base'}" + - "{name: 'test', variant:1}" + - "{name: 'gtest', variant:1}" + - "{name: 'vg', variant:1}" + - "{name: 'style'}" agentSelector: - "{nodeLabel: 'skip-agent'}" run: | echo "Installing DOCA: ${DOCA_VERSION} ..." .ci/scripts/doca_install.sh - - name: Install Doca-host on Tools - run: | - echo "Installing DOCA: ${DOCA_VERSION} ..." - .ci/scripts/doca_install.sh - containerSelector: - - "{name: 'style', category: 'tool'}" - agentSelector: - - "{nodeLabel: 'skip-agent'}" - - name: Autogen + containerSelector: + - "{category: 'base'}" + - "{name: 'test', variant:1}" + - "{name: 'gtest', variant:1}" + - "{name: 'vg', variant:1}" + - "{name: 'style'}" run: | ./autogen.sh -s parallel: false - name: Build + containerSelector: + - "{category: 'base'}" + - "{name: 'test', variant:1}" + - "{name: 'gtest', variant:1}" + - "{name: 'vg', variant:1}" + - "{name: 'style'}" enable: ${do_build} run: | [ "x${do_build}" == "xtrue" ] && action=yes || action=no @@ -138,6 +201,11 @@ steps: - name: Package enable: ${do_package} + containerSelector: + - "{category: 'base'}" + # - "{name: 'test', variant:1}" + # - "{name: 'gtest', variant:1}" + # - "{name: 'vg', variant:1}" run: | [ "x${do_package}" == "xtrue" ] && action=yes || action=no env WORKSPACE=$PWD TARGET=${flags} jenkins_test_rpm=${action} ./contrib/test_jenkins.sh @@ -227,12 +295,13 @@ steps: - name: Test enable: ${do_test} containerSelector: - - "{name: 'skip-container'}" + - "{name: 'test', variant:1}" agentSelector: - - "{nodeLabel: 'beni09', variant:1}" + - "{nodeLabel: 'skip-agent'}" run: | [ "x${do_test}" == "xtrue" ] && action=yes || action=no env WORKSPACE=$PWD TARGET=${flags} jenkins_test_run=${action} ./contrib/test_jenkins.sh + sleep 80000 parallel: false onfail: | ./.ci/artifacts.sh @@ -242,9 +311,9 @@ steps: - name: Gtest enable: ${do_gtest} containerSelector: - - "{name: 'skip-container'}" + - "{name: 'gtest', variant:1}" agentSelector: - - "{nodeLabel: 'beni09', variant:1}" + - "{nodeLabel: 'skip-agent'}" run: | [ "x${do_gtest}" == "xtrue" ] && action=yes || action=no env WORKSPACE=$PWD TARGET=${flags} jenkins_test_gtest=${action} ./contrib/test_jenkins.sh @@ -259,9 +328,9 @@ steps: - name: Valgrind enable: ${do_valgrind} containerSelector: - - "{name: 'skip-container'}" + - "{name: 'vg', variant:1}" agentSelector: - - "{nodeLabel: 'beni09', variant:1}" + - "{nodeLabel: 'skip-agent'}" run: | [ "x${do_valgrind}" == "xtrue" ] && action=yes || action=no env WORKSPACE=$PWD TARGET=${flags} jenkins_test_vg=${action} ./contrib/test_jenkins.sh @@ -289,6 +358,13 @@ steps: - name: Artifacts enable: ${do_artifact} + containerSelector: + - "{category: 'base'}" + - "{name: 'test', variant:1}" + - "{name: 'gtest', variant:1}" + - "{name: 'vg', variant:1}" + - "{name: 'style'}" + - "{category: 'tool', variant:1}" run: | ./.ci/artifacts.sh parallel: false diff --git a/contrib/jenkins_tests/globals.sh b/contrib/jenkins_tests/globals.sh index 22e00d140..72c705224 100755 --- a/contrib/jenkins_tests/globals.sh +++ b/contrib/jenkins_tests/globals.sh @@ -75,6 +75,16 @@ function do_archive() set -e } +function do_hugepages() +{ + if [[ -f /.dockerenv ]] || [[ -f /run/.containerenv ]] || [[ -n "${KUBERNETES_SERVICE_HOST}" ]]; then + mkdir -p /mnt/huge + mount -t hugetlbfs nodev /mnt/huge + grep hugetlbfs /proc/mounts + echo $? + fi +} + # Test if an environment module exists and load it if yes. # Otherwise, return error code. # $1 - module name diff --git a/contrib/jenkins_tests/gtest.sh b/contrib/jenkins_tests/gtest.sh index b289efb8c..9551d71ab 100755 --- a/contrib/jenkins_tests/gtest.sh +++ b/contrib/jenkins_tests/gtest.sh @@ -2,6 +2,11 @@ source $(dirname $0)/globals.sh +# Fix hugepages for docker environments +do_hugepages +ulimit -l unlimited +ulimit -c unlimited + echo "Checking for gtest ..." # Check dependencies @@ -10,11 +15,6 @@ if [ $(test -d ${install_dir} >/dev/null 2>&1 || echo $?) ]; then exit 1 fi -if [ $(command -v ibdev2netdev >/dev/null 2>&1 || echo $?) ]; then - echo "[SKIP] ibdev2netdev tool does not exist" - exit 1 -fi - cd $WORKSPACE rm -rf $gtest_dir @@ -25,16 +25,21 @@ gtest_app="$PWD/tests/gtest/gtest" gtest_lib=$install_dir/lib/${prj_lib} gtest_ip_list="" -if [ ! -z $(do_get_ip 'eth') ]; then - gtest_ip_list="$(do_get_ip 'eth')" -fi -if [ ! -z $(do_get_ip 'eth' '' $gtest_ip_list) ]; then - gtest_ip_list="${gtest_ip_list}:$(do_get_ip 'eth' '' $gtest_ip_list)" + +if [[ -f /.dockerenv ]] || [[ -f /run/.containerenv ]] || [[ -n "${KUBERNETES_SERVICE_HOST}" ]]; then + gtest_opt="--addr=$(ip -f inet addr show net1 | awk '/inet / {print $2}' | cut -d/ -f1):$(ip -f inet addr show net2 | awk '/inet / {print $2}' | cut -d/ -f1)" else - echo "[SKIP] two eth interfaces are required. found: ${gtest_ip_list}" - exit 0 + if [ ! -z $(do_get_ip 'eth') ]; then + gtest_ip_list="$(do_get_ip 'eth')" + fi + if [ ! -z $(do_get_ip 'eth' '' $gtest_ip_list) ]; then + gtest_ip_list="${gtest_ip_list}:$(do_get_ip 'eth' '' $gtest_ip_list)" + else + echo "[SKIP] two eth interfaces are required. found: ${gtest_ip_list}" + exit 0 + fi + gtest_opt="--addr=${gtest_ip_list}" fi -gtest_opt="--addr=${gtest_ip_list}" set +eE diff --git a/contrib/jenkins_tests/test.sh b/contrib/jenkins_tests/test.sh index 74abc461c..81aaf7996 100755 --- a/contrib/jenkins_tests/test.sh +++ b/contrib/jenkins_tests/test.sh @@ -2,17 +2,15 @@ source $(dirname $0)/globals.sh +# Fix hugepages for docker environments +do_hugepages + echo "Checking for test ..." if [ $(test -d ${install_dir} >/dev/null 2>&1 || echo $?) ]; then echo "[SKIP] Not found ${install_dir} : build should be done before this stage" exit 1 fi -if [ $(command -v ibdev2netdev >/dev/null 2>&1 || echo $?) ]; then - echo "[SKIP] ibdev2netdev tool does not exist" - exit 0 -fi - cd $WORKSPACE rm -rf $test_dir @@ -46,52 +44,8 @@ test_ip_list="" test_list="tcp-pp tcp-tp tcp-ul" test_lib=$install_dir/lib/${prj_lib} -if [ ! -z "${test_remote_ip}" ] ; then - [[ "${test_remote_ip}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || {\ - echo ">> FAIL wrong ip address ${test_remote_ip}" - exit 1 - } - test_ip_list="eth:${test_remote_ip}" - [ -z "${NODE_NAME}" ] && NODE_NAME=${HOSTNAME} - sperf_exec_dir="/tmp/sockperf_exec_${NODE_NAME}" - rmt_user=root - - rmt_os=$(${sudo_cmd} ssh ${rmt_user}@${test_remote_ip} ". /etc/os-release ; echo \${NAME,,} | awk '{print \$1}'") - [ ! -z "${test_remote_rebuild}" ] && rmt_os="rebuld" - local_os=$(. /etc/os-release ; echo ${NAME,,} | awk '{print $1}') - - #skip_remote_prep=1 - if [ -z "${skip_remote_prep}" ] ; then - ${sudo_cmd} ssh ${rmt_user}@${test_remote_ip} "rm -rf ${sperf_exec_dir} && mkdir ${sperf_exec_dir}" - - if [[ "${rmt_os}" =~ .*"${local_os}".* ]] ; then - ${sudo_cmd} scp -q ${test_app} ${rmt_user}@${test_remote_ip}:${sperf_exec_dir} - ${sudo_cmd} scp -q ${test_lib} ${rmt_user}@${test_remote_ip}:${sperf_exec_dir} - eval "pid=$(${sudo_cmd} ssh ${rmt_user}@${test_remote_ip} pidof ${prj_service})" - if [ ! -z "${pid}" ] ; then - echo "${prj_service} pid=${pid}" - eval "${sudo_cmd} ssh ${rmt_user}@${test_remote_ip} kill -9 ${pid}" - fi - ${sudo_cmd} scp -q ${install_dir}/sbin/${prj_service} ${rmt_user}@${test_remote_ip}:${sperf_exec_dir} - eval "${sudo_cmd} ssh ${rmt_user}@${test_remote_ip} ${sudo_cmd} ${sperf_exec_dir}/${prj_service} &" - else - ${sudo_cmd} -E rsync -q -I -a -r --exclude jenkins --exclude '*.o' --exclude '.deps' --exclude '*.l*' \ - -e ssh ${WORKSPACE} ${rmt_user}@${test_remote_ip}:${sperf_exec_dir} - ${sudo_cmd} scp -q ${test_dir}/sockperf_v2.zip ${rmt_user}@${test_remote_ip}:${sperf_exec_dir} - if [ $? -eq 0 ] ; then - subdir=${WORKSPACE##*/} - cmd="cd ${sperf_exec_dir}/${subdir} && " - cmd+="./autogen.sh && ./configure && make ${make_opt} && " - cmd+="cp src/vma/.libs/*.so ${sperf_exec_dir} &&" - cmd+="cd ${sperf_exec_dir} && " - cmd+="unzip sockperf_v2.zip && cd sockperf-sockperf_v2 && " - cmd+="./autogen.sh && ./configure && make ${make_opt} && cp sockperf ${sperf_exec_dir}" - ${sudo_cmd} ssh ${rmt_user}@${test_remote_ip} "${cmd}" - else - exit 1 - fi - fi - fi +if [[ -f /.dockerenv ]] || [[ -f /run/.containerenv ]] || [[ -n "${KUBERNETES_SERVICE_HOST}" ]]; then + test_ip_list="eth_ip4:$(ip -f inet addr show net1 | awk '/inet / {print $2}' | cut -d/ -f1)" else if [ ! -z $(do_get_ip 'ib') ]; then test_ip_list="${test_ip_list} ib:$(do_get_ip 'ib')" @@ -101,6 +55,14 @@ else fi fi +if [ "$test_ip_list" == "eth_ip4: eth_ip6:" ] || [ -z "${test_ip_list}" ]; then + echo "ERROR: Cannot get IPv4/6 address of net1 interface!" + exit 1 +fi + +# start the ssh server as verifyer.pl requiers +/etc/init.d/ssh start + nerrors=0 for test_link in $test_ip_list; do @@ -109,34 +71,10 @@ for test_link in $test_ip_list; do test_name=${test_in}-${test} test_tap=${WORKSPACE}/${prefix}/test-${test_name}.tap - if [ ! -z "${test_remote_ip}" ] ; then - - eval "pid=$(${sudo_cmd} pidof ${prj_service})" - [ ! -z "${pid}" ] && eval "${sudo_cmd} kill -9 ${pid}" - eval "${sudo_cmd} ${install_dir}/sbin/${prj_service} --console -v5 & " - - echo "BUILD_NUMBER=${BUILD_NUMBER}" - eval "pid=$(${sudo_cmd} ssh ${rmt_user}@${test_remote_ip} pidof ${prj_service})" - if [ ! -z "${pid}" ] ; then - echo "${prj_service} pid=${pid}" - eval "${sudo_cmd} ssh ${rmt_user}@${test_remote_ip} kill -9 ${pid}" - fi - ${sudo_cmd} scp -q ${install_dir}/sbin/${prj_service} ${rmt_user}@${test_remote_ip}:${sperf_exec_dir} - eval "${sudo_cmd} ssh ${rmt_user}@${test_remote_ip} ${sudo_cmd} ${sperf_exec_dir}/${prj_service} &" - - vutil="$(dirname $0)/vutil.sh" - [ ! -e "${vutil}" ] && { echo "error vutil not found" ; exit 1 ; } - - ${sudo_cmd} $timeout_exe ${vutil} -a "${test_app}" -x "--load-vma=${test_lib} " -t "${test}:tc[1-9]$" \ - -s "${test_remote_ip}" -p "${test_remote_port}" -l "${test_dir}/${test_name}.log" \ - -e "VMA_TX_BUFS=20000 VMA_RX_BUFS=20000" - - else - ${sudo_cmd} $timeout_exe $PWD/tests/verifier/verifier.pl -a ${test_app} -x " --load-vma=$test_lib " \ - -t ${test}:tc[1-9]$ -s ${test_ip} -l ${test_dir}/${test_name}.log \ - -e " VMA_TX_BUFS=20000 VMA_RX_BUFS=20000 " \ - --progress=0 - fi + ${sudo_cmd} $timeout_exe $PWD/tests/verifier/verifier.pl -a ${test_app} -x " --load-vma=$test_lib " \ + -t ${test}:tc[1-9]$ -s ${test_ip} -l ${test_dir}/${test_name}.log \ + -e " VMA_TX_BUFS=20000 VMA_RX_BUFS=20000 "\ + --progress=0 cp $PWD/${test_name}.dump ${test_dir}/${test_name}.dump grep -e 'PASS' -e 'FAIL' ${test_dir}/${test_name}.dump > ${test_dir}/${test_name}.tmp diff --git a/contrib/jenkins_tests/vg.sh b/contrib/jenkins_tests/vg.sh index af4c4c9b8..897f52591 100755 --- a/contrib/jenkins_tests/vg.sh +++ b/contrib/jenkins_tests/vg.sh @@ -2,9 +2,10 @@ source $(dirname $0)/globals.sh -echo "Checking for valgrind ..." +# Fix hugepages for docker environments +do_hugepages -#do_module "tools/valgrind-3.12.0" +echo "Checking for valgrind ..." set +eE @@ -24,9 +25,14 @@ test_ip_list="" #if [ ! -z $(do_get_ip 'ib') ]; then # test_ip_list="${test_ip_list} ib:$(do_get_ip 'ib')" #fi -if [ ! -z "$(do_get_ip 'eth')" ]; then - test_ip_list="${test_ip_list} eth_ip4:$(do_get_ip 'eth')" +if [[ -f /.dockerenv ]] || [[ -f /run/.containerenv ]] || [[ -n "${KUBERNETES_SERVICE_HOST}" ]]; then + test_ip_list="eth_ip4:$(ip -f inet addr show net1 | awk '/inet / {print $2}' | cut -d/ -f1)" +else + if [ ! -z "$(do_get_ip 'eth')" ]; then + test_ip_list="${test_ip_list} eth_ip4:$(do_get_ip 'eth')" + fi fi + test_list="tcp:--tcp udp:" test_lib=${vg_dir}/install/lib/${prj_lib} test_app=sockperf diff --git a/tests/gtest/tcp/tcp_bind.cc b/tests/gtest/tcp/tcp_bind.cc index 946047727..ec772d4b5 100644 --- a/tests/gtest/tcp/tcp_bind.cc +++ b/tests/gtest/tcp/tcp_bind.cc @@ -70,6 +70,7 @@ TEST_F(tcp_bind, ti_1) { * @details */ TEST_F(tcp_bind, ti_2) { + GTEST_SKIP() << "Skipping this test temporarily;Please see Issue #4332286."; int rc = EOK; int fd; diff --git a/tests/gtest/tcp/tcp_event.cc b/tests/gtest/tcp/tcp_event.cc index c65288624..ea73726a5 100644 --- a/tests/gtest/tcp/tcp_event.cc +++ b/tests/gtest/tcp/tcp_event.cc @@ -64,6 +64,7 @@ TEST_F(tcp_event, DISABLED_ti_1) { } TEST_F(tcp_event, ti_2) { + GTEST_SKIP() << "Skipping this test temporarily;Please see Issue #4332286."; int rc = EOK; int fd; struct epoll_event event; diff --git a/tests/gtest/udp/udp_bind.cc b/tests/gtest/udp/udp_bind.cc index 88a4857a5..8d5dfb7c3 100644 --- a/tests/gtest/udp/udp_bind.cc +++ b/tests/gtest/udp/udp_bind.cc @@ -70,6 +70,7 @@ TEST_F(udp_bind, ti_1) { * @details */ TEST_F(udp_bind, ti_2) { + GTEST_SKIP() << "Skipping this test temporarily;Please see Issue #4332286."; int rc = EOK; int fd; diff --git a/tests/gtest/udp/udp_connect.cc b/tests/gtest/udp/udp_connect.cc index af0857ac5..8172d4ab0 100644 --- a/tests/gtest/udp/udp_connect.cc +++ b/tests/gtest/udp/udp_connect.cc @@ -84,6 +84,7 @@ TEST_F(udp_connect, ti_1) { * @details */ TEST_F(udp_connect, ti_2) { + GTEST_SKIP() << "Skipping this test temporarily;Please see Issue #4332286."; int rc = EOK; int fd; int i;