From 9e0a0f0f32708c5cf57f058e894f9caae31056eb Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 14 Mar 2024 00:59:57 +0800 Subject: [PATCH] Check whether required tests are executed. (#19884) ### Description Check the onnx node tests and model tests worked ### Motivation and Context onnx node test data and model data are mount in one dir. And onnxruntime_test_all search the dir and load the data. If the dir does exist or there's some change in onnxruntime_test_all, those tests may not be executed. For example, all onnx node test data is 32M. It's hardly for us aware of the regression. So I add the simple check to ensure those tests are executed. --------- Co-authored-by: Yi Zhang --- .../azure-pipelines/linux-ci-pipeline.yml | 9 +++++++-- .../azure-pipelines/linux-gpu-ci-pipeline.yml | 4 ++++ .../templates/check_test_result.yml | 20 +++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tools/ci_build/github/azure-pipelines/templates/check_test_result.yml diff --git a/tools/ci_build/github/azure-pipelines/linux-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/linux-ci-pipeline.yml index 02147c321fab3..82e571bf6519f 100644 --- a/tools/ci_build/github/azure-pipelines/linux-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/linux-ci-pipeline.yml @@ -86,7 +86,7 @@ stages: -e NIGHTLY_BUILD \ -e BUILD_BUILDNUMBER \ onnxruntimecpubuildcentos8x64 \ - /bin/bash -c " + /bin/bash -c ' set -ex; \ python3.9 /onnxruntime_src/tools/ci_build/build.py \ --build_dir /build --cmake_generator 'Ninja' \ @@ -105,7 +105,8 @@ stages: --parallel --use_binskim_compliant_compile_flags \ --build_csharp \ --enable_onnx_tests --enable_address_sanitizer \ - --test;" + --test; + ' workingDirectory: $(Build.SourcesDirectory) - task: PublishTestResults@2 @@ -285,6 +286,10 @@ stages: " displayName: 'Run Release tests and symbolic shape infer test' + - template: templates/check_test_result.yml + parameters: + FileName: '$(Build.BinariesDirectory)/Release/onnxruntime_test_all.Release.results.xml' + - task: PublishTestResults@2 displayName: 'Publish unit test results' inputs: diff --git a/tools/ci_build/github/azure-pipelines/linux-gpu-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/linux-gpu-ci-pipeline.yml index 165bd804a8ad5..78ee0e1a318e4 100644 --- a/tools/ci_build/github/azure-pipelines/linux-gpu-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/linux-gpu-ci-pipeline.yml @@ -265,4 +265,8 @@ stages: ' displayName: 'Run Tests' + - template: templates/check_test_result.yml + parameters: + FileName: '$(Build.BinariesDirectory)/Release/onnxruntime_test_all.Release.results.xml' + - template: templates/clean-agent-build-directory-step.yml diff --git a/tools/ci_build/github/azure-pipelines/templates/check_test_result.yml b/tools/ci_build/github/azure-pipelines/templates/check_test_result.yml new file mode 100644 index 0000000000000..1a68d415c44d6 --- /dev/null +++ b/tools/ci_build/github/azure-pipelines/templates/check_test_result.yml @@ -0,0 +1,20 @@ +parameters: +- name: FileName + type: string + +steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.x' + addToPath: true + architecture: 'x64' + + - task: PythonScript@0 + displayName: 'Check test result yml' + inputs: + scriptSource: 'inline' + script: | + with open('${{parameters.FileName}}', 'r') as file: + content = file.read() + assert 'data_onnx_opset' in content, "operator test not found in test result file" + assert 'models_zoo_opset' in content, "models_zoo model not found in test reuslt file"