diff --git a/.azure-pipelines/test-docker-sonic-vs-template.yml b/.azure-pipelines/test-docker-sonic-vs-template.yml index 47f02f059..4748b09fb 100644 --- a/.azure-pipelines/test-docker-sonic-vs-template.yml +++ b/.azure-pipelines/test-docker-sonic-vs-template.yml @@ -57,13 +57,40 @@ jobs: docker ps ip netns list pushd sonic-swss/tests - sudo py.test -v --force-flaky --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) + + # run pytests in sets of 20 + all_tests=$(ls test_*.py) + all_tests="${all_tests} p4rt" + test_set=() + for test in ${all_tests}; do + test_set+=("${test}") + if [ ${#test_set[@]} -ge 20 ]; then + test_name=$(echo "${test_set[0]}" | cut -d "." -f 1) + echo "${test_set[*]}" | xargs sudo py.test -v --force-flaky --junitxml="${test_name}_tr.xml" --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) + container_count=$(docker ps -q -a | wc -l) + if [ ${container_count} -gt 0 ]; then + docker stop $(docker ps -q -a) + docker rm $(docker ps -q -a) + fi + test_set=() + fi + done + if [ ${#test_set[@]} -gt 0 ]; then + test_name=$(echo "${test_set[0]}" | cut -d "." -f 1) + echo "${test_set[*]}" | xargs sudo py.test -v --force-flaky --junitxml="${test_name}_tr.xml" --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) + container_count=$(docker ps -q -a | wc -l) + if [ ${container_count} -gt 0 ]; then + docker stop $(docker ps -q -a) + docker rm $(docker ps -q -a) + fi + fi + rm -rf $(Build.ArtifactStagingDirectory)/download displayName: "Run vs tests" - task: PublishTestResults@2 inputs: - testResultsFiles: '**/tr.xml' + testResultsFiles: '**/*_tr.xml' testRunTitle: vstest condition: always()