-
Notifications
You must be signed in to change notification settings - Fork 202
Add Test Isolation support #2216
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
Volodymyr Dvernytskyi (Drakonian)
wants to merge
7
commits into
microsoft:main
Choose a base branch
from
Drakonian:AddTestIsolationSupport2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+871
−0
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c36ac32
Add test isolation support
Drakonian d9039ab
Update test isolation descriptions
Drakonian 1f0214e
Add telemetry for test isolation
Drakonian 28a1f88
Update Actions/.Modules/TestIsolation.psm1
Drakonian c696ac2
Build the default-runner filter as an interval complement
Drakonian 63b52dc
Merge remote-tracking branch 'origin/main' into AddTestIsolationSupport2
Drakonian 2e2558a
Merge remote-tracking branch 'origin/main' into AddTestIsolationSupport2
Drakonian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Test Isolation module for AL-Go for GitHub. | ||
|
|
||
| .DESCRIPTION | ||
| Builds a scriptblock compatible with Run-AlPipeline's -RunTestsInBcContainer | ||
| override. The scriptblock invokes Run-TestsInBcContainer once per declared | ||
| partition (each with its own test runner and codeunit-range filter), plus one | ||
| trailing call under the default runner whose filter excludes every codeunit | ||
| matched by the explicit partitions. | ||
| #> | ||
|
|
||
| function New-PartitionedTestRunnerScriptBlock { | ||
| <# | ||
| .SYNOPSIS | ||
| Build a scriptblock for Run-AlPipeline's -RunTestsInBcContainer hook. | ||
| .DESCRIPTION | ||
| Run-AlPipeline invokes the override once per test app with a hashtable | ||
| of parameters (extensionId, containerName, disabledTests, JUnit/XUnit | ||
| file, AppendTo*ResultFile, auth context, etc.). The returned | ||
| scriptblock loops over the configured partitions and, for each one, | ||
| invokes Run-TestsInBcContainer with the partition's runner id and | ||
| codeunit-range filter. After all partitions, it issues one trailing | ||
| call under defaultRunnerCodeunitId whose -testCodeunitRange is the | ||
| negation of the union of every explicit partition's filter — so every | ||
| test codeunit not matched by an explicit partition runs under the | ||
| default runner exactly once. | ||
|
|
||
| Result-file appending is preserved because we forward the JUnit/XUnit | ||
| file params Run-AlPipeline already configured (AppendTo*ResultFile = $true). | ||
| .PARAMETER Settings | ||
| The testIsolation settings object with `defaultRunnerCodeunitId` and | ||
| `partitions` (array of @{ runnerCodeunitId; codeunits }). Closed over | ||
| by the returned scriptblock. | ||
| .OUTPUTS | ||
| [scriptblock] returning $true if every invocation reported success. | ||
| #> | ||
| Param( | ||
| [Parameter(Mandatory = $true)] | ||
| $Settings | ||
| ) | ||
|
|
||
| $capturedPartitions = @($Settings.partitions) | ||
| $capturedDefaultRunner = [int] $Settings.defaultRunnerCodeunitId | ||
|
|
||
| # Build the negative filter for the trailing default-runner call by | ||
| # collecting every '|'-separated piece from every partition's codeunits | ||
| # filter, prefixing each with '<>' and joining with '&'. Result is a | ||
| # BC integer-field filter expression that matches every codeunit ID NOT | ||
| # covered by an explicit partition. | ||
| $defaultRangeFilter = '' | ||
| if ($capturedPartitions.Count -gt 0) { | ||
| $negatedPieces = @() | ||
| foreach ($p in $capturedPartitions) { | ||
| foreach ($piece in ([string] $p.codeunits).Split('|')) { | ||
| $trimmed = $piece.Trim() | ||
| if ($trimmed) { $negatedPieces += "<>$trimmed" } | ||
| } | ||
| } | ||
| $defaultRangeFilter = $negatedPieces -join '&' | ||
| } | ||
|
|
||
| return { | ||
| Param([Hashtable] $parameters) | ||
|
|
||
| $appId = "$($parameters.extensionId)" | ||
| $allPassed = $true | ||
| $invocations = 0 | ||
|
|
||
| foreach ($p in $capturedPartitions) { | ||
| $call = @{} | ||
| foreach ($k in $parameters.Keys) { $call[$k] = $parameters[$k] } | ||
| $call['testCodeunitRange'] = "$($p.codeunits)" | ||
| $call['testRunnerCodeunitId'] = "$([int] $p.runnerCodeunitId)" | ||
|
|
||
| Write-Host "Running partition runner=$($p.runnerCodeunitId) range='$($p.codeunits)' app=$appId" | ||
| $invocations++ | ||
|
|
||
| $passed = Run-TestsInBcContainer @call | ||
| if (-not $passed) { $allPassed = $false } | ||
| } | ||
|
|
||
| $defaultCall = @{} | ||
| foreach ($k in $parameters.Keys) { $defaultCall[$k] = $parameters[$k] } | ||
| if ($defaultRangeFilter) { $defaultCall['testCodeunitRange'] = $defaultRangeFilter } | ||
| if ($capturedDefaultRunner -gt 0) { $defaultCall['testRunnerCodeunitId'] = "$capturedDefaultRunner" } | ||
| $defaultRunnerDisplay = if ($capturedDefaultRunner -gt 0) { "$capturedDefaultRunner" } else { "BC default" } | ||
|
|
||
| Write-Host "Running default partition runner=$defaultRunnerDisplay range='$defaultRangeFilter' app=$appId" | ||
| $invocations++ | ||
|
|
||
| $passed = Run-TestsInBcContainer @defaultCall | ||
| if (-not $passed) { $allPassed = $false } | ||
|
|
||
| Write-Host "Partitioned test run for app $appId complete. Invocations: $invocations. All passed: $allPassed" | ||
| return $allPassed | ||
| }.GetNewClosure() | ||
| } | ||
|
|
||
| Export-ModuleMember -Function New-PartitionedTestRunnerScriptBlock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.