Skip to content

Commit

Permalink
BCPT Test Report (#619)
Browse files Browse the repository at this point in the history
This PR will add a BCPT Test Report to the build summary, looking like
this:

![image](https://github.com/microsoft/AL-Go/assets/10775043/7a9d2e42-e017-41fc-9bc2-62cc2534bea1)

You can also add a bcptBaseLine.json to the project in order to
establish a baseline for the performance tests.
It looks like this:

![image](https://github.com/microsoft/AL-Go/assets/10775043/fd5612e5-11c9-4483-bd27-c49dc6ed05c0)


TODOs:
- [x] Add tests
- [x] Add thresholds to project settings
- [x] Determine how thresholds should work? threshold on very small
items like (enter account no.) doesn't make much sense. It absolutely
makes sense to have threshold on scenarios.
- [x] Determine sorting of test results? (codeunitID, codeunitName or
???)
- [x] Issue GitHub warnings and errors when thresholds are exceeded
- [x] Is durationMin in milliseconds, seconds or what? how many decimal
digits should be displayed?
- [x] Get BCPT Backend Team signoff that BCPT Test Results are correctly
understood and compared
- [x] Add scenario documentation

Example of bcpt tests with failures and warnings:

![image](https://github.com/microsoft/AL-Go/assets/10775043/85b16114-687f-435d-bc93-0d54757b7196)

---------

Co-authored-by: freddydk <[email protected]>
Co-authored-by: Alexander Holstrup <[email protected]>
Co-authored-by: Maria Zhelezova <[email protected]>
  • Loading branch information
4 people authored Jun 21, 2024
1 parent bf2b6a2 commit dd7d7a6
Show file tree
Hide file tree
Showing 13 changed files with 554 additions and 120 deletions.
6 changes: 6 additions & 0 deletions Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,12 @@ function ReadSettings {
"buildModes" = @()
"useCompilerFolder" = $false
"pullRequestTrigger" = "pull_request_target"
"bcptThresholds" = [ordered]@{
"DurationWarning" = 10
"DurationError" = 25
"NumberOfSqlStmtsWarning" = 5
"NumberOfSqlStmtsError" = 10
}
"fullBuildPatterns" = @()
"excludeEnvironments" = @()
"alDoc" = [ordered]@{
Expand Down
45 changes: 30 additions & 15 deletions Actions/AnalyzeTests/AnalyzeTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[Parameter(HelpMessage = "Specifies the parent telemetry scope for the telemetry signal", Mandatory = $false)]
[string] $parentTelemetryScopeJson = '7b7d',
[Parameter(HelpMessage = "Project to analyze", Mandatory = $false)]
[string] $project
[string] $project = '.'
)

$telemetryScope = $null
Expand All @@ -17,25 +17,40 @@ try {
. (Join-Path -Path $PSScriptRoot 'TestResultAnalyzer.ps1')

$testResultsFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\TestResults.xml"
if (Test-Path $testResultsFile) {
$testResults = [xml](Get-Content "$project\TestResults.xml")
$testResultSummary = GetTestResultSummary -testResults $testResults -includeFailures 50
$testResultsSummaryMD, $testResultsfailuresMD, $testResultsFailuresSummaryMD = GetTestResultSummaryMD -testResultsFile $testResultsFile

Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "TestResultMD=$testResultSummary"
Write-Host "TestResultMD=$testResultSummary"
$settings = $env:Settings | ConvertFrom-Json
$bcptTestResultsFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\bcptTestResults.json"
$bcptBaseLineFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\bcptBaseLine.json"
$bcptThresholdsFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\bcptThresholds.json"
$bcptSummaryMD = GetBcptSummaryMD `
-bcptTestResultsFile $bcptTestResultsFile `
-baseLinePath $bcptBaseLineFile `
-thresholdsPath $bcptThresholdsFile `
-bcptThresholds ($settings.bcptThresholds | ConvertTo-HashTable)

Add-Content -path $ENV:GITHUB_STEP_SUMMARY -value "$($testResultSummary.Replace("\n","`n"))`n"
# If summary fits, we will display it in the GitHub summary
if ($testResultsSummaryMD.Length -gt 65000) {
# If Test results summary is too long, we will not display it in the GitHub summary, instead we will display a message to download the test results
$testResultsSummaryMD = "<i>Test results summary size exceeds GitHub summary capacity. Download **TestResults** artifact to see details.</i>"
}
else {
Write-Host "Test results not found"
# If summary AND BCPT summary fits, we will display both in the GitHub summary
if ($testResultsSummaryMD.Length + $bcptSummaryMD.Length -gt 65000) {
# If Combined Test Results and BCPT summary exceeds GitHub summary capacity, we will not display the BCPT summary
$bcptSummaryMD = "<i>Performance test results summary size exceeds GitHub summary capacity. Download **BcptTestResults** artifact to see details.</i>"
}

$bcptTestResultsFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\BCPTTestResults.json"
if (Test-Path $bcptTestResultsFile) {
# TODO Display BCPT Test Results
# If summary AND BCPT summary AND failures summary fits, we will display all in the GitHub summary
if ($testResultsSummaryMD.Length + $testResultsfailuresMD.Length + $bcptSummaryMD.Length -gt 65000) {
# If Combined Test Results, failures and BCPT summary exceeds GitHub summary capacity, we will not display the failures details, only the failures summary
$testResultsfailuresMD = $testResultsFailuresSummaryMD
}
else {
#Add-Content -path $ENV:GITHUB_STEP_SUMMARY -value "*BCPT test results not found*`n`n"

Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "## Test results`n`n"
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "$($testResultsSummaryMD.Replace("\n","`n"))`n`n"
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "$($testResultsfailuresMD.Replace("\n","`n"))`n`n"
if ($bcptSummaryMD) {
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "## Performance test results`n`n"
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "$($bcptSummaryMD.Replace("\n","`n"))`n`n"
}

TrackTrace -telemetryScope $telemetryScope
Expand Down
Loading

0 comments on commit dd7d7a6

Please sign in to comment.