Skip to content

Commit dd7d7a6

Browse files
freddydkaholstrup1mazhelez
authored
BCPT Test Report (microsoft#619)
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]>
1 parent bf2b6a2 commit dd7d7a6

13 files changed

+554
-120
lines changed

Actions/AL-Go-Helper.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,12 @@ function ReadSettings {
638638
"buildModes" = @()
639639
"useCompilerFolder" = $false
640640
"pullRequestTrigger" = "pull_request_target"
641+
"bcptThresholds" = [ordered]@{
642+
"DurationWarning" = 10
643+
"DurationError" = 25
644+
"NumberOfSqlStmtsWarning" = 5
645+
"NumberOfSqlStmtsError" = 10
646+
}
641647
"fullBuildPatterns" = @()
642648
"excludeEnvironments" = @()
643649
"alDoc" = [ordered]@{

Actions/AnalyzeTests/AnalyzeTests.ps1

+30-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[Parameter(HelpMessage = "Specifies the parent telemetry scope for the telemetry signal", Mandatory = $false)]
33
[string] $parentTelemetryScopeJson = '7b7d',
44
[Parameter(HelpMessage = "Project to analyze", Mandatory = $false)]
5-
[string] $project
5+
[string] $project = '.'
66
)
77

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

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

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

27-
Add-Content -path $ENV:GITHUB_STEP_SUMMARY -value "$($testResultSummary.Replace("\n","`n"))`n"
32+
# If summary fits, we will display it in the GitHub summary
33+
if ($testResultsSummaryMD.Length -gt 65000) {
34+
# 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
35+
$testResultsSummaryMD = "<i>Test results summary size exceeds GitHub summary capacity. Download **TestResults** artifact to see details.</i>"
2836
}
29-
else {
30-
Write-Host "Test results not found"
37+
# If summary AND BCPT summary fits, we will display both in the GitHub summary
38+
if ($testResultsSummaryMD.Length + $bcptSummaryMD.Length -gt 65000) {
39+
# If Combined Test Results and BCPT summary exceeds GitHub summary capacity, we will not display the BCPT summary
40+
$bcptSummaryMD = "<i>Performance test results summary size exceeds GitHub summary capacity. Download **BcptTestResults** artifact to see details.</i>"
3141
}
32-
33-
$bcptTestResultsFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\BCPTTestResults.json"
34-
if (Test-Path $bcptTestResultsFile) {
35-
# TODO Display BCPT Test Results
42+
# If summary AND BCPT summary AND failures summary fits, we will display all in the GitHub summary
43+
if ($testResultsSummaryMD.Length + $testResultsfailuresMD.Length + $bcptSummaryMD.Length -gt 65000) {
44+
# If Combined Test Results, failures and BCPT summary exceeds GitHub summary capacity, we will not display the failures details, only the failures summary
45+
$testResultsfailuresMD = $testResultsFailuresSummaryMD
3646
}
37-
else {
38-
#Add-Content -path $ENV:GITHUB_STEP_SUMMARY -value "*BCPT test results not found*`n`n"
47+
48+
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "## Test results`n`n"
49+
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "$($testResultsSummaryMD.Replace("\n","`n"))`n`n"
50+
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "$($testResultsfailuresMD.Replace("\n","`n"))`n`n"
51+
if ($bcptSummaryMD) {
52+
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "## Performance test results`n`n"
53+
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "$($bcptSummaryMD.Replace("\n","`n"))`n`n"
3954
}
4055

4156
TrackTrace -telemetryScope $telemetryScope

0 commit comments

Comments
 (0)