Skip to content

Parallel Tests Processing - #532

Closed
Friedrich Weinmann (FriedrichWeinmann) wants to merge 3 commits into
microsoft:psnextfrom
FriedrichWeinmann:psnext-test-processing
Closed

Parallel Tests Processing#532
Friedrich Weinmann (FriedrichWeinmann) wants to merge 3 commits into
microsoft:psnextfrom
FriedrichWeinmann:psnext-test-processing

Conversation

@FriedrichWeinmann

@FriedrichWeinmann Friedrich Weinmann (FriedrichWeinmann) commented Oct 16, 2025

Copy link
Copy Markdown
Member

Rewrite of the Tests processing logic, to enable parallel processing of tests.
By default, Up to 5 tests will now be processed at a time, there is a parameter & configuration setting to change that.

Added a new command for better Tests diagnostics:

Get-ZtTestStatistics

$s = Get-ZtTestStatistics
$s[0].Messages
Timestamp           FunctionName           Line Level       TargetObject Message
---------           ------------           ---- -----       ------------ -------
2025-10-16 16:02:31 Invoke-ZtTest          54   Verbose                  Processing test '21810'
2025-10-16 16:02:31 Test-Assessment-21810  21   VeryVerbose              🟦 Start
2025-10-16 16:02:46 Add-ZtTestResultDetail 192  Verbose                  Adding test result detail for Resource-specific consent is restricted
2025-10-16 16:02:46 Add-ZtTestResultDetail 193  Debug                    Result: …
2025-10-16 16:02:46 Invoke-ZtTest          86   Verbose                  Processing test '21810' - Concluded
$s | Where-Object Success -ne $true
TestID Start               Duration         Success Error
------ -----               --------         ------- -----
21822  2025-10-16 16:02:40 00:00:02.1888895 False   Cannot bind argument to parameter 'InputObject' because it is null.
24568  2025-10-16 16:02:54 00:00:00.1956550 False   Cannot bind argument to parameter 'Policies' because it is null.
21862  2025-10-16 16:02:45 00:00:00.0535597 False   Response status code does not indicate success: Forbidden (Forbidden).

Other tweaks

  • Upd: Invoke-ZtGraphRequestCache - added throttling for Intune requests to 1000/20s
  • Fix: Invoke-ZtAssessment - Removed Progressbar when deleting old report data. No longer hangs around until INvoke-ZtAssessment completes.
  • Fix: Invoke-ZtAssessment - Database disconnects properly, without calling -Debug.

@merill

Copy link
Copy Markdown
Contributor

This is starting to look good Friedrich. Thanks a lot.

A few things: The Azure issue didn't exist with the single thread.

Some Intune APIs /tests are heavily throttled (see below). I think for those it will be good to flag them to only execute sequently instead of being run parallely. Maybe we use some metadata on the test that says not to run them in parallel (or some other idea).

Also the other area that does take a lot of time is the data export method Export-TenantData specifically Applications, Service Principals (which can have a million plus objects in large tenants). I think running parallel there will help reduce the overall time by a lot.

Merill 2025-10-17 at 14 36 03@2x

@FriedrichWeinmann

Copy link
Copy Markdown
Member Author

Heya Merill,
I've added throttling for the Intune endpoints (and added a simple way in variables.ps1 to add more throttling for specific endpoints, if it becomes necessary), This throttling applies across all runspaces and should avoid multiple Intune tests interfering with each other.
Though it may reduce some parallelism performance in those cases, it is the architecturally most simple solution while also avoiding to make Test writing any more complex.

I am unfortunately unable to reproduce the first error (Get-AzContext).
Can you show what Az.Accounts versions you have installed?

Get-Module Az.Accounts -ListAvailable

re: Export performance

That was one of the main items I worked on this week and hope to have an update for you today.
Parallelized, but also improved SPN sub-properties processing (A prime case for batching). Some of the headaches from that just made my mind escape into "doing that other thing first".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants