Skip to content

Commit 18730c3

Browse files
authored
Tests requiring EXO or SPO must not be run in parallel. (#1361)
The current check only does this for _all_ Data pillar tests, or tests that use SecurityCompliance service. This change adds EXO, SPO and AIP to the SecurityCompliance as services. Potential further improvement - completely remove the Pillar check and only leave the required services check. This is more reliable and even can have the side effect of pushing Data checks to parallel if there is now (or in the future) such that only use Graph or Azure. Addresses #1360
2 parents fd7241c + cf7324a commit 18730c3

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/powershell/private/tests/Invoke-ZtTests.ps1

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,24 @@
111111
$skippedTestsForService.ForEach{
112112
$notConnectedService = ($_).Service.Where{ $_ -notin $ConnectedService }
113113
# Mark the test as skipped.
114+
Write-PSFMessage -Message ('Test {0} is skipped because no service connection was found' -f $_.TestId) -Level Verbose
114115
Add-ZtTestResultDetail -SkippedBecause NotConnectedToService -TestId $_.TestId -NotConnectedService $notConnectedService
115116
}
116117

117118
$testsToRun = $testsToRun.Where{ $_.TestId -notin $skippedTestsForService.TestId }
118119

119-
# Separate Sync Tests (Compliance/ExchangeOnline/SharePointOnline) from Parallel Tests (because of DLL order to manage in runspaces & remoting into WPS)
120-
# Tests that depend on SecurityCompliance remoting must run on the main thread regardless of pillar.
121-
[int[]]$syncTestIds = $testsToRun.Where{
122-
$_.Pillar -contains 'Data' -or $_.Service -contains 'SecurityCompliance'
123-
}.TestId
124-
$syncTests = $testsToRun.Where{ $_.TestId -in $syncTestIds }
125-
$parallelTests = $testsToRun.Where{ $_.TestId -notin $syncTestIds }
120+
# Separate Sync Tests (Compliance/ExchangeOnline/SharePointOnline/AIP) from Parallel Tests (because of DLL order to manage in runspaces & remoting into WPS)
121+
# Tests that depend on SecurityCompliance/ExchangeOnline/SharePointOnline/AIPService must run on the main thread
122+
# regardless of pillar: those services expose their cmdlets through dynamically-generated, connection-bound
123+
# proxy modules (Connect-IPPSSession / Connect-ExchangeOnline / Connect-SPOService / Connect-AipService) that only exist in the
124+
# main runspace where Connect-ZtAssessment ran. In a worker runspace those cmdlets are "not recognized",
125+
# so such tests would incorrectly skip (e.g. Get-SafeLinksPolicy, Get-OrganizationConfig, Get-SPOTenant).
126+
$mainThreadServices = 'SecurityCompliance', 'ExchangeOnline', 'SharePointOnline', 'AipService'
127+
128+
$syncTests, $parallelTests = $testsToRun.Where({
129+
$_.Pillar -contains 'Data' -or
130+
@($_.Service).Where({ $_ -in $mainThreadServices })
131+
}, 'Split')
126132

127133
[dateTime] $startTime = [datetime]::Now
128134
$workflow = $null

0 commit comments

Comments
 (0)