Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Update validation-tests.yml pipenv install issues #1080

Merged
merged 3 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/scripts/run_validation_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash

set +e

# Function to log messages to GitHub Actions
log_to_github() {
echo "$1" >>"$GITHUB_STEP_SUMMARY"
}

# Function to run a test and handle retries
run_test() {
local test=$1
local retries=$2
local test_port_p=$3
local test_port_r=$4
local start_time
local end_time
local duration

echo "::group::${test}"
start_time=$(date '+%s')
sudo --preserve-env python3 -m pipenv run pytest "${test}" --media=/mnt/media --build="../.." --nic="${test_port_p},${test_port_r}" --collect-only -q --no-summary

for retry in $(seq 1 "$retries"); do
echo "sudo --preserve-env python3 -m pipenv run pytest \"${test}\" --media=/mnt/media --build=\"../..\" --nic=\"${test_port_p},${test_port_r}\""
sudo --preserve-env python3 -m pipenv run pytest "${test}" --media=/mnt/media --build="../.." --nic="${test_port_p},${test_port_r}"
local result=$?
echo "RETRY: ${retry}"
[[ "$result" == "0" ]] && break
done

end_time=$(date '+%s')
duration=$((end_time - start_time))
local status="❌"
local suffix="[Err]"

if [[ "$result" == "0" ]]; then
status="✅"
suffix="[OK]"
TESTS_SUCCESS+=("${test}")
else
TESTS_FAIL+=("${test}")
fi

log_to_github "| ${status} | ${test} | $(date --date="@${start_time}" '+%d%m%y_%H%M%S') | $(date --date="@${end_time}" '+%d%m%y_%H%M%S') | ${duration}s | ${suffix} |"
echo "::endgroup::"
}

# Main script execution
echo "::group::pre-execution-summary"

# Export environment variables
export TEST_PORT_P="${TEST_PORT_P}"
export TEST_PORT_R="${TEST_PORT_R}"

SUMMARY_MAIN_HEADER="Starting "
# Collect tests to be executed
if [[ -n "${VALIDATION_TESTS_1}" ]]; then
SUMMARY_MAIN_HEADER="${SUMMARY_MAIN_HEADER} tests/${VALIDATION_TESTS_1}"
python3 -m pipenv run pytest "tests/${VALIDATION_TESTS_1}" --media=/mnt/media --build="../.." --nic="${TEST_PORT_P},${TEST_PORT_R}" --collect-only -q --no-summary >tests.log 2>&1
fi

if [[ -n "${VALIDATION_TESTS_2}" ]]; then
SUMMARY_MAIN_HEADER="${SUMMARY_MAIN_HEADER}, tests/${VALIDATION_TESTS_2}"
python3 -m pipenv run pytest "tests/${VALIDATION_TESTS_2}" --media=/mnt/media --build="../.." --nic="${TEST_PORT_P},${TEST_PORT_R}" --collect-only -q --no-summary >>tests.log 2>&1
fi

mapfile -t TESTS_INCLUDED_IN_EXECUTION < <(grep -v "collected in" tests.log)
NUMBER_OF_TESTS="${#TESTS_INCLUDED_IN_EXECUTION[@]}"
TESTS_FAIL=()
TESTS_SUCCESS=()

echo "${SUMMARY_MAIN_HEADER} tests (total ${NUMBER_OF_TESTS}) :rocket:"
echo "----------------------------------"
echo "Tests to be executed:"
echo "${TESTS_INCLUDED_IN_EXECUTION[@]}"

log_to_github "## ${SUMMARY_MAIN_HEADER} tests (total ${NUMBER_OF_TESTS}) :rocket:"
log_to_github "| ❌/✅ | Collected Test | Started | Ended | Took (s) | Result |"
log_to_github "| --- | --- | --- | --- | --- | --- |"
echo "::endgroup::"

# Execute each test
for test in "${TESTS_INCLUDED_IN_EXECUTION[@]}"; do
run_test "$test" "$PYTEST_RETRIES" "$TEST_PORT_P" "$TEST_PORT_R"
done

# Summary of test results
log_to_github "### Total success ${#TESTS_SUCCESS[@]}/${NUMBER_OF_TESTS}:"
log_to_github "${TESTS_SUCCESS[@]}"
log_to_github "### Total failed ${#TESTS_FAIL[@]}/${NUMBER_OF_TESTS}:"
log_to_github "${TESTS_FAIL[@]}"

# Determine exit status
if [[ "${#TESTS_FAIL[@]}" == "0" ]] || [[ "${VALIDATION_NO_FAIL_TESTS}" == "true" ]]; then
exit 0
else
exit 1
fi
8 changes: 6 additions & 2 deletions .github/workflows/gtest-bare-metal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ env:
# Customize the env if
BUILD_TYPE: 'Release'
DPDK_VERSION: '23.11'
DPDK_REBUILD: 'false'
# Bellow ENV variables are required to be defined on runner side:
# TEST_PF_PORT_P: '0000:49:00.0'
# TEST_PF_PORT_R: '0000:49:00.1'
Expand Down Expand Up @@ -71,6 +72,7 @@ jobs:
ref: '${{ inputs.branch-to-checkout || github.head_ref || github.ref }}'

- name: Checkout DPDK
if: env.DPDK_REBUILD == 'true'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: 'DPDK/dpdk'
Expand All @@ -83,10 +85,12 @@ jobs:
sudo apt-get install -y systemtap-sdt-dev

- name: Apply dpdk patches
if: env.DPDK_REBUILD == 'true'
run: |
patch -d "dpdk" -p1 -i <(cat patches/dpdk/${{ env.DPDK_VERSION }}/*.patch)

- name: Build dpdk
if: env.DPDK_REBUILD == 'true'
run: |
cd dpdk
meson build
Expand Down Expand Up @@ -119,8 +123,8 @@ jobs:
- name: Binding network adapter
run: |
sudo ./script/nicctl.sh create_vf "${TEST_PF_PORT_P}" || true
sudo ./dpdk/usertools/dpdk-devbind.py -b vfio-pci "${TEST_DMA_PORT_P}" || true
sudo ./dpdk/usertools/dpdk-devbind.py -b vfio-pci "${TEST_DMA_PORT_R}" || true
sudo dpdk-devbind.py -b vfio-pci "${TEST_DMA_PORT_P}" || true
sudo dpdk-devbind.py -b vfio-pci "${TEST_DMA_PORT_R}" || true

- name: Start MtlManager at background
run: |
Expand Down
Loading