Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Stemcell Automation can build 2019 stemcells
Browse files Browse the repository at this point in the history
[#164738451]

Co-authored-by: Jackson Feeny <[email protected]>
  • Loading branch information
mvalliath and Jackson Feeny committed Mar 21, 2019
1 parent b479e22 commit d29d468
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
21 changes: 15 additions & 6 deletions AutomationHelpers.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -559,19 +559,19 @@ Describe "Validate-OSVersion" {
It "fails gracefully when the OS major version doesn't match" {
Mock Get-OSVersionString { "14.0.16299.0" }

{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2016, Version 1709 or 1803"
{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2019 or Windows Server 2016, Version 1709 or 1803"

Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2016, Version 1709 or 1803" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2019 or Windows Server 2016, Version 1709 or 1803" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "Failed to validate the OS version. See 'c:\provisions\log.log' for more info." }
Assert-MockCalled Get-OSVersionString -Times 1 -Scope It
}

It "fails gracefully when the OS minor version doesn't match" {
Mock Get-OSVersionString { "10.5.16299.0" }

{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2016, Version 1709"
{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2019 or Windows Server 2016, Version 1709"

Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2016, Version 1709 or 1803" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2019 or Windows Server 2016, Version 1709 or 1803" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "Failed to validate the OS version. See 'c:\provisions\log.log' for more info." }
Assert-MockCalled Get-OSVersionString -Times 1 -Scope It

Expand All @@ -580,9 +580,9 @@ Describe "Validate-OSVersion" {
It "fails gracefully when the OS build version doesn't match" {
Mock Get-OSVersionString { "10.0.12345.0" }

{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2016, Version 1709"
{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2019 or Windows Server 2016, Version 1709"

Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2016, Version 1709 or 1803" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2019 or Windows Server 2016, Version 1709 or 1803" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "Failed to validate the OS version. See 'c:\provisions\log.log' for more info." }
Assert-MockCalled Get-OSVersionString -Times 1 -Scope It
}
Expand All @@ -605,6 +605,15 @@ Describe "Validate-OSVersion" {
Assert-MockCalled Get-OSVersionString -Times 1 -Scope It
}

It "successfully validates the OS when it is Windows Server 2019" {
Mock Get-OSVersionString { "10.0.17763.2761" }

{ Validate-OSVersion } | Should -Not -Throw

Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "Found correct OS version: Windows Server 2019" }
Assert-MockCalled Get-OSVersionString -Times 1 -Scope It
}

It "fails gracefully when an exception is received when getting OS version" {
Mock Get-OSVersionString { throw "Could not fetch OS version" }
Mock Write-Log
Expand Down
6 changes: 5 additions & 1 deletion AutomationHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,12 @@ function Validate-OSVersion
{
Write-Log "Found correct OS version: Windows Server 2016, Version 1803"
}
elseif ($osVersion -match "10\.0\.17763\..+")
{
Write-Log "Found correct OS version: Windows Server 2019"
}
else {
throw "OS Version Mismatch: Please use Windows Server 2016, Version 1709 or 1803"
throw "OS Version Mismatch: Please use Windows Server 2019 or Windows Server 2016, Version 1709 or 1803"
}
}
catch [Exception]
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ The BOSH Windows stemcell automation tool will create stemcells for the followin

## Supported Windows Server versions
The BOSH Windows stemcell automation tool is compatible with the following Windows versions:

* Windows Server 1709
* Windows Server 1803
* Windows Server 2019


## Prerequisites
The following need to be downloaded:
Expand Down

0 comments on commit d29d468

Please sign in to comment.