kitchen-hyperv 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cane +1 -1
- data/.gitignore +15 -15
- data/CHANGELOG.md +17 -1
- data/Gemfile +15 -15
- data/LICENSE.txt +22 -22
- data/README.md +4 -0
- data/Rakefile +68 -68
- data/kitchen-hyperv.gemspec +32 -32
- data/lib/kitchen/driver/hyperv.rb +11 -16
- data/lib/kitchen/driver/hyperv_version.rb +22 -22
- data/lib/kitchen/driver/powershell.rb +212 -205
- data/spec/kitchen/driver/hyperv_spec.rb +70 -70
- data/spec/spec_helper.rb +43 -43
- data/spec/support/hyperv.Tests.ps1 +43 -43
- data/support/hyperv.ps1 +14 -2
- metadata +3 -4
data/spec/spec_helper.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2012, Fletcher Nichol
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
gem "minitest"
|
20
|
-
gem "minitest-stub-const"
|
21
|
-
|
22
|
-
if ENV["CODECLIMATE_REPO_TOKEN"]
|
23
|
-
require "codeclimate-test-reporter"
|
24
|
-
CodeClimate::TestReporter.start
|
25
|
-
elsif ENV["COVERAGE"]
|
26
|
-
require "simplecov"
|
27
|
-
SimpleCov.profiles.define "gem" do
|
28
|
-
command_name "Specs"
|
29
|
-
|
30
|
-
add_filter ".gem/"
|
31
|
-
add_filter "/spec/"
|
32
|
-
add_filter "/lib/vendor/"
|
33
|
-
|
34
|
-
add_group "Libraries", "/lib/"
|
35
|
-
end
|
36
|
-
SimpleCov.start "gem"
|
37
|
-
end
|
38
|
-
|
39
|
-
require 'minitest'
|
40
|
-
require 'minitest/stub_const'
|
41
|
-
require "minitest/autorun"
|
42
|
-
require "mocha/setup"
|
43
|
-
require "tempfile"
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2012, Fletcher Nichol
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
gem "minitest"
|
20
|
+
gem "minitest-stub-const"
|
21
|
+
|
22
|
+
if ENV["CODECLIMATE_REPO_TOKEN"]
|
23
|
+
require "codeclimate-test-reporter"
|
24
|
+
CodeClimate::TestReporter.start
|
25
|
+
elsif ENV["COVERAGE"]
|
26
|
+
require "simplecov"
|
27
|
+
SimpleCov.profiles.define "gem" do
|
28
|
+
command_name "Specs"
|
29
|
+
|
30
|
+
add_filter ".gem/"
|
31
|
+
add_filter "/spec/"
|
32
|
+
add_filter "/lib/vendor/"
|
33
|
+
|
34
|
+
add_group "Libraries", "/lib/"
|
35
|
+
end
|
36
|
+
SimpleCov.start "gem"
|
37
|
+
end
|
38
|
+
|
39
|
+
require 'minitest'
|
40
|
+
require 'minitest/stub_const'
|
41
|
+
require "minitest/autorun"
|
42
|
+
require "mocha/setup"
|
43
|
+
require "tempfile"
|
@@ -1,43 +1,43 @@
|
|
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
|
-
|
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
|
+
|
data/support/hyperv.ps1
CHANGED
@@ -76,14 +76,17 @@ function New-KitchenVM
|
|
76
76
|
$UseDynamicMemory,
|
77
77
|
$DynamicMemoryMinBytes,
|
78
78
|
$DynamicMemoryMaxBytes,
|
79
|
-
$boot_iso_path
|
79
|
+
$boot_iso_path,
|
80
|
+
$EnableGuestServices
|
80
81
|
)
|
81
82
|
$null = $psboundparameters.remove('ProcessorCount')
|
82
83
|
$null = $psboundparameters.remove('UseDynamicMemory')
|
83
84
|
$null = $psboundparameters.remove('DynamicMemoryMinBytes')
|
84
85
|
$null = $psboundparameters.remove('DynamicMemoryMaxBytes')
|
85
86
|
$null = $psboundparameters.remove('boot_iso_path')
|
87
|
+
$null = $psboundparameters.remove('EnableGuestServices')
|
86
88
|
$UseDynamicMemory = [Convert]::ToBoolean($UseDynamicMemory)
|
89
|
+
$null = [bool]::TryParse($EnableGuestServices,[ref]$EnableGuestServices)
|
87
90
|
|
88
91
|
$vm = new-vm @psboundparameters |
|
89
92
|
Set-Vm -ProcessorCount $ProcessorCount -passthru
|
@@ -95,6 +98,9 @@ function New-KitchenVM
|
|
95
98
|
}
|
96
99
|
if (-not [string]::IsNullOrEmpty($boot_iso_path)) {
|
97
100
|
Mount-VMISO -Id $vm.Id -Path $boot_iso_path
|
101
|
+
}
|
102
|
+
if ($EnableGuestServices -and (Get-command Enable-VMIntegrationService -ErrorAction SilentlyContinue)) {
|
103
|
+
Enable-VMIntegrationService -VM $vm -Name 'Guest Service Interface'
|
98
104
|
}
|
99
105
|
$vm | Start-Vm -passthru |
|
100
106
|
foreach {
|
@@ -211,5 +217,11 @@ function Mount-VMISO
|
|
211
217
|
[cmdletbinding()]
|
212
218
|
param($Id, $Path)
|
213
219
|
|
214
|
-
|
220
|
+
if ((Get-VM -Id $Id).Generation -eq 2)
|
221
|
+
{
|
222
|
+
Add-VMDvdDrive (Get-VM -Id $Id).Name | Set-VMDvdDrive -VMName (Get-VM -Id $Id).Name -Path $Path
|
223
|
+
}
|
224
|
+
|
225
|
+
Set-VMDvdDrive -VMName (Get-VM -Id $Id).Name -Path $Path
|
215
226
|
}
|
227
|
+
|
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.3.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: 2016-
|
11
|
+
date: 2016-11-28 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.6
|
183
183
|
signing_key:
|
184
184
|
specification_version: 4
|
185
185
|
summary: Hyper-V Driver for Test-Kitchen
|
@@ -187,4 +187,3 @@ test_files:
|
|
187
187
|
- spec/kitchen/driver/hyperv_spec.rb
|
188
188
|
- spec/spec_helper.rb
|
189
189
|
- spec/support/hyperv.Tests.ps1
|
190
|
-
has_rdoc:
|