Unverified Commit 204d10d5 authored by Nate Mailhot's avatar Nate Mailhot Committed by GitHub
Browse files

fix: change pytest result artifact upload name to include job id and workf… (#4744)

parent 1645884d
...@@ -77,23 +77,31 @@ runs: ...@@ -77,23 +77,31 @@ runs:
fi fi
fi fi
# Run without --rm so we can copy results even if container crashes (example SIGSEGV exit 139) # Get absolute path for test-results directory and ensure it has proper permissions
docker run ${GPU_FLAGS} -w /workspace \ TEST_RESULTS_DIR="$(pwd)/test-results"
chmod 777 "${TEST_RESULTS_DIR}"
echo "📁 Test results will be saved to: ${TEST_RESULTS_DIR}"
docker run ${GPU_FLAGS} --rm -w /workspace \
--cpus=${NUM_CPUS} \ --cpus=${NUM_CPUS} \
--network host \ --network host \
--name ${{ env.CONTAINER_ID }}_pytest \ --name ${{ env.CONTAINER_ID }}_pytest \
-v "${TEST_RESULTS_DIR}:/workspace/test-results" \
${{ inputs.image_tag }} \ ${{ inputs.image_tag }} \
bash -c "mkdir -p /workspace/test-results && ${PYTEST_CMD}" bash -c "${PYTEST_CMD}"
TEST_EXIT_CODE=$? TEST_EXIT_CODE=$?
echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> $GITHUB_ENV echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> $GITHUB_ENV
echo "🧪 Tests completed with exit code: ${TEST_EXIT_CODE}" echo "🧪 Tests completed with exit code: ${TEST_EXIT_CODE}"
# Copy test results from container to host # Verify test results were written (only in normal mode)
docker cp ${{ env.CONTAINER_ID }}_pytest:/workspace/test-results . || echo "Failed to copy test results" if [[ "${{ inputs.dry_run }}" != "true" ]]; then
if [[ -f "${TEST_RESULTS_DIR}/${{ env.PYTEST_XML_FILE }}" ]]; then
# Clean up container echo "✅ Test results file found: ${TEST_RESULTS_DIR}/${{ env.PYTEST_XML_FILE }}"
docker rm -f ${{ env.CONTAINER_ID }}_pytest || echo "Failed to clean up container" else
echo "⚠️ Test results file not found: ${TEST_RESULTS_DIR}/${{ env.PYTEST_XML_FILE }}"
fi
fi
# Always continue to results processing # Always continue to results processing
exit 0 exit 0
...@@ -107,13 +115,6 @@ runs: ...@@ -107,13 +115,6 @@ runs:
STR_TEST_TYPE=$(echo "${{ inputs.test_type }}" | tr ', ' '_') STR_TEST_TYPE=$(echo "${{ inputs.test_type }}" | tr ', ' '_')
echo "STR_TEST_TYPE=${STR_TEST_TYPE}" >> $GITHUB_ENV echo "STR_TEST_TYPE=${STR_TEST_TYPE}" >> $GITHUB_ENV
# Skip XML processing if in dry-run mode
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
echo "✅ Dry-run mode: Test collection completed"
echo "⏭️ No JUnit XML generated (dry-run mode)"
exit 0
fi
# Check for JUnit XML file and determine test status # Check for JUnit XML file and determine test status
JUNIT_FILE="test-results/pytest_test_report.xml" JUNIT_FILE="test-results/pytest_test_report.xml"
...@@ -125,23 +126,9 @@ runs: ...@@ -125,23 +126,9 @@ runs:
ERROR_TESTS=$(grep -o 'errors="[0-9]*"' "$JUNIT_FILE" | grep -o '[0-9]*' | head -1 || echo "0") ERROR_TESTS=$(grep -o 'errors="[0-9]*"' "$JUNIT_FILE" | grep -o '[0-9]*' | head -1 || echo "0")
echo "📊 ${TOTAL_TESTS} tests completed (${FAILED_TESTS} failed, ${ERROR_TESTS} errors)" echo "📊 ${TOTAL_TESTS} tests completed (${FAILED_TESTS} failed, ${ERROR_TESTS} errors)"
# Create uniquely named metadata file with step context information
# Use framework-testtype-arch to make it unique per test run
METADATA_FILE="test-results/test_metadata_${{ inputs.framework }}_${STR_TEST_TYPE}_${{ inputs.platform_arch }}.json"
JUNIT_NAME="pytest_test_report_${{ inputs.framework }}_${STR_TEST_TYPE}_${{ inputs.platform_arch }}.xml"
# Rename XML file to unique name # Rename XML file to unique name
JUNIT_NAME="pytest_test_report_${{ inputs.framework }}_${STR_TEST_TYPE}_${{ inputs.platform_arch }}_${{ github.run_id }}_${{ job.check_run_id }}.xml"
mv "$JUNIT_FILE" "test-results/$JUNIT_NAME" mv "$JUNIT_FILE" "test-results/$JUNIT_NAME"
echo '{' > "$METADATA_FILE"
echo ' "job_name": "${{ github.job }}",' >> "$METADATA_FILE"
echo ' "framework": "${{ inputs.framework }}",' >> "$METADATA_FILE"
echo ' "test_type": "${{ inputs.test_type }}",' >> "$METADATA_FILE"
echo ' "platform_arch": "${{ inputs.platform_arch }}",' >> "$METADATA_FILE"
echo ' "junit_xml_file": "'"$JUNIT_NAME"'",' >> "$METADATA_FILE"
echo ' "step_name": "Run ${{ inputs.test_type }} tests"' >> "$METADATA_FILE"
echo '}' >> "$METADATA_FILE"
echo "📝 Created test metadata file: $METADATA_FILE"
echo "📝 Renamed XML file to: $JUNIT_NAME" echo "📝 Renamed XML file to: $JUNIT_NAME"
else else
echo "⚠️ JUnit XML file not found - test results may not be available for upload" echo "⚠️ JUnit XML file not found - test results may not be available for upload"
...@@ -155,10 +142,8 @@ runs: ...@@ -155,10 +142,8 @@ runs:
- name: Upload Test Results - name: Upload Test Results
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
if: always() && inputs.dry_run != 'true' # Skip upload in dry-run mode if: always() # Always upload test results, even if tests failed
with: with:
name: test-results-${{ inputs.framework }}-${{ env.STR_TEST_TYPE }}-${{ env.PLATFORM_ARCH }} name: test-results-${{ inputs.framework }}-${{ env.STR_TEST_TYPE }}-${{ env.PLATFORM_ARCH }}-${{ github.run_id }}-${{ job.check_run_id }}
path: | path: test-results/pytest_test_report_${{ inputs.framework }}_${{ env.STR_TEST_TYPE }}_${{ inputs.platform_arch }}_${{ github.run_id }}_${{ job.check_run_id }}.xml
test-results/pytest_test_report_${{ inputs.framework }}_${{ env.STR_TEST_TYPE }}_${{ inputs.platform_arch }}.xml
test-results/test_metadata_${{ inputs.framework }}_${{ env.STR_TEST_TYPE }}_${{ inputs.platform_arch }}.json
retention-days: 7 retention-days: 7
...@@ -419,6 +419,7 @@ jobs: ...@@ -419,6 +419,7 @@ jobs:
export KUBECONFIG=$(pwd)/.kubeconfig export KUBECONFIG=$(pwd)/.kubeconfig
kubectl config set-context --current --namespace=$NAMESPACE kubectl config set-context --current --namespace=$NAMESPACE
- name: Run Fault Tolerance Tests - name: Run Fault Tolerance Tests
id: run-ft-tests
run: | run: |
set -x set -x
export KUBECONFIG=$(pwd)/.kubeconfig export KUBECONFIG=$(pwd)/.kubeconfig
...@@ -440,14 +441,49 @@ jobs: ...@@ -440,14 +441,49 @@ jobs:
pip install -r container/deps/requirements.test.txt pip install -r container/deps/requirements.test.txt
pip install kubernetes==32.0.1 kubernetes_asyncio kr8s pyyaml requests tabulate pydantic pip install kubernetes==32.0.1 kubernetes_asyncio kr8s pyyaml requests tabulate pydantic
# Run the pytest command (tests orchestrate K8s, don't need dynamo package) # Create test-results directory
mkdir -p test-results
# Run the pytest command with JUnit XML output
set +e # Don't exit on test failures
pytest tests/fault_tolerance/deploy/test_deployment.py \ pytest tests/fault_tolerance/deploy/test_deployment.py \
-m 'k8s and fault_tolerance' \ -m 'k8s and fault_tolerance' \
-k '${{ matrix.framework.test_scenario }}' \ -k '${{ matrix.framework.test_scenario }}' \
-s -v \ -s -v \
--namespace ${NAMESPACE} \ --namespace ${NAMESPACE} \
--image ${IMAGE} \ --image ${IMAGE} \
--client-type legacy --client-type legacy \
--junitxml=test-results/pytest_ft_report.xml \
--tb=short
TEST_EXIT_CODE=$?
echo "TEST_EXIT_CODE=${TEST_EXIT_CODE}" >> $GITHUB_ENV
echo "🧪 Fault tolerance tests completed with exit code: ${TEST_EXIT_CODE}"
exit ${TEST_EXIT_CODE}
continue-on-error: true
- name: Process Fault Tolerance Test Results
if: always()
run: |
set -x
# Rename JUnit XML with unique naming if it exists
if [ -f "test-results/pytest_ft_report.xml" ]; then
mv "test-results/pytest_ft_report.xml" "test-results/pytest_ft_report_${{ matrix.framework.name }}_amd64_${{ github.run_id }}_${{ job.check_run_id }}.xml"
echo "✅ JUnit XML report renamed with unique identifier"
else
echo "⚠️ JUnit XML report not found"
fi
- name: Upload Fault Tolerance Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.framework.name }}-fault_tolerance-amd64-${{ github.run_id }}-${{ job.check_run_id }}
path: test-results/pytest_ft_report_${{ matrix.framework.name }}_amd64_${{ github.run_id }}_${{ job.check_run_id }}.xml
retention-days: 7
- name: Cleanup - name: Cleanup
if: always() if: always()
timeout-minutes: 5 timeout-minutes: 5
...@@ -640,6 +676,7 @@ jobs: ...@@ -640,6 +676,7 @@ jobs:
kubectl config set-context --current --namespace=$NAMESPACE --kubeconfig "${KUBECONFIG}" kubectl config set-context --current --namespace=$NAMESPACE --kubeconfig "${KUBECONFIG}"
kubectl config get-contexts kubectl config get-contexts
- name: Run Tests - name: Run Tests
id: run-tests
env: env:
NAMESPACE: ${{ needs.deploy-operator.outputs.NAMESPACE }} NAMESPACE: ${{ needs.deploy-operator.outputs.NAMESPACE }}
run: | run: |
...@@ -647,6 +684,9 @@ jobs: ...@@ -647,6 +684,9 @@ jobs:
export KUBECONFIG=$(pwd)/.kubeconfig export KUBECONFIG=$(pwd)/.kubeconfig
kubectl config set-context --current --namespace=$NAMESPACE kubectl config set-context --current --namespace=$NAMESPACE
# Redirect all output to a log file while still showing it
exec > >(tee -a test-output.log) 2>&1
cd examples/backends/$FRAMEWORK cd examples/backends/$FRAMEWORK
export FRAMEWORK_RUNTIME_IMAGE="${{ secrets.AZURE_ACR_HOSTNAME }}/ai-dynamo/dynamo:${{ github.sha }}-${FRAMEWORK}-amd64" export FRAMEWORK_RUNTIME_IMAGE="${{ secrets.AZURE_ACR_HOSTNAME }}/ai-dynamo/dynamo:${{ github.sha }}-${FRAMEWORK}-amd64"
export KUBE_NS=$NAMESPACE export KUBE_NS=$NAMESPACE
...@@ -739,6 +779,32 @@ jobs: ...@@ -739,6 +779,32 @@ jobs:
echo "Test passed: Response matches expected format and content" echo "Test passed: Response matches expected format and content"
fi fi
exit $TEST_RESULT exit $TEST_RESULT
continue-on-error: true
- name: Process Deployment Test Results
if: always()
run: |
set -x
# Create test-results directory
mkdir -p test-results
# Copy and rename the test output log with unique naming
if [ -f "test-output.log" ]; then
cp test-output.log "test-results/deploy_test_output_${{ env.FRAMEWORK }}_${{ matrix.profile }}_amd64_${{ github.run_id }}_${{ job.check_run_id }}.log"
echo "✅ Test output log copied to test-results/"
else
echo "⚠️ test-output.log not found"
fi
- name: Upload Deployment Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ env.FRAMEWORK }}-deploy-${{ matrix.profile }}-amd64-${{ github.run_id }}-${{ job.check_run_id }}
path: test-results/deploy_test_output_${{ env.FRAMEWORK }}_${{ matrix.profile }}_amd64_${{ github.run_id }}_${{ job.check_run_id }}.log
retention-days: 7
- name: Cleanup - name: Cleanup
if: always() if: always()
timeout-minutes: 5 timeout-minutes: 5
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment