Skip to content

Commit

Permalink
buildreference, introduce retired kbs (dataplat#6912)
Browse files Browse the repository at this point in the history
* introduce retired kbs

* removed spaces
  • Loading branch information
niphlod authored Oct 10, 2020
1 parent 2d5ac17 commit b99253a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
14 changes: 13 additions & 1 deletion bin/dbatools-buildref-index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"LastUpdated": "2020-10-02T00:00:00",
"LastUpdated": "2020-10-08T00:00:00",
"Data": [
{
"Version": "8.0.47",
Expand Down Expand Up @@ -3987,6 +3987,12 @@
"Version": "13.0.5426",
"KBList": "4505830"
},
{
"CU": "CU9",
"Version": "13.0.5479",
"KBList": "4515435",
"Retired": true
},
{
"CU": "CU10",
"Version": "13.0.5492",
Expand Down Expand Up @@ -4247,6 +4253,12 @@
"Version": "15.0.4053",
"KBList": "4563110"
},
{
"CU": "CU7",
"Version": "15.0.4063",
"KBList": "4570012",
"Retired": true
},
{
"CU": "CU8",
"Version": "15.0.4073",
Expand Down
6 changes: 6 additions & 0 deletions functions/Get-DbaBuildReference.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,15 @@ function Get-DbaBuildReference {
$Detected.KB = $el.KBList
if (($Build -and $el.Version -eq $Build) -or ($Kb -and $el.KBList -eq $currentKb)) {
$Detected.MatchType = 'Exact'
if ($el.Retired) {
$Detected.Warning = "This version has been officially retired by Microsoft"
}
break
} elseif ($MajorVersion -and $Detected.SP -contains $ServicePack -and (!$CumulativeUpdate -or ($el.CU -and $el.CU -eq $CumulativeUpdate))) {
$Detected.MatchType = 'Exact'
if ($el.Retired) {
$Detected.Warning = "This version has been officially retired by Microsoft"
}
break
}
}
Expand Down
3 changes: 2 additions & 1 deletion functions/Test-DbaBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ function Test-DbaBuild {
VersionObject = $el.VersionObject
SP = $lastsp
CU = $el.CU
Retired = $el.Retired
}
}
}
Expand All @@ -244,7 +245,7 @@ function Test-DbaBuild {
$targetedBuild = $SPsAndCUs | Where-Object SP -eq $targetSPName | Select-Object -First 1
}
if ($ParsedMaxBehind.ContainsKey('CU')) {
[string[]]$AllCUs = ($SPsAndCUs | Where-Object VersionObject -gt $targetedBuild.VersionObject).CU | Select-Object -Unique
[string[]]$AllCUs = ($SPsAndCUs | Where-Object VersionObject -gt $targetedBuild.VersionObject | Where-Object Retired -ne $true).CU | Select-Object -Unique
if ($AllCUs.Length -gt 0) {
#CU after the targeted build available
$targetCU = $AllCUs.Length - $ParsedMaxBehind['CU'] - 1
Expand Down
16 changes: 12 additions & 4 deletions tests/Get-DbaBuildReference.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,18 @@ Describe "$CommandName Unit Test" -Tags Unittest {
}
}
Context "Passing just -Update works, see #6823" {
function Get-DbaBuildReferenceIndexOnline { }
Mock Get-DbaBuildReferenceIndexOnline -MockWith { } -ModuleName dbatools
Get-DbaBuildReference -Update -WarningVariable warnings 3>$null
$warnings | Should -BeNullOrEmpty
It 'works with -Update' {
function Get-DbaBuildReferenceIndexOnline { }
Mock Get-DbaBuildReferenceIndexOnline -MockWith { } -ModuleName dbatools
Get-DbaBuildReference -Update -WarningVariable warnings 3>$null
$warnings | Should -BeNullOrEmpty
}
}
Context "Retired KBs" {
It 'Handles retired KBs' {
$result = Get-DbaBuildReference -Build '13.0.5479'
$result.Warning | Should -Be 'This version has been officially retired by Microsoft'
}
}

# These are groups by major release (aka "Name")
Expand Down
12 changes: 12 additions & 0 deletions tests/Test-DbaBuild.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
Context "Retired KBs" {
It "Handles retired kbs" {
$result = Test-DbaBuild -Build '13.0.5479' -Latest
$result.Warning | Should -Be 'This version has been officially retired by Microsoft'
$latestCUfor2019 = (Test-DbaBuild -Build '15.0.4003' -MaxBehind '0CU').CUTarget.Replace('CU', '')
#CU7 for 2019 was retired
[int]$behindforCU7 = [int]$latestCUfor2019 - 7
$goBackTo = "$($behindforCU7)CU"
$result = Test-DbaBuild -Build '15.0.4003' -MaxBehind $goBackTo
$result.CUTarget | Should -Be 'CU6'
}
}
}
Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
Context "Command actually works" {
Expand Down

0 comments on commit b99253a

Please sign in to comment.