kitchen-hyperv 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +117 -92
- data/Gemfile +15 -15
- data/README.md +5 -0
- data/Rakefile +39 -39
- data/kitchen-hyperv.gemspec +32 -32
- data/lib/kitchen/driver/hyperv.rb +18 -1
- data/lib/kitchen/driver/hyperv_version.rb +22 -22
- data/lib/kitchen/driver/powershell.rb +236 -235
- data/spec/support/hyperv.Tests.ps1 +194 -160
- data/support/hyperv.ps1 +5 -0
- metadata +3 -3
|
@@ -1,160 +1,194 @@
|
|
|
1
|
-
. $PSScriptRoot\..\..\support\hyperv.ps1
|
|
2
|
-
|
|
3
|
-
describe 'New-DifferencingDisk' {
|
|
4
|
-
mock new-vhd -Verifiable -MockWith {}
|
|
5
|
-
|
|
6
|
-
context 'mandatory parameters' {
|
|
7
|
-
mock Test-Path -MockWith {}
|
|
8
|
-
|
|
9
|
-
$command = get-command new-differencingDisk
|
|
10
|
-
|
|
11
|
-
it 'Path is mandatory' {
|
|
12
|
-
$Command.Parameters['Path'].Attributes.Mandatory | should be $true
|
|
13
|
-
}
|
|
14
|
-
it 'ParentPath is mandatory' {
|
|
15
|
-
$Command.Parameters['ParentPath'].Attributes.Mandatory | should be $true
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
context 'when differencing disk exists' {
|
|
20
|
-
mock Test-Path -ParameterFilter {$Path -eq 'c:\.kitchen\diff.vhd'} -MockWith {$true}
|
|
21
|
-
|
|
22
|
-
new-differencingDisk -Path 'c:\.kitchen\diff.vhd' -parentpath 'c:\source.vhd'
|
|
23
|
-
|
|
24
|
-
it 'does not create a new vhd' {
|
|
25
|
-
Assert-MockCalled new-vhd -Times 0
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
context 'when a differencing disk does not exist' {
|
|
30
|
-
mock Test-Path -ParameterFilter {$Path -eq 'c:\.kitchen\diff.vhd'} -MockWith {$false}
|
|
31
|
-
|
|
32
|
-
new-differencingDisk -Path 'c:\.kitchen\diff.vhd' -parentpath 'c:\source.vhd'
|
|
33
|
-
|
|
34
|
-
it 'creates a new differencing disk' {
|
|
35
|
-
Assert-MockCalled new-vhd -Times 1 -ParameterFilter {
|
|
36
|
-
$Path -eq 'c:\.kitchen\diff.vhd' -and
|
|
37
|
-
$ParentPath -eq 'c:\source.vhd' -and
|
|
38
|
-
$Differencing -eq $true
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
Describe "New-KitchenVM with VlanId" {
|
|
45
|
-
function New-VM {}
|
|
46
|
-
function Set-VM {}
|
|
47
|
-
function Set-VMMemory {}
|
|
48
|
-
function Set-VMNetworkAdapterVlan {param ($VM, [Switch]$Access, $VlanId)}
|
|
49
|
-
function Start-VM {}
|
|
50
|
-
|
|
51
|
-
Mock New-VM
|
|
52
|
-
Mock Set-VM
|
|
53
|
-
Mock Set-VMMemory
|
|
54
|
-
Mock Set-VMNetworkAdapterVlan
|
|
55
|
-
Mock Start-VM
|
|
56
|
-
|
|
57
|
-
Context "When VlanId is not specified" {
|
|
58
|
-
New-KitchenVM
|
|
59
|
-
|
|
60
|
-
It "Should not set the VlanId for the VM" {
|
|
61
|
-
Assert-MockCalled Set-VMNetworkAdapterVlan -Times 0
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
Context "When VlanId is specified" {
|
|
66
|
-
$testVlanId = 1
|
|
67
|
-
New-KitchenVM -VlanId $testVlanId
|
|
68
|
-
|
|
69
|
-
It "Should set the VlanId for the VM" {
|
|
70
|
-
Assert-MockCalled Set-VMNetworkAdapterVlan -Times 1 -ParameterFilter {
|
|
71
|
-
$VM -eq $null -and
|
|
72
|
-
$Access -eq $true -and
|
|
73
|
-
$VlanId -eq $testVlanId
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
Describe "New-KitchenVM with AdditionalDisks" {
|
|
80
|
-
function New-VM {}
|
|
81
|
-
function Set-VM {}
|
|
82
|
-
function Set-VMMemory {}
|
|
83
|
-
function Add-VMHardDiskDrive {param ($Path)}
|
|
84
|
-
function Start-VM {}
|
|
85
|
-
|
|
86
|
-
Mock New-VM
|
|
87
|
-
Mock Set-VM
|
|
88
|
-
Mock Set-VMMemory
|
|
89
|
-
Mock Add-VMHardDiskDrive
|
|
90
|
-
Mock Start-VM
|
|
91
|
-
|
|
92
|
-
Context "When AdditionalDisks is not specified" {
|
|
93
|
-
New-KitchenVM
|
|
94
|
-
|
|
95
|
-
It "Should not add additional disks to the VM" {
|
|
96
|
-
Assert-MockCalled Add-VMHardDiskDrive -Times 0
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
Context "When AdditionalDisks is specified" {
|
|
101
|
-
$AdditionalDisks = @(".\test1.vhd", ".\test2.vhdx")
|
|
102
|
-
New-KitchenVM -AdditionalDisks $AdditionalDisks
|
|
103
|
-
|
|
104
|
-
It "Should add additinoal disks to the VM" {
|
|
105
|
-
Assert-MockCalled Add-VMHardDiskDrive -Times $AdditionalDisks.Count -ParameterFilter {
|
|
106
|
-
$VM -eq $null -and
|
|
107
|
-
$Path -in $AdditionalDisks
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
Describe "New-KitchenVM with DisableSecureBoot" {
|
|
114
|
-
function New-VM {}
|
|
115
|
-
function Set-VM {}
|
|
116
|
-
function Set-VMMemory {}
|
|
117
|
-
function Set-VMFirmware {param ($EnableSecureBoot)}
|
|
118
|
-
function Start-VM {}
|
|
119
|
-
|
|
120
|
-
Mock New-VM
|
|
121
|
-
Mock Set-VM
|
|
122
|
-
Mock Set-VMMemory
|
|
123
|
-
Mock Set-VMFirmware
|
|
124
|
-
Mock Start-VM
|
|
125
|
-
|
|
126
|
-
Context "When DisableSecureBoot is not specified" {
|
|
127
|
-
New-KitchenVM
|
|
128
|
-
|
|
129
|
-
It "Should not set firmware settings on the VM" {
|
|
130
|
-
Assert-MockCalled Set-VMFirmware -Times 0
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
Context "When DisableSecureBoot is False" {
|
|
135
|
-
New-KitchenVM -DisableSecureBoot $false
|
|
136
|
-
|
|
137
|
-
It "Should not set firmware settings on the VM" {
|
|
138
|
-
Assert-MockCalled Set-VMFirmware -Times 0
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
Context "When DisableSecureBoot is True and Generation is 1" {
|
|
143
|
-
New-KitchenVM -Generation 1 -DisableSecureBoot $true
|
|
144
|
-
|
|
145
|
-
It "Should not set firmware settings on the VM" {
|
|
146
|
-
Assert-MockCalled Set-VMFirmware -Times 0
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
Context "When DisableSecureBoot is True and Generation is 2" {
|
|
151
|
-
New-KitchenVM -Generation 2 -DisableSecureBoot $true
|
|
152
|
-
|
|
153
|
-
It "Should disable secure boot on the VM" {
|
|
154
|
-
Assert-MockCalled Set-VMFirmware -Times 1 -ParameterFilter {
|
|
155
|
-
$VM -eq $null -and
|
|
156
|
-
$EnableSecureBoot -eq "Off"
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
1
|
+
. $PSScriptRoot\..\..\support\hyperv.ps1
|
|
2
|
+
|
|
3
|
+
describe 'New-DifferencingDisk' {
|
|
4
|
+
mock new-vhd -Verifiable -MockWith {}
|
|
5
|
+
|
|
6
|
+
context 'mandatory parameters' {
|
|
7
|
+
mock Test-Path -MockWith {}
|
|
8
|
+
|
|
9
|
+
$command = get-command new-differencingDisk
|
|
10
|
+
|
|
11
|
+
it 'Path is mandatory' {
|
|
12
|
+
$Command.Parameters['Path'].Attributes.Mandatory | should be $true
|
|
13
|
+
}
|
|
14
|
+
it 'ParentPath is mandatory' {
|
|
15
|
+
$Command.Parameters['ParentPath'].Attributes.Mandatory | should be $true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
context 'when differencing disk exists' {
|
|
20
|
+
mock Test-Path -ParameterFilter {$Path -eq 'c:\.kitchen\diff.vhd'} -MockWith {$true}
|
|
21
|
+
|
|
22
|
+
new-differencingDisk -Path 'c:\.kitchen\diff.vhd' -parentpath 'c:\source.vhd'
|
|
23
|
+
|
|
24
|
+
it 'does not create a new vhd' {
|
|
25
|
+
Assert-MockCalled new-vhd -Times 0
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
context 'when a differencing disk does not exist' {
|
|
30
|
+
mock Test-Path -ParameterFilter {$Path -eq 'c:\.kitchen\diff.vhd'} -MockWith {$false}
|
|
31
|
+
|
|
32
|
+
new-differencingDisk -Path 'c:\.kitchen\diff.vhd' -parentpath 'c:\source.vhd'
|
|
33
|
+
|
|
34
|
+
it 'creates a new differencing disk' {
|
|
35
|
+
Assert-MockCalled new-vhd -Times 1 -ParameterFilter {
|
|
36
|
+
$Path -eq 'c:\.kitchen\diff.vhd' -and
|
|
37
|
+
$ParentPath -eq 'c:\source.vhd' -and
|
|
38
|
+
$Differencing -eq $true
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Describe "New-KitchenVM with VlanId" {
|
|
45
|
+
function New-VM {}
|
|
46
|
+
function Set-VM {}
|
|
47
|
+
function Set-VMMemory {}
|
|
48
|
+
function Set-VMNetworkAdapterVlan {param ($VM, [Switch]$Access, $VlanId)}
|
|
49
|
+
function Start-VM {}
|
|
50
|
+
|
|
51
|
+
Mock New-VM
|
|
52
|
+
Mock Set-VM
|
|
53
|
+
Mock Set-VMMemory
|
|
54
|
+
Mock Set-VMNetworkAdapterVlan
|
|
55
|
+
Mock Start-VM
|
|
56
|
+
|
|
57
|
+
Context "When VlanId is not specified" {
|
|
58
|
+
New-KitchenVM
|
|
59
|
+
|
|
60
|
+
It "Should not set the VlanId for the VM" {
|
|
61
|
+
Assert-MockCalled Set-VMNetworkAdapterVlan -Times 0
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Context "When VlanId is specified" {
|
|
66
|
+
$testVlanId = 1
|
|
67
|
+
New-KitchenVM -VlanId $testVlanId
|
|
68
|
+
|
|
69
|
+
It "Should set the VlanId for the VM" {
|
|
70
|
+
Assert-MockCalled Set-VMNetworkAdapterVlan -Times 1 -ParameterFilter {
|
|
71
|
+
$VM -eq $null -and
|
|
72
|
+
$Access -eq $true -and
|
|
73
|
+
$VlanId -eq $testVlanId
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Describe "New-KitchenVM with AdditionalDisks" {
|
|
80
|
+
function New-VM {}
|
|
81
|
+
function Set-VM {}
|
|
82
|
+
function Set-VMMemory {}
|
|
83
|
+
function Add-VMHardDiskDrive {param ($Path)}
|
|
84
|
+
function Start-VM {}
|
|
85
|
+
|
|
86
|
+
Mock New-VM
|
|
87
|
+
Mock Set-VM
|
|
88
|
+
Mock Set-VMMemory
|
|
89
|
+
Mock Add-VMHardDiskDrive
|
|
90
|
+
Mock Start-VM
|
|
91
|
+
|
|
92
|
+
Context "When AdditionalDisks is not specified" {
|
|
93
|
+
New-KitchenVM
|
|
94
|
+
|
|
95
|
+
It "Should not add additional disks to the VM" {
|
|
96
|
+
Assert-MockCalled Add-VMHardDiskDrive -Times 0
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Context "When AdditionalDisks is specified" {
|
|
101
|
+
$AdditionalDisks = @(".\test1.vhd", ".\test2.vhdx")
|
|
102
|
+
New-KitchenVM -AdditionalDisks $AdditionalDisks
|
|
103
|
+
|
|
104
|
+
It "Should add additinoal disks to the VM" {
|
|
105
|
+
Assert-MockCalled Add-VMHardDiskDrive -Times $AdditionalDisks.Count -ParameterFilter {
|
|
106
|
+
$VM -eq $null -and
|
|
107
|
+
$Path -in $AdditionalDisks
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Describe "New-KitchenVM with DisableSecureBoot" {
|
|
114
|
+
function New-VM {}
|
|
115
|
+
function Set-VM {}
|
|
116
|
+
function Set-VMMemory {}
|
|
117
|
+
function Set-VMFirmware {param ($EnableSecureBoot)}
|
|
118
|
+
function Start-VM {}
|
|
119
|
+
|
|
120
|
+
Mock New-VM
|
|
121
|
+
Mock Set-VM
|
|
122
|
+
Mock Set-VMMemory
|
|
123
|
+
Mock Set-VMFirmware
|
|
124
|
+
Mock Start-VM
|
|
125
|
+
|
|
126
|
+
Context "When DisableSecureBoot is not specified" {
|
|
127
|
+
New-KitchenVM
|
|
128
|
+
|
|
129
|
+
It "Should not set firmware settings on the VM" {
|
|
130
|
+
Assert-MockCalled Set-VMFirmware -Times 0
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
Context "When DisableSecureBoot is False" {
|
|
135
|
+
New-KitchenVM -DisableSecureBoot $false
|
|
136
|
+
|
|
137
|
+
It "Should not set firmware settings on the VM" {
|
|
138
|
+
Assert-MockCalled Set-VMFirmware -Times 0
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
Context "When DisableSecureBoot is True and Generation is 1" {
|
|
143
|
+
New-KitchenVM -Generation 1 -DisableSecureBoot $true
|
|
144
|
+
|
|
145
|
+
It "Should not set firmware settings on the VM" {
|
|
146
|
+
Assert-MockCalled Set-VMFirmware -Times 0
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
Context "When DisableSecureBoot is True and Generation is 2" {
|
|
151
|
+
New-KitchenVM -Generation 2 -DisableSecureBoot $true
|
|
152
|
+
|
|
153
|
+
It "Should disable secure boot on the VM" {
|
|
154
|
+
Assert-MockCalled Set-VMFirmware -Times 1 -ParameterFilter {
|
|
155
|
+
$VM -eq $null -and
|
|
156
|
+
$EnableSecureBoot -eq "Off"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
Describe "New-KitchenVM with StaticMacAddress" {
|
|
163
|
+
function New-VM {}
|
|
164
|
+
function Set-VM {}
|
|
165
|
+
function Set-VMMemory {}
|
|
166
|
+
function Set-VMNetworkAdapter {param ($VM, $StaticMacAddress)}
|
|
167
|
+
function Start-VM {}
|
|
168
|
+
|
|
169
|
+
Mock New-VM
|
|
170
|
+
Mock Set-VM
|
|
171
|
+
Mock Set-VMMemory
|
|
172
|
+
Mock Set-VMNetworkAdapter
|
|
173
|
+
Mock Start-VM
|
|
174
|
+
|
|
175
|
+
Context "When StaticMacAddress is not specified" {
|
|
176
|
+
New-KitchenVM -StaticMacAddress ""
|
|
177
|
+
|
|
178
|
+
It "Should not set the StaticMacAddress for the VM" {
|
|
179
|
+
Assert-MockCalled Set-VMNetworkAdapter -Times 1
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
Context "When StaticMacAddress is specified" {
|
|
184
|
+
$testStaticMacAddress = "00155D01B532"
|
|
185
|
+
New-KitchenVM -StaticMacAddress $testStaticMacAddress
|
|
186
|
+
|
|
187
|
+
It "Should set the StaticMacAddress for the VM" {
|
|
188
|
+
Assert-MockCalled Set-VMNetworkAdapter -Times 1 -ParameterFilter {
|
|
189
|
+
$VM -eq $VM.VMName -and
|
|
190
|
+
$StaticMacAddress -eq $testStaticMacAddress
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
data/support/hyperv.ps1
CHANGED
|
@@ -59,6 +59,7 @@ function New-KitchenVM {
|
|
|
59
59
|
$Generation = 1,
|
|
60
60
|
$DisableSecureBoot,
|
|
61
61
|
$MemoryStartupBytes,
|
|
62
|
+
$StaticMacAddress,
|
|
62
63
|
$Name,
|
|
63
64
|
$Path,
|
|
64
65
|
$VHDPath,
|
|
@@ -74,6 +75,7 @@ function New-KitchenVM {
|
|
|
74
75
|
)
|
|
75
76
|
$null = $psboundparameters.remove('DisableSecureBoot')
|
|
76
77
|
$null = $psboundparameters.remove('ProcessorCount')
|
|
78
|
+
$null = $psboundparameters.remove('StaticMacAddress')
|
|
77
79
|
$null = $psboundparameters.remove('UseDynamicMemory')
|
|
78
80
|
$null = $psboundparameters.remove('DynamicMemoryMinBytes')
|
|
79
81
|
$null = $psboundparameters.remove('DynamicMemoryMaxBytes')
|
|
@@ -97,6 +99,9 @@ function New-KitchenVM {
|
|
|
97
99
|
if (-not [string]::IsNullOrEmpty($boot_iso_path)) {
|
|
98
100
|
Mount-VMISO -Id $vm.Id -Path $boot_iso_path
|
|
99
101
|
}
|
|
102
|
+
if ($StaticMacAddress -ne $null) {
|
|
103
|
+
Set-VMNetworkAdapter -VMName $vm.VMName -StaticMacAddress $StaticMacAddress
|
|
104
|
+
}
|
|
100
105
|
if ($EnableGuestServices -and (Get-command Enable-VMIntegrationService -ErrorAction SilentlyContinue)) {
|
|
101
106
|
Enable-VMIntegrationService -VM $vm -Name 'Guest Service Interface'
|
|
102
107
|
}
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-hyperv
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steven Murawski
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
179
179
|
version: '0'
|
|
180
180
|
requirements: []
|
|
181
181
|
rubyforge_project:
|
|
182
|
-
rubygems_version: 2.6.
|
|
182
|
+
rubygems_version: 2.6.11
|
|
183
183
|
signing_key:
|
|
184
184
|
specification_version: 4
|
|
185
185
|
summary: Hyper-V Driver for Test-Kitchen
|