Skip to content

Commit

Permalink
Merge pull request #43 from AArnott/testhangdump
Browse files Browse the repository at this point in the history
Collect dumps and sequence.xml files on test hangs and crashes
  • Loading branch information
AArnott authored Mar 27, 2020
2 parents 8a3f6cd + 941448d commit 532c624
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/Linux.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<RunSettings />
14 changes: 14 additions & 0 deletions .github/workflows/Windows.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="blame" enabled="True">
<Configuration>
<CollectDump DumpType="full" />
<CollectDumpOnTestSessionHang TestTimeout="30000" DumpType="full" />
<!-- This ResultsDirectory must exist, but it is totally ignored. -->
<ResultsDirectory>%GITHUB_WORKSPACE%</ResultsDirectory>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
13 changes: 12 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
run: |
./init.ps1 -UpgradePrerequisites
dotnet --info
if ($env:RUNNER_OS -eq "Windows") {
choco install procdump
Write-Host "##[set-env name=PROCDUMP_PATH;]$env:PROGRAMDATA\chocolatey\bin\"
}
shell: pwsh
- name: Set pipeline variables based on source
run: azure-pipelines/variables/_pipelines.ps1
Expand All @@ -44,7 +48,7 @@ jobs:
- name: pack
run: dotnet pack src --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog"
- name: test
run: dotnet test src --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
run: dotnet test src --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --settings "${{ github.workspace }}/.github/workflows/${{ runner.os }}.runsettings"
- name: Update pipeline variables based on build outputs
run: azure-pipelines/variables/_pipelines.ps1
shell: pwsh
Expand Down Expand Up @@ -73,6 +77,13 @@ jobs:
name: build_logs-${{ runner.os }}
path: obj/_artifacts/build_logs
continue-on-error: true
- name: Upload testResults
if: always()
uses: actions/upload-artifact@v1
with:
name: testResults-${{ runner.os }}
path: obj/_artifacts/testResults
continue-on-error: true
- name: Upload coverageResults
if: always()
uses: actions/upload-artifact@v1
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/macOS.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<RunSettings />
1 change: 1 addition & 0 deletions azure-pipelines/Darwin.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<RunSettings />
1 change: 1 addition & 0 deletions azure-pipelines/Linux.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<RunSettings />
14 changes: 14 additions & 0 deletions azure-pipelines/Windows_NT.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="blame" enabled="True">
<Configuration>
<CollectDump DumpType="full" />
<CollectDumpOnTestSessionHang TestTimeout="30000" DumpType="full" />
<!-- This ResultsDirectory must exist, but it is totally ignored. -->
<ResultsDirectory>%BUILD_ARTIFACTSTAGINGDIRECTORY%</ResultsDirectory>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
12 changes: 12 additions & 0 deletions azure-pipelines/artifacts/testResults.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if ($env:AGENT_TEMPDIRECTORY) {
# The DotNetCoreCLI uses an alternate location to publish these files
$guidRegex = '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$'
@{
$env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\testhost.*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse });
}
} else {
$srcRoot = Resolve-Path "$PSScriptRoot\..\..\src"
@{
$srcRoot = (Get-ChildItem "$srcRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File);
}
}
6 changes: 3 additions & 3 deletions azure-pipelines/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ steps:
displayName: dotnet test -f net472
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
testRunTitle: net472-$(Agent.JobName)
workingDirectory: src
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
Expand All @@ -21,15 +21,15 @@ steps:
displayName: dotnet test -f netcoreapp2.1
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
testRunTitle: netcoreapp2.1-$(Agent.JobName)
workingDirectory: src

- task: DotNetCoreCLI@2
displayName: dotnet test -f netcoreapp3.1
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
testRunTitle: netcoreapp3.1-$(Agent.JobName)
workingDirectory: src

Expand Down
7 changes: 7 additions & 0 deletions azure-pipelines/install-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ steps:
dotnet --info
displayName: Install prerequisites

# The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests.
- powershell: |
choco install procdump
Write-Host "##vso[task.setvariable variable=PROCDUMP_PATH;]$env:ProgramData\chocolatey\bin\"
displayName: Install procdump
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))

- task: PowerShell@2
inputs:
filePath: azure-pipelines/variables/_pipelines.ps1
Expand Down

0 comments on commit 532c624

Please sign in to comment.