Skip to content

Read E2E logs and fail the job if no tests matched the filter #62222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions .azure/pipelines/components-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,35 @@ jobs:
displayName: Build JS
- script: .dotnet/dotnet build ./src/Components/test/E2ETest -c $(BuildConfiguration) --no-restore
displayName: Build
- script: .dotnet/dotnet test ./src/Components/test/E2ETest -c $(BuildConfiguration) --no-build --filter 'Quarantined!=true|Quarantined=false'
-p:VsTestUseMSBuildOutput=false
--logger:"trx%3BLogFileName=Microsoft.AspNetCore.Components.E2ETests.trx"
--logger:"html%3BLogFileName=Microsoft.AspNetCore.Components.E2ETests.html"
--results-directory $(Build.SourcesDirectory)/artifacts/TestResults/$(BuildConfiguration)/Unquarantined
- script: |
set -o pipefail

.dotnet/dotnet test ./src/Components/test/E2ETest \
-c $(BuildConfiguration) \
--no-build \
--filter 'Quarantined!=true|Quarantined=false' \
-p:VsTestUseMSBuildOutput=false \
--logger:"trx%3BLogFileName=Microsoft.AspNetCore.Components.E2ETests.trx" \
--logger:"html%3BLogFileName=Microsoft.AspNetCore.Components.E2ETests.html" \
--results-directory $(Build.SourcesDirectory)/artifacts/TestResults/$(BuildConfiguration)/Unquarantined \
| tee e2e-test-output.log

if grep -q "No test matches the given testcase filter" e2e-test-output.log
then
echo "##vso[task.logissue type=error] No tests matched the filter."

exit 1
fi

# Check total tests run to detect abnormalities. In case the number of tests changes significantly, we should adjust the threshold.
# Extract total from the summary line "Failed: xx, Passed: yy, Skipped: zz, Total: NNN, Duration: ..."
total=$(sed -nE 's/.*Failed:[[:space:]]*[0-9]+,[[:space:]]*Passed:[[:space:]]*[0-9]+,[[:space:]]*Skipped:[[:space:]]*[0-9]+,[[:space:]]*Total:[[:space:]]*([0-9]+).*/\1/p' e2e-test-output.log)
min_total=1000
if [ -z "$total" ] || [ "$total" -lt "$min_total" ]
then
echo "##vso[task.logissue type=error] Insufficient total test count: $total. We expect at least $min_total tests to run."
exit 1
fi
displayName: Run E2E tests
- script: .dotnet/dotnet test ./src/Components/test/E2ETest -c $(BuildConfiguration) --no-build --filter 'Quarantined=true' -p:RunQuarantinedTests=true
-p:VsTestUseMSBuildOutput=false
Expand Down
Loading