From d1a1c93b9e50e3e0b2ab75c3c95472b5d4742903 Mon Sep 17 00:00:00 2001 From: Runming Wu Date: Thu, 23 Jun 2022 16:19:22 -0700 Subject: [PATCH] Run individule pytests instead of running all pytests at once. Change-Id: Ibe02f3fe47846c89c50da1d8e97a78739c2275f8 --- .../test-docker-sonic-vs-template.yml | 23 ++++++++++++++----- tests/gcov_support.sh | 6 ----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.azure-pipelines/test-docker-sonic-vs-template.yml b/.azure-pipelines/test-docker-sonic-vs-template.yml index 83fd36dc09c..ae2df1528d3 100644 --- a/.azure-pipelines/test-docker-sonic-vs-template.yml +++ b/.azure-pipelines/test-docker-sonic-vs-template.yml @@ -69,16 +69,27 @@ jobs: pushd tests if [ '${{ parameters.archive_gcov }}' == True ]; then - sudo py.test -v --force-flaky --junitxml=tr.xml --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) + all_tests=$(ls test_*.py) + all_tests="${all_tests} p4rt" + for test in ${all_tests}; do + test_name=$(echo "${test}" | cut -d "." -f 1) + sudo py.test -v --force-flaky --junitxml="${test_name}_tr.xml" --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) ${test} + container_count=$(docker ps -q -a | wc -l) + if [ ${container_count} -gt 0 ]; then + ./gcov_support.sh set_environment $(Build.ArtifactStagingDirectory) + docker stop $(docker ps -q -a) + docker rm $(docker ps -q -a) + fi + done else - sudo py.test -v --force-flaky --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) + sudo py.test -v --force-flaky --junitxml=tests_tr.xml --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) fi rm -rf $(Build.ArtifactStagingDirectory)/download displayName: "Run vs tests" - task: PublishTestResults@2 inputs: - testResultsFiles: '**/tr.xml' + testResultsFiles: '**/*_tr.xml' testRunTitle: vstest condition: always() @@ -87,9 +98,9 @@ jobs: if [ '${{ parameters.archive_gcov }}' == True ]; then sudo apt-get install -y lcov - ./tests/gcov_support.sh set_environment $(Build.ArtifactStagingDirectory) - docker stop $(docker ps -q -a) - docker rm $(docker ps -q -a) + cd $(Build.ArtifactStagingDirectory)/gcov_tmp/ + tar -zcvf sonic-gcov.tar.gz sonic-gcov/ + rm -rf sonic-gcov fi displayName: "Collect logs" condition: always() diff --git a/tests/gcov_support.sh b/tests/gcov_support.sh index d96ee1c2505..1395f091490 100755 --- a/tests/gcov_support.sh +++ b/tests/gcov_support.sh @@ -197,12 +197,6 @@ gcov_set_environment() echo "cat list" cat ${CONTAINER_LIST} - - cd ${build_dir}/gcov_tmp/ - tar -zcvf sonic-gcov.tar.gz sonic-gcov/ - rm -rf sonic-gcov - cd ../../ - rm ${CONTAINER_LIST} } gcov_merge_info()