From 7e34975c97c544471d192f0463d42510a2638caa Mon Sep 17 00:00:00 2001 From: Hoooao Date: Wed, 11 Oct 2023 10:33:28 -0400 Subject: [PATCH] Merged simplified procedure changed log_dir to default for collection add_on_miss only testgen on Add logs ci to main --- .github/workflows/PTF-TEST.yml | 111 ------------------ .github/workflows/ci-dpdk-ptf-tests.yml | 20 +++- backends/dpdk/run-dpdk-ptf-test.py | 40 ++++--- .../testgen/targets/pna/test/P4Tests.cmake | 5 +- .../targets/pna/test/TestTemplate.cmake | 4 +- 5 files changed, 47 insertions(+), 133 deletions(-) delete mode 100644 .github/workflows/PTF-TEST.yml diff --git a/.github/workflows/PTF-TEST.yml b/.github/workflows/PTF-TEST.yml deleted file mode 100644 index 7e44d9a9daf..00000000000 --- a/.github/workflows/PTF-TEST.yml +++ /dev/null @@ -1,111 +0,0 @@ -name: "PTF-backend" -# This is just a temporary workflow to test the PTF backend -# Will be merged to ci-dpdk-ptf-tests.yml once it is ready -# Note: Cache is set to 5gb, should be 1gb once the PTF backend is ready -on: - push: - branches: - - ptf-test-pr - pull_request: - branches: - - ptf-test-pr - -concurrency: - # if workflow for PR or push is already running stop it, and start new one - group: p4c_ptf-test-${{ github.ref }} - cancel-in-progress: true - -env: - SDE: ${{ github.workspace }} - P4C_DIR: ${{ github.workspace }}/p4c - SDE_INSTALL: ${{ github.workspace }}/sde_install - IPDK_RECIPE: ${{ github.workspace }}/ipdk.recipe - DEPEND_INSTALL: /usr/local - -jobs: - build_p4dpdk_ubuntu: - runs-on: ubuntu-22.04 - steps: - - name: 'ccache' - uses: hendrikmuhs/ccache-action@v1 - with: - key: ptf-${{ runner.os }}-test - max-size: 5000M - - - name: 'Checkout DPDK-target' - uses: actions/checkout@v3 - with: - repository: p4lang/p4-dpdk-target - path: p4sde - submodules: 'recursive' - - - name: 'Checkout ipdk-recipe' - uses: actions/checkout@v3 - with: - repository: ipdk-io/networking-recipe - path: ipdk.recipe - submodules: 'recursive' - - - name: checkout P4C - uses: actions/checkout@v3 - with: - path: p4c - submodules: recursive - - - name: 'Install DPDK dependencies' - working-directory: p4sde/tools/setup - run: | - sudo apt update -y - python install_dep.py - - name: 'Compile p4sde dpdk target' - working-directory: p4sde - run: | - mkdir ${GITHUB_WORKSPACE}/install - ./autogen.sh - ./configure --prefix=$SDE_INSTALL - make - make install - - name: 'Build infrap4d dependencies' - working-directory: ipdk.recipe - run: | - echo "Install infrap4d dependencies" - sudo apt install libatomic1 libnl-route-3-dev openssl - sudo pip3 install -r requirements.txt - cd $IPDK_RECIPE/setup - echo "Build infrap4d dependencies" - cmake -B build -DCMAKE_INSTALL_PREFIX="$DEPEND_INSTALL" -DUSE_SUDO=ON - cmake --build build - - name: 'Build infrap4d' - working-directory: ipdk.recipe - run: | - sudo ./make-all.sh --target=dpdk --no-krnlmon --no-ovs -S $SDE_INSTALL -D $DEPEND_INSTALL - - name: 'Build p4c with only the DPDK backend' - working-directory: p4c - run: | - sudo -E tools/dpdk-ci-build.sh $P4C_DIR $IPDK_RECIPE $SDE_INSTALL $DEPEND_INSTALL - - name: 'Run DPDK PTF tests' - continue-on-error: true - working-directory: p4c/build - run: | - sudo $IPDK_RECIPE/install/sbin/copy_config_files.sh $IPDK_RECIPE/install $SDE_INSTALL - sudo $IPDK_RECIPE/install/sbin/set_hugepages.sh - sudo -E ctest --output-on-failure --schedule-random -R testgen-p4c-pna-ptf -V - - - name: 'Get ERROR log' - continue-on-error: true - working-directory: /var/log/stratum - run: | - cat *ERROR - - - name: 'Get INFO log' - continue-on-error: true - working-directory: /var/log/stratum - run: | - cat *INFO - - - name: 'Get WARNING log' - continue-on-error: true - working-directory: /var/log/stratum - run: | - cat *WARNING - diff --git a/.github/workflows/ci-dpdk-ptf-tests.yml b/.github/workflows/ci-dpdk-ptf-tests.yml index 6ba464c4319..60e6e75a050 100644 --- a/.github/workflows/ci-dpdk-ptf-tests.yml +++ b/.github/workflows/ci-dpdk-ptf-tests.yml @@ -105,4 +105,22 @@ jobs: working-directory: p4c/build run: | sudo $IPDK_INSTALL_DIR/sbin/set_hugepages.sh - sudo -E ctest --output-on-failure --schedule-random -R dpdk-ptf* + sudo -E ctest --output-on-failure --schedule-random -R testgen-p4c-pna-ptf -V + + - name: 'Get ERROR log' + continue-on-error: true + working-directory: /var/log/stratum + run: | + cat *ERROR + + - name: 'Get INFO log' + continue-on-error: true + working-directory: /var/log/stratum + run: | + cat *INFO + + - name: 'Get WARNING log' + continue-on-error: true + working-directory: /var/log/stratum + run: | + cat *WARNING diff --git a/backends/dpdk/run-dpdk-ptf-test.py b/backends/dpdk/run-dpdk-ptf-test.py index 0ce2178a702..060b83a3ad1 100755 --- a/backends/dpdk/run-dpdk-ptf-test.py +++ b/backends/dpdk/run-dpdk-ptf-test.py @@ -81,6 +81,8 @@ def is_port_alive(ns, port) -> bool: command = f"sudo ip netns exec {ns} netstat -tuln" out, _ = testutils.exec_process(command, timeout=10, capture_output=True) + if not out: + return False if str(port) in out: return True return False @@ -202,6 +204,7 @@ def run_infrap4d( f"{self.options.ipdk_install_dir}/sbin/infrap4d " f"-grpc_open_insecure_mode={insecure_mode} " f"-log_dir={log_dir} " + f"-detach=false " f"-dpdk_sde_install={options.ipdk_install_dir} " f"-dpdk_infrap4d_cfg={options.ipdk_install_dir}/share/stratum/dpdk/dpdk_skip_p4.conf " f"-chassis_config_file={options.ipdk_install_dir}/share/stratum/dpdk/dpdk_port_config.pb.txt " @@ -214,6 +217,18 @@ def run_infrap4d( cnt += 1 testutils.log.info("Cannot connect to Infrap4d: " + str(cnt) + " try") if not is_port_alive(self.bridge.ns_name, GRPC_PORT): + # Print the log files. + error_file = log_dir.joinpath("infrap4d.ERROR") + if error_file.exists(): + testutils.log.error("######## Infrap4d Error ######## \n%s", error_file.read_text()) + info_file = log_dir.joinpath("infrap4d.INFO") + if info_file.exists(): + testutils.log.error("######## Infrap4d Info ######## \n%s", info_file.read_text()) + warning_file = log_dir.joinpath("infrap4d.WARNING") + if warning_file.exists(): + testutils.log.error( + "######## Infrap4d Warning ######## \n%s", warning_file.read_text() + ) return testutils.FAILURE return self.switch_proc @@ -235,16 +250,16 @@ def build_and_load_pipeline( # Load pipeline. # NOTE: in generated PTF tests, the pipelines are loaded in individual test cases. # This should be commented when working with Testgen. - command = ( - f"{self.options.ipdk_install_dir}/bin/p4rt-ctl " - "set-pipe br0 " - f"{conf_bin} " - f"{info_name} " - ) - returncode = self.bridge.ns_exec(command, timeout=30) - if returncode != testutils.SUCCESS: - testutils.log.error("Failed to load pipeline") - return returncode + # command = ( + # f"{self.options.ipdk_install_dir}/bin/p4rt-ctl " + # "set-pipe br0 " + # f"{conf_bin} " + # f"{info_name} " + # ) + # returncode = self.bridge.ns_exec(command, timeout=30) + # if returncode != testutils.SUCCESS: + # testutils.log.error("Failed to load pipeline") + # return returncode return testutils.SUCCESS def run_ptf(self, grpc_port: int, info_name, conf_bin) -> int: @@ -276,11 +291,6 @@ def run_test(options: Options) -> int: proc_env_vars["LD_LIBRARY_PATH"] += f"{options.ld_library_path}" else: proc_env_vars["LD_LIBRARY_PATH"] = f"{options.ld_library_path}" - if "PATH" in proc_env_vars: - proc_env_vars["PATH"] += f"{options.ipdk_install_dir}/bin" - else: - proc_env_vars["PATH"] = f"{options.ipdk_install_dir}/bin" - proc_env_vars["PATH"] += f"{options.ipdk_install_dir}/sbin" proc_env_vars["SDE_INSTALL"] = f"{options.ipdk_install_dir}" # Define the test environment and compile the P4 target diff --git a/backends/p4tools/modules/testgen/targets/pna/test/P4Tests.cmake b/backends/p4tools/modules/testgen/targets/pna/test/P4Tests.cmake index 1203791a2c2..f0645f5f14b 100644 --- a/backends/p4tools/modules/testgen/targets/pna/test/P4Tests.cmake +++ b/backends/p4tools/modules/testgen/targets/pna/test/P4Tests.cmake @@ -26,10 +26,9 @@ set(P4C_PNA_TEST_SUITES_P416 ${PNA_TESTS} ${CUSTOM_PNA_TESTS}) option(P4TOOLS_TESTGEN_PNA_TEST_METADATA "Run tests on the Metadata test back end" OFF) # check for infrap4d -find_program (INFRAP4D infrap4d - PATHS $ENV{IPDK_RECIPE} ) +find_program(INFRAP4D infrap4d PATHS ${IPDK_INSTALL_DIR}/sbin) # SDE_INSTALL is the path to the dpdk-target install directory -if(TRUE AND INFRAP4D AND DEFINED ENV{SDE_INSTALL}) +if(INFRAP4D AND EXISTS ${IPDK_INSTALL_DIR}) set(DPDK_ENV_SETUP TRUE) else() set(DPDK_ENV_SETUP FALSE) diff --git a/backends/p4tools/modules/testgen/targets/pna/test/TestTemplate.cmake b/backends/p4tools/modules/testgen/targets/pna/test/TestTemplate.cmake index 437cbe698e4..a19b1f831c3 100644 --- a/backends/p4tools/modules/testgen/targets/pna/test/TestTemplate.cmake +++ b/backends/p4tools/modules/testgen/targets/pna/test/TestTemplate.cmake @@ -22,9 +22,7 @@ macro(check_pna_with_ptf testfile testfolder p4test) file(APPEND ${testfile} "do\n") file(APPEND ${testfile} "\techo \"Found \${item}\"\n") file(APPEND ${testfile} "\t python3 ${__dpdk_runner} -tf \${item} ${P4C_SOURCE_DIR} \ - --ipdk-recipe=$ENV{IPDK_RECIPE} \ - --sde-install=$ENV{SDE_INSTALL} \ - --ld-library-path=$ENV{LD_LIBRARY_PATH} \ + --ipdk-install-dir=${IPDK_INSTALL_DIR} \ -ll=DEBUG ${p4test}\n") file(APPEND ${testfile} "done\n") endmacro(check_pna_with_ptf)