kitchen-hyperv 0.1.20 → 0.2.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/.cane +1 -1
- data/.gitignore +15 -15
- data/Gemfile +15 -10
- data/{CHANGELOG.md → HISTORY.md} +21 -21
- data/LICENSE.txt +22 -22
- data/README.md +2 -0
- data/Rakefile +69 -52
- data/kitchen-hyperv.gemspec +32 -31
- data/lib/kitchen/driver/hyperv.rb +31 -9
- data/lib/kitchen/driver/hyperv_version.rb +22 -22
- data/lib/kitchen/driver/powershell.rb +193 -194
- data/spec/kitchen/driver/hyperv_spec.rb +70 -70
- data/spec/spec_helper.rb +43 -43
- data/spec/support/hyperv.Tests.ps1 +43 -2
- data/support/hyperv.ps1 +19 -6
- metadata +18 -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,2 +1,43 @@
|
|
|
1
|
-
. $PSScriptRoot\..\..\support\hyperv.ps1
|
|
2
|
-
|
|
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
|
@@ -17,7 +17,14 @@ $ProgressPreference = 'SilentlyContinue'
|
|
|
17
17
|
function New-DifferencingDisk
|
|
18
18
|
{
|
|
19
19
|
[cmdletbinding()]
|
|
20
|
-
param (
|
|
20
|
+
param (
|
|
21
|
+
[parameter(Mandatory)]
|
|
22
|
+
[ValidateNotNullOrEmpty()]
|
|
23
|
+
[string[]]$Path,
|
|
24
|
+
[parameter(Mandatory)]
|
|
25
|
+
[ValidateNotNullOrEmpty()]
|
|
26
|
+
[string]$ParentPath
|
|
27
|
+
)
|
|
21
28
|
if (-not (Test-Path $Path))
|
|
22
29
|
{
|
|
23
30
|
$null = new-vhd @psboundparameters -Differencing
|
|
@@ -68,12 +75,14 @@ function New-KitchenVM
|
|
|
68
75
|
$ProcessorCount,
|
|
69
76
|
$UseDynamicMemory,
|
|
70
77
|
$DynamicMemoryMinBytes,
|
|
71
|
-
$DynamicMemoryMaxBytes
|
|
78
|
+
$DynamicMemoryMaxBytes,
|
|
79
|
+
$boot_iso_path
|
|
72
80
|
)
|
|
73
81
|
$null = $psboundparameters.remove('ProcessorCount')
|
|
74
82
|
$null = $psboundparameters.remove('UseDynamicMemory')
|
|
75
83
|
$null = $psboundparameters.remove('DynamicMemoryMinBytes')
|
|
76
84
|
$null = $psboundparameters.remove('DynamicMemoryMaxBytes')
|
|
85
|
+
$null = $psboundparameters.remove('boot_iso_path')
|
|
77
86
|
$UseDynamicMemory = [Convert]::ToBoolean($UseDynamicMemory)
|
|
78
87
|
|
|
79
88
|
$vm = new-vm @psboundparameters |
|
|
@@ -84,7 +93,9 @@ function New-KitchenVM
|
|
|
84
93
|
else {
|
|
85
94
|
$vm | Set-VMMemory -DynamicMemoryEnabled $false
|
|
86
95
|
}
|
|
87
|
-
|
|
96
|
+
if (-not [string]::IsNullOrEmpty($boot_iso_path)) {
|
|
97
|
+
Mount-VMISO -Id $vm.Id -Path $boot_iso_path
|
|
98
|
+
}
|
|
88
99
|
$vm | Start-Vm -passthru |
|
|
89
100
|
foreach {
|
|
90
101
|
$vm = $_
|
|
@@ -188,9 +199,11 @@ function Get-VmDetail
|
|
|
188
199
|
|
|
189
200
|
function Get-DefaultVMSwitch
|
|
190
201
|
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
202
|
+
[CmdletBinding()]
|
|
203
|
+
param ($Name)
|
|
204
|
+
Get-VMSwitch @PSBoundParameters |
|
|
205
|
+
Select-Object -First 1 |
|
|
206
|
+
Select-Object Name, Id
|
|
194
207
|
}
|
|
195
208
|
|
|
196
209
|
function Mount-VMISO
|
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.2.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-05-
|
|
11
|
+
date: 2016-05-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -108,6 +108,20 @@ dependencies:
|
|
|
108
108
|
- - ">="
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: countloc
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
126
|
name: test-kitchen
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -132,8 +146,8 @@ files:
|
|
|
132
146
|
- ".cane"
|
|
133
147
|
- ".gitignore"
|
|
134
148
|
- ".rubocop.yml"
|
|
135
|
-
- CHANGELOG.md
|
|
136
149
|
- Gemfile
|
|
150
|
+
- HISTORY.md
|
|
137
151
|
- LICENSE.txt
|
|
138
152
|
- README.md
|
|
139
153
|
- Rakefile
|
|
@@ -165,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
165
179
|
version: '0'
|
|
166
180
|
requirements: []
|
|
167
181
|
rubyforge_project:
|
|
168
|
-
rubygems_version: 2.6.
|
|
182
|
+
rubygems_version: 2.6.4
|
|
169
183
|
signing_key:
|
|
170
184
|
specification_version: 4
|
|
171
185
|
summary: Hyper-V Driver for Test-Kitchen
|