Skip to content

Commit 8baea60

Browse files
author
CI (Automated)
committed
Merge remote-tracking branch 'local-from/develop' into HEAD
2 parents fda8a3e + 4810620 commit 8baea60

File tree

2 files changed

+51
-18
lines changed

2 files changed

+51
-18
lines changed

bosh-psmodules/modules/BOSH.Agent/BOSH.Agent.Tests.ps1

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ Describe "Write-AgentConfig" {
9898
Test-Path $configPath | Should Be $True
9999
}
100100

101-
It "disables ephemeral disk mounting by default" {
101+
It "enables ephemeral disk mounting by default" {
102102
{ Write-AgentConfig -BoshDir $boshDir -IaaS aws } | Should Not Throw
103103
$configPath = (Join-Path $boshDir "agent.json")
104104
Test-Path $configPath | Should Be $True
105-
($configPath) | Should -Not -FileContentMatch 'EnableEphemeralDiskMounting'
105+
($configPath) | Should -FileContentMatch 'EnableEphemeralDiskMounting'
106106
}
107107

108108
It "enables ephemeral disk mounting when the flag is true" {
@@ -154,11 +154,11 @@ Describe "Write-AgentConfig" {
154154
($configPath) | Should -FileContentMatch ([regex]::New('"Metadata-Flavor":\s*"Google"'))
155155
}
156156

157-
It "disables ephemeral disk mounting by default" {
157+
It "enables ephemeral disk mounting by default" {
158158
{ Write-AgentConfig -BoshDir $boshDir -IaaS gcp } | Should Not Throw
159159
$configPath = (Join-Path $boshDir "agent.json")
160160
Test-Path $configPath | Should Be $True
161-
($configPath) | Should -Not -FileContentMatch 'EnableEphemeralDiskMounting'
161+
($configPath) | Should -FileContentMatch 'EnableEphemeralDiskMounting'
162162
}
163163

164164
It "enables ephemeral disk mounting when the flag is true" {
@@ -178,11 +178,11 @@ Describe "Write-AgentConfig" {
178178
$configContent.Infrastructure.Settings.Sources[0].Type | Should Be "CDROM"
179179
}
180180

181-
It "disables ephemeral disk mounting by default" {
181+
It "enables ephemeral disk mounting by default" {
182182
{ Write-AgentConfig -BoshDir $boshDir -IaaS vsphere } | Should Not Throw
183183
$configPath = (Join-Path $boshDir "agent.json")
184184
Test-Path $configPath | Should Be $True
185-
($configPath) | Should -Not -FileContentMatch 'EnableEphemeralDiskMounting'
185+
($configPath) | Should -FileContentMatch 'EnableEphemeralDiskMounting'
186186
}
187187

188188
It "enables ephemeral disk mounting when the flag is true" {
@@ -238,18 +238,47 @@ Describe "Install-Agent" {
238238
}
239239
}
240240

241-
It "calls helper functions with default arguments" {
242-
Mock -Verifiable -ModuleName BOSH.Agent Copy-Agent {} -ParameterFilter { $InstallDir -eq "C:\" -and $agentZipPath -eq "some-agent-zip-path" }
241+
Context "windows 2012R2" {
242+
It "calls helper functions with default arguments" {
243+
Mock Get-OSVersion { "windows2012R2" } -ModuleName BOSH.Agent
244+
Mock Test-Path { $true } -ModuleName BOSH.Agent
243245

244-
Mock -Verifiable -ModuleName BOSH.Agent Protect-Dir {} -ParameterFilter { $path -eq "C:\bosh" }
245-
Mock -Verifiable -ModuleName BOSH.Agent Protect-Dir {} -ParameterFilter { $path -eq "C:\var" }
246-
Mock -Verifiable -ModuleName BOSH.Agent Protect-Dir {} -ParameterFilter { $path -eq "C:\Windows\Panther" -and $disableInheritance -eq $false }
246+
Mock -Verifiable -ModuleName BOSH.Agent Copy-Agent {} -ParameterFilter { $InstallDir -eq "C:\" -and $agentZipPath -eq "some-agent-zip-path" }
247247

248-
Mock -Verifiable -ModuleName BOSH.Agent Write-AgentConfig {} -ParameterFilter { $IaaS -eq "aws" -and $BoshDir -eq "C:\bosh" -and $EnableEphemeralDiskMounting -eq $false}
249-
Mock -Verifiable -ModuleName BOSH.Agent Set-Path {} -ParameterFilter { $Path -eq "C:\var\vcap\bosh\bin" }
250-
Mock -Verifiable -ModuleName BOSH.Agent Install-AgentService {}
251-
Install-Agent -IaaS aws -agentZipPath "some-agent-zip-path"
252-
Assert-VerifiableMock
248+
Mock -Verifiable -ModuleName BOSH.Agent Protect-Dir {} -ParameterFilter { $path -eq "C:\bosh" }
249+
Mock -Verifiable -ModuleName BOSH.Agent Protect-Dir {} -ParameterFilter { $path -eq "C:\var" }
250+
Mock -Verifiable -ModuleName BOSH.Agent Protect-Dir {} -ParameterFilter { $path -eq "C:\Windows\Panther" -and $disableInheritance -eq $false }
251+
252+
Mock -Verifiable -ModuleName BOSH.Agent Write-AgentConfig {} -ParameterFilter { $IaaS -eq "aws" -and $BoshDir -eq "C:\bosh" -and $EnableEphemeralDiskMounting -eq $false }
253+
Mock -Verifiable -ModuleName BOSH.Agent Set-Path {} -ParameterFilter { $Path -eq "C:\var\vcap\bosh\bin" }
254+
Mock -Verifiable -ModuleName BOSH.Agent Install-AgentService {}
255+
256+
Install-Agent -IaaS aws -agentZipPath "some-agent-zip-path"
257+
258+
Assert-VerifiableMock
259+
Assert-MockCalled Get-OSVersion -Times 1 -Scope It -ModuleName BOSH.Agent
260+
}
261+
}
262+
263+
Context "windows 2016" {
264+
It "calls helper functions with default arguments" {
265+
Mock Get-OSVersion { "window2016" } -ModuleName BOSH.Agent
266+
Mock Test-Path { $true } -ModuleName BOSH.Agent
267+
268+
Mock -Verifiable -ModuleName BOSH.Agent Copy-Agent {} -ParameterFilter { $InstallDir -eq "C:\" -and $agentZipPath -eq "some-agent-zip-path" }
269+
Mock -Verifiable -ModuleName BOSH.Agent Protect-Dir {} -ParameterFilter { $Path -eq "C:\bosh" }
270+
Mock -Verifiable -ModuleName BOSH.Agent Protect-Dir {} -ParameterFilter { $Path -eq "C:\var" }
271+
Mock -Verifiable -ModuleName BOSH.Agent Protect-Dir {} -ParameterFilter { $Path -eq "C:\Windows\Panther" -and $disableInheritance -eq $false }
272+
273+
Mock -Verifiable -ModuleName BOSH.Agent Write-AgentConfig {} -ParameterFilter { $IaaS -eq "aws" -and $BoshDir -eq "C:\bosh" -and $EnableEphemeralDiskMounting -eq $true }
274+
Mock -Verifiable -ModuleName BOSH.Agent Set-Path {} -ParameterFilter { $Path -eq "C:\var\vcap\bosh\bin" }
275+
Mock -Verifiable -ModuleName BOSH.Agent Install-AgentService {}
276+
277+
Install-Agent -IaaS aws -agentZipPath "some-agent-zip-path"
278+
279+
Assert-VerifiableMock
280+
Assert-MockCalled Get-OSVersion -Times 1 -Scope It -ModuleName BOSH.Agent
281+
}
253282
}
254283
}
255284

bosh-psmodules/modules/BOSH.Agent/BOSH.Agent.psm1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ function Install-Agent {
1111
Param(
1212
[string]$IaaS = $(Throw "Provide the IaaS of your VM"),
1313
[string]$agentZipPath = $(Throw "Provide the path of your agent.zip"),
14-
[switch]$EnableEphemeralDiskMounting = $false
14+
[switch]$EnableEphemeralDiskMounting = $true
1515
)
1616

17+
$OsVersion = Get-OSVersion
18+
19+
if ($OSVersion -eq "windows2012R2") { $EnableEphemeralDiskMounting = $false }
20+
1721
Write-Log "Install-Agent: Started"
1822

1923
Copy-Agent -InstallDir "C:\" -agentZipPath $agentZipPath
@@ -66,7 +70,7 @@ function Write-AgentConfig {
6670
Param(
6771
[string]$boshDir = $(Throw "Provide a directory to install the BOSH agent config"),
6872
[string]$IaaS = $(Throw "Provide an IaaS for configuration"),
69-
[bool]$EnableEphemeralDiskMounting = $false
73+
[bool]$EnableEphemeralDiskMounting = $true
7074
)
7175

7276
if (-Not (Test-Path $boshDir -PathType Container)) {

0 commit comments

Comments
 (0)