Skip to content

Commit

Permalink
Run individule pytests instead of running all pytests at once. (sonic…
Browse files Browse the repository at this point in the history
…-net#2350)

*Run pytests one test at a time.
  • Loading branch information
mint570 authored Jul 12, 2022
1 parent 0c3c9c6 commit 47f6162
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
23 changes: 17 additions & 6 deletions .azure-pipelines/test-docker-sonic-vs-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()
Expand Down
6 changes: 0 additions & 6 deletions tests/gcov_support.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 47f6162

Please sign in to comment.