-
Notifications
You must be signed in to change notification settings - Fork 392
New check to validate if build was replaced by a newer one #815
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d202ad6
Logic added for known issues
dpaulson45 4d72f5a
Fixed logic with known issues
dpaulson45 40b3e2c
Updated Pester testing common code logic
dpaulson45 3b76c68
Added ability to extract main logic for pester testing
dpaulson45 5e1eedf
Pester testing for Known Build Issue
dpaulson45 1cab651
Fixed some bugs that pester testing found
dpaulson45 f6c801c
Add ValidateNotNullOrEmpty on $AnalyzeResults
dpaulson45 0a45fdd
Revert "Add ValidateNotNullOrEmpty on $AnalyzeResults"
dpaulson45 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
168 changes: 168 additions & 0 deletions
168
Diagnostics/HealthChecker/Analyzer/Invoke-AnalyzerKnownBuildIssues.ps1
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,168 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| . $PSScriptRoot\Add-AnalyzedResultInformation.ps1 | ||
| . $PSScriptRoot\..\Helpers\Invoke-CatchActions.ps1 | ||
|
|
||
| Function Invoke-AnalyzerKnownBuildIssues { | ||
| [CmdletBinding()] | ||
| param( | ||
| [Parameter(Mandatory = $true)] | ||
| [ref]$AnalyzeResults, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [string]$CurrentBuild, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [object]$DisplayGroupingKey | ||
| ) | ||
|
|
||
| Write-Verbose "Calling: $($MyInvocation.MyCommand)" | ||
|
|
||
| # Extract for Pester Testing - Start | ||
| Function GetVersionFromString { | ||
| param( | ||
| [object]$VersionString | ||
| ) | ||
| try { | ||
| return New-Object System.Version $VersionString -ErrorAction Stop | ||
| } catch { | ||
| Write-Verbose "Failed to convert '$VersionString' in $($MyInvocation.MyCommand)" | ||
| Invoke-CatchActions | ||
| } | ||
| } | ||
|
|
||
| Function GetKnownIssueInformation { | ||
| param( | ||
| [string]$Name, | ||
| [string]$Url | ||
| ) | ||
|
|
||
| return [PSCustomObject]@{ | ||
| Name = $Name | ||
| Url = $Url | ||
| } | ||
| } | ||
|
|
||
| Function GetKnownIssueBuildInformation { | ||
| param( | ||
| [string]$BuildNumber, | ||
| [string]$FixBuildNumber, | ||
| [bool]$BuildBound = $true | ||
| ) | ||
|
|
||
| return [PSCustomObject]@{ | ||
| BuildNumber = $BuildNumber | ||
| FixBuildNumber = $FixBuildNumber | ||
| BuildBound = $BuildBound | ||
| } | ||
| } | ||
|
|
||
| Function TestOnKnownBuildIssue { | ||
| [CmdletBinding()] | ||
| [OutputType("System.Boolean")] | ||
| param( | ||
| [object]$IssueBuildInformation, | ||
| [version]$CurrentBuild | ||
| ) | ||
| $knownIssue = GetVersionFromString $IssueBuildInformation.BuildNumber | ||
| Write-Verbose "Testing Known Issue Build $knownIssue" | ||
|
|
||
| if ($null -eq $knownIssue -or | ||
| $CurrentBuild.Minor -ne $knownIssue.Minor) { return $false } | ||
|
|
||
| $fixValueNull = [string]::IsNullOrEmpty($IssueBuildInformation.FixBuildNumber) | ||
| if ($fixValueNull) { | ||
| $resolvedBuild = GetVersionFromString "0.0.0.0" | ||
| } else { | ||
| $resolvedBuild = GetVersionFromString $IssueBuildInformation.FixBuildNumber | ||
| } | ||
|
|
||
| Write-Verbose "Testing against possible resolved build number $resolvedBuild" | ||
| $buildBound = $IssueBuildInformation.BuildBound | ||
| $withinBuildBoundRange = $CurrentBuild.Build -eq $knownIssue.Build | ||
| $fixNeeded = $fixValueNull -or $CurrentBuild -lt $resolvedBuild | ||
| Write-Verbose "BuildBound: $buildBound | WithinBuildBoundRage: $withinBuildBoundRange | FixNeeded: $fixNeeded" | ||
| if ($CurrentBuild -ge $knownIssue) { | ||
| if ($buildBound) { | ||
| return $withinBuildBoundRange -and $fixNeeded | ||
| } else { | ||
| return $fixNeeded | ||
| } | ||
| } | ||
|
|
||
| return $false | ||
| } | ||
|
|
||
| # Extract for Pester Testing - End | ||
|
|
||
| Function TestForKnownBuildIssues { | ||
| param( | ||
| [version]$CurrentVersion, | ||
| [object[]]$KnownBuildIssuesToFixes, | ||
| [object]$InformationUrl | ||
| ) | ||
| Write-Verbose "Calling: $($MyInvocation.MyCommand)" | ||
| Write-Verbose "Testing CurrentVersion $CurrentVersion" | ||
|
|
||
| if ($null -eq $Script:CachedKnownIssues) { | ||
| $Script:CachedKnownIssues = @() | ||
| } | ||
|
|
||
| foreach ($issue in $KnownBuildIssuesToFixes) { | ||
|
|
||
| if ((TestOnKnownBuildIssue $issue $CurrentVersion) -and | ||
| (-not($Script:CachedKnownIssues.Contains($InformationUrl)))) { | ||
| Write-Verbose "Known issue Match detected" | ||
| if (-not ($Script:DisplayKnownIssueHeader)) { | ||
| $Script:DisplayKnownIssueHeader = $true | ||
|
|
||
| $AnalyzeResults | Add-AnalyzedResultInformation -Name "Known Issue Detected" ` | ||
| -Details "True" ` | ||
| -DisplayGroupingKey $DisplayGroupingKey ` | ||
| -DisplayWriteType "Yellow" | ||
|
|
||
| $AnalyzeResults | Add-AnalyzedResultInformation -Details "This build has a known issue(s) which may or may not have been addressed. See the below link(s) for more information.`r`n" ` | ||
| -DisplayGroupingKey $DisplayGroupingKey ` | ||
| -DisplayCustomTabNumber 2 ` | ||
| -DisplayWriteType "Yellow" | ||
| } | ||
|
|
||
| $AnalyzeResults | Add-AnalyzedResultInformation -Details "$($InformationUrl.Name):`r`n`t`t`t$($InformationUrl.Url)" ` | ||
| -DisplayGroupingKey $DisplayGroupingKey ` | ||
| -DisplayCustomTabNumber 2 ` | ||
| -DisplayWriteType "Yellow" | ||
|
|
||
| if (-not ($Script:CachedKnownIssues.Contains($InformationUrl))) { | ||
| $Script:CachedKnownIssues += $InformationUrl | ||
| Write-Verbose "Added known issue to cache" | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| try { | ||
| $currentVersion = New-Object System.Version $CurrentBuild -ErrorAction Stop | ||
| } catch { | ||
| Write-Verbose "Failed to set the current build to a version type object. $CurrentBuild" | ||
| Invoke-CatchActions | ||
| } | ||
|
|
||
| try { | ||
| Write-Verbose "Working on November 2021 Security Updates - OWA redirection" | ||
| TestForKnownBuildIssues -CurrentVersion $currentVersion ` | ||
| -KnownBuildIssuesToFixes @( | ||
| (GetKnownIssueBuildInformation "15.2.986.14" $null), | ||
| (GetKnownIssueBuildInformation "15.2.922.19" $null), | ||
| (GetKnownIssueBuildInformation "15.1.2375.17" $null), | ||
| (GetKnownIssueBuildInformation "15.1.2308.20" $null), | ||
| (GetKnownIssueBuildInformation "15.0.1497.26" $null) | ||
| ) ` | ||
| -InformationUrl (GetKnownIssueInformation ` | ||
| "OWA redirection doesn't work after installing November 2021 security updates for Exchange Server 2019, 2016, or 2013" ` | ||
| "https://support.microsoft.com/help/5008997") | ||
| } catch { | ||
| Write-Verbose "Failed to run TestForKnownBuildIssues" | ||
| Invoke-CatchActions | ||
| } | ||
| } | ||
75 changes: 75 additions & 0 deletions
75
Diagnostics/HealthChecker/Analyzer/Tests/Invoke-AnalyzerKnownBuildIssues.Tests.ps1
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,75 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingInvokeExpression', '', Justification = 'Pester testing file')] | ||
| [CmdletBinding()] | ||
| param() | ||
|
|
||
| BeforeAll { | ||
| . $PSScriptRoot\..\..\..\..\Shared\PesterLoadFunctions.NotPublished.ps1 | ||
| $scriptContent = Get-PesterScriptContent -FilePath "$PSScriptRoot\..\Invoke-AnalyzerKnownBuildIssues.ps1" | ||
| Invoke-Expression $scriptContent | ||
| Function Invoke-CatchActions { throw "Called Invoke-CatchActions" } | ||
|
|
||
| Function TestPesterResults { | ||
| param( | ||
| [hashtable]$TestGroup, | ||
| [object]$KnownIssue | ||
| ) | ||
|
|
||
| foreach ($key in $TestGroup.Keys) { | ||
| $currentBuild = GetVersionFromString $key | ||
| TestOnKnownBuildIssue $KnownIssue $currentBuild -Verbose | Should -Be $TestGroup[$key] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Describe "Testing Known Build Issue Main Logic" { | ||
|
|
||
| Context "Basic Test Initial Tests" { | ||
|
|
||
| It "Initial Testing CU Bound" { | ||
|
|
||
| TestPesterResults -TestGroup @{ | ||
| "15.1.2375.17" = $true | ||
| "15.1.2375.16" = $false | ||
| "15.1.2376.17" = $false | ||
| "15.1.2375.18" = $true | ||
| } ` | ||
| -KnownIssue (GetKnownIssueBuildInformation -BuildNumber "15.1.2375.17" -FixBuildNumber $null) | ||
| } | ||
|
|
||
| It "Initial Testing CU Not Bound" { | ||
|
|
||
| TestPesterResults -TestGroup @{ | ||
| "15.1.2375.17" = $true | ||
| "15.1.2375.16" = $false | ||
| "15.1.2376.17" = $true | ||
| "15.1.2375.18" = $true | ||
| } ` | ||
| -KnownIssue (GetKnownIssueBuildInformation -BuildNumber "15.1.2375.17" -FixBuildNumber $null -BuildBound $false) | ||
| } | ||
|
|
||
| It "On Fix Build" { | ||
|
|
||
| TestPesterResults -TestGroup @{ | ||
| "15.1.2375.17" = $true | ||
| "15.1.2375.16" = $false | ||
| "15.1.2376.17" = $false | ||
| "15.1.2375.18" = $false | ||
| } ` | ||
| -KnownIssue (GetKnownIssueBuildInformation -BuildNumber "15.1.2375.17" -FixBuildNumber "15.1.2375.18") | ||
| } | ||
|
|
||
| It "Testing Major Diff" { | ||
|
|
||
| TestPesterResults -TestGroup @{ | ||
| "15.1.2375.17" = $false | ||
| "15.1.2375.16" = $false | ||
| "15.1.2376.17" = $false | ||
| "15.1.2375.18" = $false | ||
| } ` | ||
| -KnownIssue (GetKnownIssueBuildInformation -BuildNumber "15.2.2375.17" -FixBuildNumber $null) | ||
| } | ||
| } | ||
| } |
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
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.