kitchen-vagrant 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kitchen/driver/vagrant_version.rb +1 -1
- metadata +3 -17
- data/.gitignore +0 -17
- data/.rspec +0 -2
- data/.travis.yml +0 -24
- data/CHANGELOG.md +0 -569
- data/Gemfile +0 -15
- data/Guardfile +0 -23
- data/README.md +0 -653
- data/Rakefile +0 -46
- data/example/kitchen.vagrant.yml +0 -122
- data/kitchen-vagrant.gemspec +0 -30
- data/spec/kitchen/driver/vagrant_spec.rb +0 -2115
- data/spec/spec_helper.rb +0 -33
data/Rakefile
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
|
5
|
-
require "rspec/core/rake_task"
|
6
|
-
desc "Run all specs in spec directory"
|
7
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
8
|
-
t.pattern = "spec/**/*_spec.rb"
|
9
|
-
end
|
10
|
-
|
11
|
-
desc "Run all test suites"
|
12
|
-
task :test => [:spec]
|
13
|
-
|
14
|
-
require "chefstyle"
|
15
|
-
require "rubocop/rake_task"
|
16
|
-
RuboCop::RakeTask.new(:style) do |task|
|
17
|
-
task.options << "--display-cop-names"
|
18
|
-
end
|
19
|
-
|
20
|
-
desc "Display LOC stats"
|
21
|
-
task :stats do
|
22
|
-
puts "\n## Production Code Stats"
|
23
|
-
sh "countloc -r lib/kitchen"
|
24
|
-
puts "\n## Test Code Stats"
|
25
|
-
sh "countloc -r spec"
|
26
|
-
end
|
27
|
-
|
28
|
-
desc "Run all quality tasks"
|
29
|
-
task :quality => [:style, :stats]
|
30
|
-
|
31
|
-
task :default => [:test, :quality]
|
32
|
-
|
33
|
-
begin
|
34
|
-
require "github_changelog_generator/task"
|
35
|
-
|
36
|
-
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
37
|
-
config.future_release = Kitchen::Driver::VAGRANT_VERSION
|
38
|
-
config.enhancement_labels = "enhancement,Enhancement,New Feature,Feature,Improvement".split(",")
|
39
|
-
config.bug_labels = "bug,Bug".split(",")
|
40
|
-
config.exclude_labels = %w{Duplicate Question Discussion No_Changelog}
|
41
|
-
end
|
42
|
-
rescue LoadError
|
43
|
-
task :changelog do
|
44
|
-
raise "github_changelog_generator not installed! gem install github_changelog_generator."
|
45
|
-
end
|
46
|
-
end
|
data/example/kitchen.vagrant.yml
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
---
|
2
|
-
# All the options for kitchen-vagrant enumerated and annotated
|
3
|
-
# options are illustrated where they most commonly would be set
|
4
|
-
driver:
|
5
|
-
name: vagrant # test-kitchen default
|
6
|
-
|
7
|
-
# If not set, check for the environment variable `VAGRANT_DEFAULT_PROVIDER`
|
8
|
-
# If that is unset, default to `virtualbox`
|
9
|
-
# provider: virtualbox
|
10
|
-
|
11
|
-
# If `true` check if the box is up-to-date
|
12
|
-
# box_check_update: nil
|
13
|
-
|
14
|
-
# If `true`, then SSL certificates from the server will not be verified.
|
15
|
-
# box_download_insecure: nil
|
16
|
-
|
17
|
-
# A relative path to a CA certificate bundle
|
18
|
-
# for verifying endpoints with custom certificates
|
19
|
-
# box_download_ca_cert: nil
|
20
|
-
|
21
|
-
# Integer for setting custom boot timeout
|
22
|
-
# boot_timeout: nil
|
23
|
-
# Hash for passing k/v options to specific
|
24
|
-
# providers for customization
|
25
|
-
# emtpy by default
|
26
|
-
# customize:
|
27
|
-
# memory: 1024
|
28
|
-
# cpuexecutioncap: 50
|
29
|
-
# If `true`, allows GUI mode for Vagrant providers
|
30
|
-
# that support this feature
|
31
|
-
# gui: nil
|
32
|
-
|
33
|
-
# If `true`, use "Linked Clones" or "Differencing Disk"
|
34
|
-
# options for providers that support this feature
|
35
|
-
# This can reduce disk usage and offer performance benefits.
|
36
|
-
# linked_clone: nil
|
37
|
-
|
38
|
-
# An Array of network customizations for the virtual machine.
|
39
|
-
# Each Array element is itself an Array of arguments to be passed to the
|
40
|
-
# config.vm.network method
|
41
|
-
# network: []
|
42
|
-
|
43
|
-
# An optional hook to run a command immediately prior to
|
44
|
-
# the `vagrant up --no-provisioner` command being executed.
|
45
|
-
# **CAUTION**
|
46
|
-
# pre_create_command: nil
|
47
|
-
|
48
|
-
# Enables Vagrant built-in provisioning
|
49
|
-
# Useful in conjunction with `vagrantfiles`
|
50
|
-
# provision: false
|
51
|
-
|
52
|
-
# Hash for passing k/v options to Vagrant's SSH
|
53
|
-
# configuration. Only needed for advanaced/custom
|
54
|
-
# configuration. **CAUTION**
|
55
|
-
# ssh: {}
|
56
|
-
|
57
|
-
# An array of arrays that configure a synced folder
|
58
|
-
# This value is automatically configured if using
|
59
|
-
# the `cache_directory` option. Otherwise, empty.
|
60
|
-
# synced_folders:
|
61
|
-
# - ["data/%{instance_name}", "/opt/instance_data"]
|
62
|
-
# - ["/host_path", "/vm_path", "create: true, type: :nfs"]
|
63
|
-
|
64
|
-
# This should only need to get set if the Vagrant binary
|
65
|
-
# isn't in the PATH or there is a specific location desired
|
66
|
-
# vagrant_binary: "vagrant"
|
67
|
-
|
68
|
-
# By default, use the Vagrantfile.erb that is part of the gem
|
69
|
-
# otherwise use whatever the user provides here. **CAUTION**
|
70
|
-
# vagrantfile_erb: Alt_Vagrantfile.erb
|
71
|
-
|
72
|
-
# An array of paths to Vagrantfiles
|
73
|
-
# Empty by default
|
74
|
-
# vagrantfiles: []
|
75
|
-
|
76
|
-
# We only set this to a path for a subset of known bento boxes
|
77
|
-
# driver.windows_os? ? "/omnibus/cache" : "/tmp/omnibus/cache"
|
78
|
-
# if set to `false` this will disable caching entirely
|
79
|
-
# cache_directory: /tmp/omnibus/cache
|
80
|
-
|
81
|
-
# Path to kitchen's global cache directory, primarily for caching
|
82
|
-
# chef-client downlaods
|
83
|
-
# Default is File.expand_path("~/.kitchen/cache")
|
84
|
-
# kitchen_cache_directory: /Users/cheeseplus/.kitchen/cache
|
85
|
-
|
86
|
-
# If `box` or `machine`, sets the respective value for
|
87
|
-
# config.cache.scope. Any other truthy value yields `box`
|
88
|
-
# cachier: nil
|
89
|
-
|
90
|
-
provisioner:
|
91
|
-
name: chef_zero
|
92
|
-
|
93
|
-
verifier:
|
94
|
-
name: inspec
|
95
|
-
|
96
|
-
platforms:
|
97
|
-
# We will grab boxes from bento on Vagrant Cloud
|
98
|
-
# for a set of common platforms
|
99
|
-
- name: ubuntu-16.04
|
100
|
-
- name: centos-7
|
101
|
-
# Otherwise for platforms we don't know, the box needs to exist locally
|
102
|
-
# and be known to Vagrant, otherwise provide `box` or `box_url`
|
103
|
-
- name: openbsd-5.6
|
104
|
-
driver:
|
105
|
-
# Versioned boxes from Vagrant Cloud can be utilized
|
106
|
-
# `box_version` only works when `box` uses the Vagrant Cloud syntax
|
107
|
-
# box: organization/openbsd-56
|
108
|
-
# box_version: 1.2.3
|
109
|
-
# If not using Vagrant Cloud, the box can be fetched
|
110
|
-
# remotely via `http(s)://` or locally via `file://`
|
111
|
-
# `box` requires a value
|
112
|
-
box: openbsd-5.6
|
113
|
-
box_url: http://url.tld/openbsd-5.6.box
|
114
|
-
|
115
|
-
suites:
|
116
|
-
- name: default
|
117
|
-
driver:
|
118
|
-
# If Windows, this is nil otherwise it's set to
|
119
|
-
# "#{driver.instance.name}.vagrantup.com"
|
120
|
-
# vm_hostname: "custom.tld"
|
121
|
-
run_list:
|
122
|
-
- recipe[cookbook::default]
|
data/kitchen-vagrant.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "kitchen/driver/vagrant_version.rb"
|
5
|
-
require "English"
|
6
|
-
|
7
|
-
Gem::Specification.new do |gem|
|
8
|
-
gem.name = "kitchen-vagrant"
|
9
|
-
gem.version = Kitchen::Driver::VAGRANT_VERSION
|
10
|
-
gem.license = "Apache-2.0"
|
11
|
-
gem.authors = ["Fletcher Nichol"]
|
12
|
-
gem.email = ["fnichol@nichol.ca"]
|
13
|
-
gem.description = "Kitchen::Driver::Vagrant - A Vagrant Driver for Test Kitchen."
|
14
|
-
gem.summary = gem.description
|
15
|
-
gem.homepage = "https://github.com/test-kitchen/kitchen-vagrant/"
|
16
|
-
|
17
|
-
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
18
|
-
gem.executables = []
|
19
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
-
gem.require_paths = ["lib"]
|
21
|
-
|
22
|
-
gem.add_dependency "test-kitchen", "~> 1.4"
|
23
|
-
|
24
|
-
gem.add_development_dependency "countloc", "~> 0.4"
|
25
|
-
gem.add_development_dependency "rake"
|
26
|
-
gem.add_development_dependency "rspec", "~> 3.2"
|
27
|
-
gem.add_development_dependency "simplecov", "~> 0.9"
|
28
|
-
|
29
|
-
gem.add_development_dependency "chefstyle"
|
30
|
-
end
|
@@ -1,2115 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2015, 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
|
-
require_relative "../../spec_helper"
|
20
|
-
|
21
|
-
require "logger"
|
22
|
-
require "stringio"
|
23
|
-
|
24
|
-
require "kitchen/driver/vagrant"
|
25
|
-
require "kitchen/provisioner/dummy"
|
26
|
-
require "kitchen/transport/dummy"
|
27
|
-
require "kitchen/verifier/dummy"
|
28
|
-
|
29
|
-
describe Kitchen::Driver::Vagrant do
|
30
|
-
|
31
|
-
let(:logged_output) { StringIO.new }
|
32
|
-
let(:logger) { Logger.new(logged_output) }
|
33
|
-
let(:config) { { :kitchen_root => "/kroot" } }
|
34
|
-
let(:platform) { Kitchen::Platform.new(:name => "fooos-99") }
|
35
|
-
let(:suite) { Kitchen::Suite.new(:name => "suitey") }
|
36
|
-
let(:verifier) { Kitchen::Verifier::Dummy.new }
|
37
|
-
let(:provisioner) { Kitchen::Provisioner::Dummy.new }
|
38
|
-
let(:lifecycle_hooks) { Kitchen::LifecycleHooks.new({}) }
|
39
|
-
let(:transport) { Kitchen::Transport::Dummy.new }
|
40
|
-
let(:state_file) { double("state_file") }
|
41
|
-
let(:state) { Hash.new }
|
42
|
-
let(:env) { Hash.new }
|
43
|
-
|
44
|
-
let(:driver_object) { Kitchen::Driver::Vagrant.new(config) }
|
45
|
-
|
46
|
-
let(:driver) do
|
47
|
-
d = driver_object
|
48
|
-
instance
|
49
|
-
d
|
50
|
-
end
|
51
|
-
|
52
|
-
let(:driver_with_no_instance) do
|
53
|
-
driver_object
|
54
|
-
end
|
55
|
-
|
56
|
-
let(:instance) do
|
57
|
-
Kitchen::Instance.new(
|
58
|
-
:verifier => verifier,
|
59
|
-
:driver => driver_object,
|
60
|
-
:logger => logger,
|
61
|
-
:suite => suite,
|
62
|
-
:platform => platform,
|
63
|
-
:provisioner => provisioner,
|
64
|
-
:lifecycle_hooks => lifecycle_hooks,
|
65
|
-
:transport => transport,
|
66
|
-
:state_file => state_file
|
67
|
-
)
|
68
|
-
end
|
69
|
-
|
70
|
-
module RunCommandStub
|
71
|
-
def run_command(_cmd, options = {})
|
72
|
-
options
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
before(:all) do
|
77
|
-
Kitchen::Driver::Vagrant.instance_eval { include RunCommandStub }
|
78
|
-
end
|
79
|
-
|
80
|
-
before(:each) { stub_const("ENV", env) }
|
81
|
-
|
82
|
-
after do
|
83
|
-
driver_object.class.send(:winrm_plugin_passed=, nil)
|
84
|
-
driver_object.class.send(:vagrant_version=, nil)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "driver api_version is 2" do
|
88
|
-
expect(driver.diagnose_plugin[:api_version]).to eq(2)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "plugin_version is set to Kitchen::Vagrant::VERSION" do
|
92
|
-
expect(driver.diagnose_plugin[:version]).to eq(
|
93
|
-
Kitchen::Driver::VAGRANT_VERSION)
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "#run_command" do
|
97
|
-
|
98
|
-
context "when invoked from a clean environment" do
|
99
|
-
|
100
|
-
it "passes through environment variables" do
|
101
|
-
options = driver.send(
|
102
|
-
:run_command,
|
103
|
-
"cmd",
|
104
|
-
:environment => { "EV1" => "Val1", "EV2" => "Val2" })
|
105
|
-
expect(options[:environment]["EV1"]).to eq("Val1")
|
106
|
-
expect(options[:environment]["EV2"]).to eq("Val2")
|
107
|
-
end
|
108
|
-
|
109
|
-
it "leaves path alone" do
|
110
|
-
path = "/foo/#{File::PATH_SEPARATOR}/bar"
|
111
|
-
options = driver.send(
|
112
|
-
:run_command,
|
113
|
-
"cmd",
|
114
|
-
:environment => { "PATH" => path })
|
115
|
-
expect(options[:environment]["PATH"]).to eq(path)
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
context "when invoked from a bundler[:environment]" do
|
121
|
-
|
122
|
-
let(:bundler_env) do
|
123
|
-
{
|
124
|
-
"BUNDLE_BIN_PATH" => "bundle_bin_path",
|
125
|
-
"BUNDLE_GEMFILE" => "bundle_gem_file",
|
126
|
-
"GEM_HOME" => "gem_home",
|
127
|
-
"GEM_PATH" => "gem_path",
|
128
|
-
"GEM_ROOT" => "gem_root",
|
129
|
-
"RUBYLIB" => "ruby_lib",
|
130
|
-
"RUBYOPT" => "ruby_opt",
|
131
|
-
"_ORIGINAL_GEM_PATH" => "original_gem_path",
|
132
|
-
}
|
133
|
-
end
|
134
|
-
|
135
|
-
it "removes all bundler related variables" do
|
136
|
-
env.merge!(bundler_env)
|
137
|
-
options = driver.send(:run_command, "cmd")
|
138
|
-
bundler_env.each do |k, _v|
|
139
|
-
expect(options[:environment]).to include(k)
|
140
|
-
expect(options[:environment][k]).to eq(nil)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
it "fixes path if it notices gem_home in it" do
|
145
|
-
allow(RbConfig::CONFIG).to receive(:[]).with("host_os").
|
146
|
-
and_return("linux")
|
147
|
-
env.merge!(bundler_env)
|
148
|
-
env["PATH"] = "gem_home/bin#{File::PATH_SEPARATOR}/something/else"
|
149
|
-
options = driver.send(:run_command, "cmd")
|
150
|
-
puts(options)
|
151
|
-
expect(options[:environment]["PATH"]).to eq("/something/else")
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
describe "configuration" do
|
157
|
-
|
158
|
-
let(:cache_directory_array) do
|
159
|
-
[
|
160
|
-
File.expand_path("~/.kitchen/cache"),
|
161
|
-
"/tmp/omnibus/cache",
|
162
|
-
"create: true",
|
163
|
-
]
|
164
|
-
end
|
165
|
-
|
166
|
-
%w{centos debian fedora opensuse ubuntu oracle freebsd hardenedbsd}.each do |name|
|
167
|
-
|
168
|
-
context "for known bento platform names starting with #{name}" do
|
169
|
-
|
170
|
-
before { allow(platform).to receive(:name) { "#{name}-99.04" } }
|
171
|
-
|
172
|
-
it "sets :box based on the platform name by default" do
|
173
|
-
expect(driver[:box]).to eq("bento/#{name}-99.04")
|
174
|
-
end
|
175
|
-
|
176
|
-
it "sets :box to a custom value" do
|
177
|
-
config[:box] = "booya"
|
178
|
-
|
179
|
-
expect(driver[:box]).to eq("booya")
|
180
|
-
end
|
181
|
-
|
182
|
-
it "sets :box_url to nil" do
|
183
|
-
config[:provider] = "the-next-coolness"
|
184
|
-
|
185
|
-
expect(driver[:box_url]).to eq(nil)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
context "for unknown bento platform names" do
|
191
|
-
|
192
|
-
before { allow(platform).to receive(:name) { "slackware-14.1" } }
|
193
|
-
|
194
|
-
it "sets :box based on the platform name by default" do
|
195
|
-
expect(driver[:box]).to eq("slackware-14.1")
|
196
|
-
end
|
197
|
-
|
198
|
-
it "sets :box to a custom value" do
|
199
|
-
config[:box] = "booya"
|
200
|
-
|
201
|
-
expect(driver[:box]).to eq("booya")
|
202
|
-
end
|
203
|
-
|
204
|
-
it "sets :box_url to nil" do
|
205
|
-
expect(driver[:box_url]).to eq(nil)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
it "sets :box_check_update to nil by default" do
|
210
|
-
expect(driver[:box_check_update]).to eq(nil)
|
211
|
-
end
|
212
|
-
|
213
|
-
it "sets :box_check_update to a custom value" do
|
214
|
-
config[:box_check_update] = true
|
215
|
-
|
216
|
-
expect(driver[:box_check_update]).to eq(true)
|
217
|
-
end
|
218
|
-
|
219
|
-
it "sets :box_download_ca_cert to nil by default" do
|
220
|
-
expect(driver[:box_download_ca_cert]).to eq(nil)
|
221
|
-
end
|
222
|
-
|
223
|
-
it "sets :box_download_ca_cert to a custom value" do
|
224
|
-
config[:box_download_ca_cert] = "cacert.pem"
|
225
|
-
|
226
|
-
expect(driver[:box_download_ca_cert]).to eq("/kroot/cacert.pem")
|
227
|
-
end
|
228
|
-
|
229
|
-
it "sets :box_download_insecure to nil by default" do
|
230
|
-
expect(driver[:box_download_insecure]).to eq(nil)
|
231
|
-
end
|
232
|
-
|
233
|
-
it "sets :box_download_insecure to a custom value" do
|
234
|
-
config[:box_download_insecure] = true
|
235
|
-
|
236
|
-
expect(driver[:box_download_insecure]).to eq(true)
|
237
|
-
end
|
238
|
-
|
239
|
-
it "sets :box_version to nil by default" do
|
240
|
-
expect(driver[:box_version]).to eq(nil)
|
241
|
-
end
|
242
|
-
|
243
|
-
it "sets :box_version to a custom value" do
|
244
|
-
config[:box_version] = "1.2.3"
|
245
|
-
|
246
|
-
expect(driver[:box_version]).to eq("1.2.3")
|
247
|
-
end
|
248
|
-
|
249
|
-
it "sets :boot_timeout to nil by default" do
|
250
|
-
expect(driver[:boot_timeout]).to eq(nil)
|
251
|
-
end
|
252
|
-
|
253
|
-
it "sets :boot_timeout to a custom value" do
|
254
|
-
config[:boot_timeout] = 600
|
255
|
-
|
256
|
-
expect(driver[:boot_timeout]).to eq(600)
|
257
|
-
end
|
258
|
-
|
259
|
-
it "sets :customize to an empty hash by default" do
|
260
|
-
expect(driver[:customize]).to eq({})
|
261
|
-
end
|
262
|
-
|
263
|
-
it "sets :customize to a custom value" do
|
264
|
-
config[:customize] = { :a => "b", :c => { :d => "e" } }
|
265
|
-
|
266
|
-
expect(driver[:customize]).to eq(:a => "b", :c => { :d => "e" })
|
267
|
-
end
|
268
|
-
|
269
|
-
it "sets :gui to nil by default" do
|
270
|
-
expect(driver[:gui]).to eq(nil)
|
271
|
-
end
|
272
|
-
|
273
|
-
it "sets :linked_clone to nil by default" do
|
274
|
-
expect(driver[:linked_clone]).to eq(nil)
|
275
|
-
end
|
276
|
-
|
277
|
-
it "sets :network to an empty array by default" do
|
278
|
-
expect(driver[:network]).to eq([])
|
279
|
-
end
|
280
|
-
|
281
|
-
it "sets :network to a custom value" do
|
282
|
-
config[:network] = [
|
283
|
-
["forwarded_port", :guest => 80, :host => 8080],
|
284
|
-
]
|
285
|
-
|
286
|
-
expect(driver[:network]).to eq([
|
287
|
-
["forwarded_port", :guest => 80, :host => 8080],
|
288
|
-
])
|
289
|
-
end
|
290
|
-
|
291
|
-
it "sets :pre_create_command to nil by default" do
|
292
|
-
expect(driver[:pre_create_command]).to eq(nil)
|
293
|
-
end
|
294
|
-
|
295
|
-
it "sets :pre_create_command to a custom value" do
|
296
|
-
config[:pre_create_command] = "execute yo"
|
297
|
-
|
298
|
-
expect(driver[:pre_create_command]).to eq("execute yo")
|
299
|
-
end
|
300
|
-
|
301
|
-
it "replaces {{vagrant_root}} in :pre_create_command" do
|
302
|
-
config[:pre_create_command] = "{{vagrant_root}}/candy"
|
303
|
-
|
304
|
-
expect(driver[:pre_create_command]).to eq(
|
305
|
-
"/kroot/.kitchen/kitchen-vagrant/suitey-fooos-99/candy"
|
306
|
-
)
|
307
|
-
end
|
308
|
-
|
309
|
-
it "sets :provision to false by default" do
|
310
|
-
expect(driver[:provision]).to eq(false)
|
311
|
-
end
|
312
|
-
|
313
|
-
it "sets :provision to a custom value" do
|
314
|
-
config[:provision] = true
|
315
|
-
|
316
|
-
expect(driver[:provision]).to eq(true)
|
317
|
-
end
|
318
|
-
|
319
|
-
it "sets :provider to virtualbox by default" do
|
320
|
-
expect(driver[:provider]).to eq("virtualbox")
|
321
|
-
end
|
322
|
-
|
323
|
-
it "sets :provider to the value of VAGRANT_DEFAULT_PROVIDER from ENV" do
|
324
|
-
env["VAGRANT_DEFAULT_PROVIDER"] = "vcool"
|
325
|
-
|
326
|
-
expect(driver[:provider]).to eq("vcool")
|
327
|
-
end
|
328
|
-
|
329
|
-
it "sets :provider to a custom value" do
|
330
|
-
config[:provider] = "mything"
|
331
|
-
|
332
|
-
expect(driver[:provider]).to eq("mything")
|
333
|
-
end
|
334
|
-
|
335
|
-
it "sets :ssh to an empty hash by default" do
|
336
|
-
expect(driver[:ssh]).to eq({})
|
337
|
-
end
|
338
|
-
|
339
|
-
it "sets :ssh to a custom value" do
|
340
|
-
config[:ssh] = { :a => "b", :c => { :d => "e" } }
|
341
|
-
|
342
|
-
expect(driver[:ssh]).to eq(:a => "b", :c => { :d => "e" })
|
343
|
-
end
|
344
|
-
|
345
|
-
it "sets :synced_folders with the cache_directory for select bento boxes" do
|
346
|
-
config[:box] = "bento/centos-99"
|
347
|
-
expect(driver[:synced_folders]).to eq([cache_directory_array])
|
348
|
-
end
|
349
|
-
|
350
|
-
it "does not set :synced_folders when cache_directory is false" do
|
351
|
-
config[:box] = "bento/centos-99"
|
352
|
-
config[:cache_directory] = false
|
353
|
-
expect(driver[:synced_folders]).to eq([])
|
354
|
-
end
|
355
|
-
|
356
|
-
it "does not set :synced_folders to cache_directory on freebsd systems" do
|
357
|
-
allow(platform).to receive(:name).and_return("freebsd-99")
|
358
|
-
expect(driver[:synced_folders]).to eq([])
|
359
|
-
end
|
360
|
-
|
361
|
-
it "sets :synced_folders to a custom value" do
|
362
|
-
config[:synced_folders] = [
|
363
|
-
["/host_path", "/vm_path", "create: true, type: :nfs"],
|
364
|
-
]
|
365
|
-
|
366
|
-
expect(driver[:synced_folders]).to eq([
|
367
|
-
[
|
368
|
-
File.expand_path("/host_path"),
|
369
|
-
"/vm_path", "create: true, type: :nfs"
|
370
|
-
],
|
371
|
-
])
|
372
|
-
end
|
373
|
-
|
374
|
-
it "replaces %{instance_name} with instance name in :synced_folders" do
|
375
|
-
config[:synced_folders] = [
|
376
|
-
["/root/%{instance_name}", "/vm_path", "stuff"],
|
377
|
-
]
|
378
|
-
|
379
|
-
expect(driver[:synced_folders]).to eq([
|
380
|
-
[File.expand_path("/root/suitey-fooos-99"), "/vm_path", "stuff"],
|
381
|
-
])
|
382
|
-
end
|
383
|
-
|
384
|
-
it "expands source paths relative to :kitchen_root in :synced_folders" do
|
385
|
-
config[:synced_folders] = [
|
386
|
-
["./a", "/vm_path", "stuff"],
|
387
|
-
]
|
388
|
-
|
389
|
-
expect(driver[:synced_folders]).to eq([
|
390
|
-
[File.expand_path("/kroot/a"), "/vm_path", "stuff"],
|
391
|
-
])
|
392
|
-
end
|
393
|
-
|
394
|
-
it "sets options to 'nil' if not set in :synced_folders entry" do
|
395
|
-
config[:synced_folders] = [
|
396
|
-
["/host_path", "/vm_path", nil],
|
397
|
-
]
|
398
|
-
|
399
|
-
expect(driver[:synced_folders]).to eq([
|
400
|
-
[File.expand_path("/host_path"), "/vm_path", "nil"],
|
401
|
-
])
|
402
|
-
end
|
403
|
-
|
404
|
-
it "sets :vagrant_binary to 'vagrant' by default" do
|
405
|
-
expect(driver[:vagrant_binary]).to eq("vagrant")
|
406
|
-
end
|
407
|
-
|
408
|
-
it "sets :vagrant_binary to a custom value" do
|
409
|
-
config[:vagrant_binary] = "vagrant.cmd"
|
410
|
-
expect(driver[:vagrant_binary]).to eq("vagrant.cmd")
|
411
|
-
end
|
412
|
-
|
413
|
-
it "sets :vagrantfile_erb to a default" do
|
414
|
-
expect(driver[:vagrantfile_erb]).to match(
|
415
|
-
%r{/kitchen-vagrant/templates/Vagrantfile\.erb$}
|
416
|
-
)
|
417
|
-
end
|
418
|
-
|
419
|
-
it "sets :vagrantfile_erb to a default value" do
|
420
|
-
config[:vagrantfile_erb] = "/a/Vagrantfile.erb"
|
421
|
-
|
422
|
-
expect(driver[:vagrantfile_erb]).to eq(
|
423
|
-
File.expand_path("/a/Vagrantfile.erb"))
|
424
|
-
end
|
425
|
-
|
426
|
-
it "expands path for :vagrantfile_erb" do
|
427
|
-
config[:vagrantfile_erb] = "Yep.erb"
|
428
|
-
|
429
|
-
expect(driver[:vagrantfile_erb]).to eq(
|
430
|
-
File.expand_path("/kroot/Yep.erb"))
|
431
|
-
end
|
432
|
-
|
433
|
-
it "sets :vagrantfiles to an empty array by default" do
|
434
|
-
expect(driver[:vagrantfiles]).to eq([])
|
435
|
-
end
|
436
|
-
|
437
|
-
it "sets and expands paths in :vagrantfiles" do
|
438
|
-
config[:vagrantfiles] = %w{one two three}
|
439
|
-
|
440
|
-
expect(driver[:vagrantfiles]).to eq(
|
441
|
-
%w{/kroot/one /kroot/two /kroot/three}.map { |f| File.expand_path(f) }
|
442
|
-
)
|
443
|
-
end
|
444
|
-
|
445
|
-
context "for unix os_types" do
|
446
|
-
|
447
|
-
before { allow(platform).to receive(:os_type).and_return("unix") }
|
448
|
-
|
449
|
-
it "sets :vm_hostname to the instance name by default" do
|
450
|
-
expect(driver[:vm_hostname]).to eq("suitey-fooos-99.vagrantup.com")
|
451
|
-
end
|
452
|
-
|
453
|
-
it "sets :vm_hostname to a custom value" do
|
454
|
-
config[:vm_hostname] = "okay"
|
455
|
-
|
456
|
-
expect(driver[:vm_hostname]).to eq("okay")
|
457
|
-
end
|
458
|
-
end
|
459
|
-
|
460
|
-
context "for windows os_types" do
|
461
|
-
|
462
|
-
before { allow(platform).to receive(:os_type).and_return("windows") }
|
463
|
-
|
464
|
-
it "sets :vm_hostname to nil by default" do
|
465
|
-
expect(driver[:vm_hostname]).to eq(nil)
|
466
|
-
end
|
467
|
-
|
468
|
-
it "sets :vm_hostname to a custom value, truncated to 12 chars" do
|
469
|
-
config[:vm_hostname] = "this-is-a-pretty-long-name-ya-think"
|
470
|
-
|
471
|
-
expect(driver[:vm_hostname]).to eq("this-is-a--k")
|
472
|
-
end
|
473
|
-
|
474
|
-
it "replaces %{instance_name} with instance name in :synced_folders" do
|
475
|
-
config[:synced_folders] = [
|
476
|
-
["/root/%{instance_name}", "/vm_path", "stuff"],
|
477
|
-
]
|
478
|
-
|
479
|
-
expect(driver[:synced_folders]).to eq([
|
480
|
-
[File.expand_path("/root/suitey-fooos-99"), "/vm_path", "stuff"],
|
481
|
-
])
|
482
|
-
end
|
483
|
-
end
|
484
|
-
|
485
|
-
context "when cache_directory is customized" do
|
486
|
-
|
487
|
-
let(:custom_cache_directory_array) do
|
488
|
-
[
|
489
|
-
File.expand_path("~/.kitchen/cache"),
|
490
|
-
"Z:\\awesome\\cache",
|
491
|
-
"create: true",
|
492
|
-
]
|
493
|
-
end
|
494
|
-
|
495
|
-
before do
|
496
|
-
config[:box] = "bento/centos-99"
|
497
|
-
config[:cache_directory] = "Z:\\awesome\\cache"
|
498
|
-
end
|
499
|
-
|
500
|
-
it "sets :synced_folders with the custom cache_directory" do
|
501
|
-
expect(driver[:synced_folders]).to eq([custom_cache_directory_array])
|
502
|
-
end
|
503
|
-
|
504
|
-
it "replaces %{instance_name} with instance name in :synced_folders" do
|
505
|
-
config[:synced_folders] = [
|
506
|
-
["/root/%{instance_name}", "/vm_path", "stuff"],
|
507
|
-
]
|
508
|
-
|
509
|
-
expect(driver[:synced_folders]).to eq([
|
510
|
-
[File.expand_path("/root/suitey-fooos-99"), "/vm_path", "stuff"],
|
511
|
-
custom_cache_directory_array,
|
512
|
-
])
|
513
|
-
end
|
514
|
-
end
|
515
|
-
end
|
516
|
-
|
517
|
-
describe "#verify_dependencies" do
|
518
|
-
|
519
|
-
it "passes for supported versions of Vagrant" do
|
520
|
-
with_modern_vagrant
|
521
|
-
|
522
|
-
driver.verify_dependencies
|
523
|
-
end
|
524
|
-
|
525
|
-
it "passes for supported versions of Vagrant when it has no instances" do
|
526
|
-
with_modern_vagrant
|
527
|
-
|
528
|
-
driver_with_no_instance.verify_dependencies
|
529
|
-
end
|
530
|
-
|
531
|
-
it "raises a UserError for unsupported versions of Vagrant" do
|
532
|
-
with_unsupported_vagrant
|
533
|
-
|
534
|
-
expect { driver.verify_dependencies }.to raise_error(
|
535
|
-
Kitchen::UserError, /Please upgrade to version 1.1.0 or higher/
|
536
|
-
)
|
537
|
-
end
|
538
|
-
|
539
|
-
it "raises a UserError for a missing Vagrant command" do
|
540
|
-
allow(driver_object).to receive(:run_command).
|
541
|
-
with("vagrant --version", any_args).and_raise(Errno::ENOENT)
|
542
|
-
|
543
|
-
expect { driver.verify_dependencies }.to raise_error(
|
544
|
-
Kitchen::UserError, /Vagrant 1.1.0 or higher is not installed/
|
545
|
-
)
|
546
|
-
end
|
547
|
-
end
|
548
|
-
|
549
|
-
describe "#load_needed_dependencies!" do
|
550
|
-
|
551
|
-
describe "with winrm transport" do
|
552
|
-
|
553
|
-
before { allow(transport).to receive(:name).and_return("WinRM") }
|
554
|
-
|
555
|
-
it "old version of Vagrant raises UserError" do
|
556
|
-
with_vagrant("1.5.0")
|
557
|
-
|
558
|
-
expect { instance }.to raise_error(
|
559
|
-
Kitchen::Error, /Please upgrade to version 1.6 or higher/
|
560
|
-
)
|
561
|
-
end
|
562
|
-
|
563
|
-
it "modern vagrant without plugin installed raises UserError" do
|
564
|
-
with_modern_vagrant
|
565
|
-
allow(driver_object).to receive(:run_command).
|
566
|
-
with("vagrant plugin list", any_args).and_return("nope (1.2.3)")
|
567
|
-
|
568
|
-
expect { instance }.to raise_error(
|
569
|
-
Kitchen::Error, /vagrant plugin install vagrant-winrm/
|
570
|
-
)
|
571
|
-
end
|
572
|
-
|
573
|
-
it "modern vagrant with plugin installed succeeds" do
|
574
|
-
with_modern_vagrant
|
575
|
-
allow(driver_object).to receive(:run_command).
|
576
|
-
with("vagrant plugin list", any_args).
|
577
|
-
and_return("vagrant-winrm (1.2.3)")
|
578
|
-
|
579
|
-
instance
|
580
|
-
end
|
581
|
-
end
|
582
|
-
|
583
|
-
describe "without winrm transport" do
|
584
|
-
|
585
|
-
before { allow(transport).to receive(:name).and_return("Anything") }
|
586
|
-
|
587
|
-
it "old version of Vagrant succeeds" do
|
588
|
-
with_vagrant("1.5.0")
|
589
|
-
|
590
|
-
instance
|
591
|
-
end
|
592
|
-
|
593
|
-
it "modern vagrant without plugin installed succeeds" do
|
594
|
-
with_modern_vagrant
|
595
|
-
allow(driver_object).to receive(:run_command).
|
596
|
-
with("vagrant plugin list", any_args).and_return("nope (1.2.3)")
|
597
|
-
|
598
|
-
instance
|
599
|
-
end
|
600
|
-
|
601
|
-
it "modern vagrant with plugin installed succeeds" do
|
602
|
-
with_modern_vagrant
|
603
|
-
allow(driver_object).to receive(:run_command).
|
604
|
-
with("vagrant plugin list", any_args).
|
605
|
-
and_return("vagrant-winrm (1.2.3)")
|
606
|
-
|
607
|
-
instance
|
608
|
-
end
|
609
|
-
end
|
610
|
-
end
|
611
|
-
|
612
|
-
describe "#create" do
|
613
|
-
|
614
|
-
let(:cmd) { driver.create(state) }
|
615
|
-
|
616
|
-
let(:vagrant_root) do
|
617
|
-
File.join(%W{
|
618
|
-
#{@dir} .kitchen kitchen-vagrant suitey-fooos-99
|
619
|
-
})
|
620
|
-
end
|
621
|
-
|
622
|
-
before do
|
623
|
-
@dir = Dir.mktmpdir("kitchen_root")
|
624
|
-
config[:kitchen_root] = @dir
|
625
|
-
|
626
|
-
allow(driver).to receive(:run_command).and_return("")
|
627
|
-
with_modern_vagrant
|
628
|
-
end
|
629
|
-
|
630
|
-
after do
|
631
|
-
FileUtils.remove_entry_secure(@dir)
|
632
|
-
end
|
633
|
-
|
634
|
-
it "logs a message on debug level for creating the Vagrantfile" do
|
635
|
-
cmd
|
636
|
-
|
637
|
-
expect(logged_output.string).to match(
|
638
|
-
/^D, .+ DEBUG -- : Creating Vagrantfile for \<suitey-fooos-99\> /
|
639
|
-
)
|
640
|
-
end
|
641
|
-
|
642
|
-
it "creates a Vagrantfile in the vagrant root directory" do
|
643
|
-
cmd
|
644
|
-
|
645
|
-
expect(File.exist?(File.join(vagrant_root, "Vagrantfile"))).to eq(true)
|
646
|
-
end
|
647
|
-
|
648
|
-
it "calls Transport's #wait_until_ready" do
|
649
|
-
conn = double("connection")
|
650
|
-
allow(transport).to receive(:connection).with(state).and_return(conn)
|
651
|
-
expect(conn).to receive(:wait_until_ready)
|
652
|
-
|
653
|
-
cmd
|
654
|
-
end
|
655
|
-
|
656
|
-
it "logs the Vagrantfile contents on debug level" do
|
657
|
-
cmd
|
658
|
-
|
659
|
-
expect(debug_lines).to match(Regexp.new(<<-REGEXP.gsub(/^ {8}/, "")))
|
660
|
-
------------
|
661
|
-
Vagrant.configure\("2"\) do \|c\|
|
662
|
-
.*
|
663
|
-
end
|
664
|
-
------------
|
665
|
-
REGEXP
|
666
|
-
end
|
667
|
-
|
668
|
-
it "raises ActionFailed if a custom Vagrantfile template was not found" do
|
669
|
-
config[:vagrantfile_erb] = "/a/bunch/of/nope"
|
670
|
-
|
671
|
-
expect { cmd }.to raise_error(
|
672
|
-
Kitchen::ActionFailed, /^Could not find Vagrantfile template/
|
673
|
-
)
|
674
|
-
end
|
675
|
-
|
676
|
-
it "runs the pre create command, if set" do
|
677
|
-
config[:pre_create_command] = "echo heya"
|
678
|
-
expect(driver).to receive(:run_command).with("echo heya", any_args)
|
679
|
-
|
680
|
-
cmd
|
681
|
-
end
|
682
|
-
|
683
|
-
it "runs vagrant up with --no-provision if :provision is falsey" do
|
684
|
-
config[:provision] = false
|
685
|
-
expect(driver).to receive(:run_command).
|
686
|
-
with("vagrant up --no-provision --provider virtualbox", any_args)
|
687
|
-
|
688
|
-
cmd
|
689
|
-
end
|
690
|
-
|
691
|
-
it "runs vagrant up without --no-provision if :provision is truthy" do
|
692
|
-
config[:provision] = true
|
693
|
-
expect(driver).to receive(:run_command).
|
694
|
-
with("vagrant up --provider virtualbox", any_args)
|
695
|
-
|
696
|
-
cmd
|
697
|
-
end
|
698
|
-
|
699
|
-
it "runs vagrant up with a custom provider if :provider is set" do
|
700
|
-
config[:provider] = "bananas"
|
701
|
-
expect(driver).to receive(:run_command).
|
702
|
-
with("vagrant up --no-provision --provider bananas", any_args)
|
703
|
-
|
704
|
-
cmd
|
705
|
-
end
|
706
|
-
|
707
|
-
describe "for state" do
|
708
|
-
|
709
|
-
context "for non-WinRM-based transports" do
|
710
|
-
|
711
|
-
let(:output) do
|
712
|
-
<<-OUTPUT.gsub(/^ {10}/, "")
|
713
|
-
Host hehe
|
714
|
-
HostName 192.168.32.64
|
715
|
-
User vagrant
|
716
|
-
Port 2022
|
717
|
-
UserKnownHostsFile /dev/null
|
718
|
-
StrictHostKeyChecking no
|
719
|
-
PasswordAuthentication no
|
720
|
-
IdentityFile /path/to/private_key
|
721
|
-
IdentitiesOnly yes
|
722
|
-
LogLevel FATAL
|
723
|
-
OUTPUT
|
724
|
-
end
|
725
|
-
|
726
|
-
before do
|
727
|
-
allow(transport).to receive(:name).and_return("Coolness")
|
728
|
-
allow(driver).to receive(:run_command).
|
729
|
-
with("vagrant ssh-config", any_args).and_return(output)
|
730
|
-
end
|
731
|
-
|
732
|
-
it "sets :hostname from ssh-config" do
|
733
|
-
cmd
|
734
|
-
|
735
|
-
expect(state).to include(:hostname => "192.168.32.64")
|
736
|
-
end
|
737
|
-
|
738
|
-
it "sets :port from ssh-config" do
|
739
|
-
cmd
|
740
|
-
|
741
|
-
expect(state).to include(:port => "2022")
|
742
|
-
end
|
743
|
-
|
744
|
-
it "sets :username from ssh-config" do
|
745
|
-
cmd
|
746
|
-
|
747
|
-
expect(state).to include(:username => "vagrant")
|
748
|
-
end
|
749
|
-
|
750
|
-
it "does not set :password by default" do
|
751
|
-
cmd
|
752
|
-
|
753
|
-
expect(state.keys).to_not include(:password)
|
754
|
-
end
|
755
|
-
|
756
|
-
it "sets :password if Password is in ssh-config" do
|
757
|
-
output.concat(" Password yep\n")
|
758
|
-
cmd
|
759
|
-
|
760
|
-
expect(state).to include(:password => "yep")
|
761
|
-
end
|
762
|
-
|
763
|
-
it "sets :ssh_key from ssh-config" do
|
764
|
-
cmd
|
765
|
-
|
766
|
-
expect(state).to include(:ssh_key => "/path/to/private_key")
|
767
|
-
end
|
768
|
-
|
769
|
-
it "does not set :proxy_command by default" do
|
770
|
-
cmd
|
771
|
-
|
772
|
-
expect(state.keys).to_not include(:proxy_command)
|
773
|
-
end
|
774
|
-
|
775
|
-
it "sets :proxy_command if ProxyCommand is in ssh-config" do
|
776
|
-
output.concat(" ProxyCommand echo proxy\n")
|
777
|
-
cmd
|
778
|
-
|
779
|
-
expect(state).to include(:proxy_command => "echo proxy")
|
780
|
-
end
|
781
|
-
end
|
782
|
-
|
783
|
-
context "for WinRM-based transports" do
|
784
|
-
|
785
|
-
let(:output) do
|
786
|
-
<<-OUTPUT.gsub(/^ {10}/, "")
|
787
|
-
Host hehe
|
788
|
-
HostName 192.168.32.64
|
789
|
-
User vagrant
|
790
|
-
Password yep
|
791
|
-
Port 9999
|
792
|
-
RDPPort 5555
|
793
|
-
OUTPUT
|
794
|
-
end
|
795
|
-
|
796
|
-
before do
|
797
|
-
allow(transport).to receive(:name).and_return("WinRM")
|
798
|
-
allow(driver).to receive(:run_command).
|
799
|
-
with("vagrant winrm-config", any_args).and_return(output)
|
800
|
-
end
|
801
|
-
|
802
|
-
it "sets :hostname from winrm-config" do
|
803
|
-
cmd
|
804
|
-
|
805
|
-
expect(state).to include(:hostname => "192.168.32.64")
|
806
|
-
end
|
807
|
-
|
808
|
-
it "sets :port from winrm-config" do
|
809
|
-
cmd
|
810
|
-
|
811
|
-
expect(state).to include(:port => "9999")
|
812
|
-
end
|
813
|
-
|
814
|
-
it "sets :username from winrm-config" do
|
815
|
-
cmd
|
816
|
-
|
817
|
-
expect(state).to include(:username => "vagrant")
|
818
|
-
end
|
819
|
-
|
820
|
-
it "sets :password from winrm-config" do
|
821
|
-
cmd
|
822
|
-
|
823
|
-
expect(state).to include(:password => "yep")
|
824
|
-
end
|
825
|
-
|
826
|
-
it "sets :rdp_port from winrm-config" do
|
827
|
-
cmd
|
828
|
-
|
829
|
-
expect(state).to include(:rdp_port => "5555")
|
830
|
-
end
|
831
|
-
end
|
832
|
-
end
|
833
|
-
|
834
|
-
it "logs a message on info level" do
|
835
|
-
cmd
|
836
|
-
|
837
|
-
expect(logged_output.string).to match(
|
838
|
-
/I, .+ INFO -- : Vagrant instance \<suitey-fooos-99\> created\.$/
|
839
|
-
)
|
840
|
-
end
|
841
|
-
end
|
842
|
-
|
843
|
-
describe "#destroy" do
|
844
|
-
|
845
|
-
let(:cmd) { driver.destroy(state) }
|
846
|
-
|
847
|
-
let(:vagrant_root) do
|
848
|
-
File.join(%W{
|
849
|
-
#{@dir} .kitchen kitchen-vagrant suitey-fooos-99
|
850
|
-
})
|
851
|
-
end
|
852
|
-
|
853
|
-
before do
|
854
|
-
@dir = Dir.mktmpdir("kitchen_root")
|
855
|
-
config[:kitchen_root] = @dir
|
856
|
-
|
857
|
-
allow(driver).to receive(:run_command).and_return("")
|
858
|
-
with_modern_vagrant
|
859
|
-
|
860
|
-
FileUtils.mkdir_p(vagrant_root)
|
861
|
-
state[:hostname] = "hosta"
|
862
|
-
end
|
863
|
-
|
864
|
-
after do
|
865
|
-
FileUtils.remove_entry_secure(@dir)
|
866
|
-
end
|
867
|
-
|
868
|
-
it "logs a message on debug level for creating the Vagrantfile" do
|
869
|
-
cmd
|
870
|
-
|
871
|
-
expect(logged_output.string).to match(
|
872
|
-
/^D, .+ DEBUG -- : Creating Vagrantfile for \<suitey-fooos-99\> /
|
873
|
-
)
|
874
|
-
end
|
875
|
-
|
876
|
-
it "logs the Vagrantfile contents on debug level" do
|
877
|
-
cmd
|
878
|
-
|
879
|
-
expect(debug_lines).to match(Regexp.new(<<-REGEXP.gsub(/^ {8}/, "")))
|
880
|
-
------------
|
881
|
-
Vagrant.configure\("2"\) do \|c\|
|
882
|
-
.*
|
883
|
-
end
|
884
|
-
------------
|
885
|
-
REGEXP
|
886
|
-
end
|
887
|
-
|
888
|
-
it "does not run vagrant destroy if :hostname is not present in state" do
|
889
|
-
state.delete(:hostname)
|
890
|
-
expect(driver).to_not receive(:run_command).
|
891
|
-
with("vagrant destroy -f", any_args)
|
892
|
-
|
893
|
-
cmd
|
894
|
-
end
|
895
|
-
|
896
|
-
it "closes the transport connection" do
|
897
|
-
connection = double(Kitchen::Transport::Base::Connection)
|
898
|
-
allow(transport).to receive(:connection).with(state) { connection }
|
899
|
-
expect(connection).to receive(:close)
|
900
|
-
|
901
|
-
cmd
|
902
|
-
end
|
903
|
-
|
904
|
-
it "runs vagrant destroy" do
|
905
|
-
expect(driver).to receive(:run_command).
|
906
|
-
with("vagrant destroy -f", any_args)
|
907
|
-
|
908
|
-
cmd
|
909
|
-
end
|
910
|
-
|
911
|
-
it "deletes the vagrant root directory" do
|
912
|
-
expect(File.directory?(vagrant_root)).to eq(true)
|
913
|
-
cmd
|
914
|
-
expect(File.directory?(vagrant_root)).to eq(false)
|
915
|
-
end
|
916
|
-
|
917
|
-
it "logs a message on info level" do
|
918
|
-
cmd
|
919
|
-
|
920
|
-
expect(logged_output.string).to match(
|
921
|
-
/I, .+ INFO -- : Vagrant instance \<suitey-fooos-99\> destroyed\.$/
|
922
|
-
)
|
923
|
-
end
|
924
|
-
|
925
|
-
it "deletes :hostname from state" do
|
926
|
-
cmd
|
927
|
-
|
928
|
-
expect(state.keys).to_not include(:hostname)
|
929
|
-
end
|
930
|
-
end
|
931
|
-
|
932
|
-
describe "Vagrantfile" do
|
933
|
-
|
934
|
-
let(:cmd) { driver.create(state) }
|
935
|
-
|
936
|
-
let(:vagrant_root) do
|
937
|
-
File.join(%W{
|
938
|
-
#{@dir} .kitchen kitchen-vagrant suitey-fooos-99
|
939
|
-
})
|
940
|
-
end
|
941
|
-
|
942
|
-
before do
|
943
|
-
@dir = Dir.mktmpdir("kitchen_root")
|
944
|
-
config[:kitchen_root] = @dir
|
945
|
-
|
946
|
-
allow(driver).to receive(:run_command).and_return("")
|
947
|
-
with_modern_vagrant
|
948
|
-
end
|
949
|
-
|
950
|
-
after do
|
951
|
-
FileUtils.remove_entry_secure(@dir)
|
952
|
-
end
|
953
|
-
|
954
|
-
it "disables the vagrant-berkshelf plugin is present" do
|
955
|
-
cmd
|
956
|
-
|
957
|
-
expect(vagrantfile).to match(regexify(
|
958
|
-
"c.berkshelf.enabled = false " \
|
959
|
-
"if Vagrant.has_plugin?(\"vagrant-berkshelf\")"
|
960
|
-
))
|
961
|
-
end
|
962
|
-
|
963
|
-
it "sets no cache.scope if missing" do
|
964
|
-
config[:cachier] = nil
|
965
|
-
cmd
|
966
|
-
|
967
|
-
expect(vagrantfile).to_not match(regexify(%{c.cache.scope}, :partial))
|
968
|
-
end
|
969
|
-
|
970
|
-
it "sets cache.scope to :box if :cachier is set" do
|
971
|
-
config[:cachier] = true
|
972
|
-
cmd
|
973
|
-
|
974
|
-
expect(vagrantfile).to match(regexify(%{c.cache.scope = :box}))
|
975
|
-
end
|
976
|
-
|
977
|
-
it "sets cache.scope if :cachier is set to a custom value" do
|
978
|
-
config[:cachier] = ":machine"
|
979
|
-
cmd
|
980
|
-
|
981
|
-
expect(vagrantfile).to match(regexify(%{c.cache.scope = :machine}))
|
982
|
-
end
|
983
|
-
|
984
|
-
it "sets the vm.box" do
|
985
|
-
cmd
|
986
|
-
|
987
|
-
expect(vagrantfile).to match(regexify(%{c.vm.box = "fooos-99"}))
|
988
|
-
end
|
989
|
-
|
990
|
-
it "sets the vm.hostname" do
|
991
|
-
config[:vm_hostname] = "charlie"
|
992
|
-
cmd
|
993
|
-
|
994
|
-
expect(vagrantfile).to match(regexify(%{c.vm.hostname = "charlie"}))
|
995
|
-
end
|
996
|
-
|
997
|
-
it "disables the /vagrant synced folder by default" do
|
998
|
-
cmd
|
999
|
-
|
1000
|
-
expect(vagrantfile).to match(regexify(
|
1001
|
-
%{c.vm.synced_folder ".", "/vagrant", disabled: true}
|
1002
|
-
))
|
1003
|
-
end
|
1004
|
-
|
1005
|
-
it "creates an empty provider block by default" do
|
1006
|
-
config[:provider] = "wowza"
|
1007
|
-
cmd
|
1008
|
-
|
1009
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {6}/, "").chomp))
|
1010
|
-
c.vm.provider :wowza do |p|
|
1011
|
-
end
|
1012
|
-
RUBY
|
1013
|
-
end
|
1014
|
-
|
1015
|
-
it "requires no Vagrantfiles by default" do
|
1016
|
-
cmd
|
1017
|
-
|
1018
|
-
expect(vagrantfile).to_not match(regexify("require"))
|
1019
|
-
end
|
1020
|
-
|
1021
|
-
it "requires each entry in :vagranfiles" do
|
1022
|
-
config[:vagrantfiles] = %w{/a /b /c}
|
1023
|
-
cmd
|
1024
|
-
|
1025
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1026
|
-
load "/a"
|
1027
|
-
load "/b"
|
1028
|
-
load "/c"
|
1029
|
-
RUBY
|
1030
|
-
end
|
1031
|
-
|
1032
|
-
it "sets no vm.box_url if missing" do
|
1033
|
-
config[:box_url] = nil
|
1034
|
-
cmd
|
1035
|
-
|
1036
|
-
expect(vagrantfile).to_not match(regexify(%{c.vm.box_url}, :partial))
|
1037
|
-
end
|
1038
|
-
|
1039
|
-
it "sets vm.box_url if :box_url is set" do
|
1040
|
-
config[:box_url] = "dat.url"
|
1041
|
-
cmd
|
1042
|
-
|
1043
|
-
expect(vagrantfile).to match(regexify(%{c.vm.box_url = "dat.url"}))
|
1044
|
-
end
|
1045
|
-
|
1046
|
-
it "sets no vm.box_version if missing" do
|
1047
|
-
config[:box_version] = nil
|
1048
|
-
cmd
|
1049
|
-
|
1050
|
-
expect(vagrantfile).to_not match(regexify(%{c.vm.box_version}, :partial))
|
1051
|
-
end
|
1052
|
-
|
1053
|
-
it "sets vm.box_version if :box_version is set" do
|
1054
|
-
config[:box_version] = "a.b.c"
|
1055
|
-
cmd
|
1056
|
-
|
1057
|
-
expect(vagrantfile).to match(regexify(%{c.vm.box_version = "a.b.c"}))
|
1058
|
-
end
|
1059
|
-
|
1060
|
-
it "sets no vm.boot_timeout if missing" do
|
1061
|
-
config[:boot_timeout] = nil
|
1062
|
-
cmd
|
1063
|
-
|
1064
|
-
expect(vagrantfile).to_not match(regexify(%{c.vm.boot_timeout}, :partial))
|
1065
|
-
end
|
1066
|
-
|
1067
|
-
it "sets no vm.boot_timeout if :boot_timeout is set" do
|
1068
|
-
config[:boot_timeout] = 600
|
1069
|
-
cmd
|
1070
|
-
|
1071
|
-
expect(vagrantfile).to match(
|
1072
|
-
regexify(%{c.vm.boot_timeout = 600}, :partial)
|
1073
|
-
)
|
1074
|
-
end
|
1075
|
-
|
1076
|
-
it "sets no vm.box_check_update if missing" do
|
1077
|
-
config[:box_check_update] = nil
|
1078
|
-
cmd
|
1079
|
-
|
1080
|
-
expect(vagrantfile).to_not match(
|
1081
|
-
regexify(%{c.vm.box_check_update}, :partial)
|
1082
|
-
)
|
1083
|
-
end
|
1084
|
-
|
1085
|
-
it "sets vm.box_check_update to false if :box_check_update is false" do
|
1086
|
-
config[:box_check_update] = false
|
1087
|
-
cmd
|
1088
|
-
|
1089
|
-
expect(vagrantfile).to match(regexify(%{c.vm.box_check_update = false}))
|
1090
|
-
end
|
1091
|
-
|
1092
|
-
it "sets no vm.box_download_insecure if missing" do
|
1093
|
-
config[:box_download_insecure] = nil
|
1094
|
-
cmd
|
1095
|
-
|
1096
|
-
expect(vagrantfile).to_not match(
|
1097
|
-
regexify(%{c.vm.box_download_insecure}, :partial)
|
1098
|
-
)
|
1099
|
-
end
|
1100
|
-
|
1101
|
-
it "sets vm.box_download_insecure to false
|
1102
|
-
if :box_download_insecure is false" do
|
1103
|
-
|
1104
|
-
config[:box_download_insecure] = false
|
1105
|
-
cmd
|
1106
|
-
|
1107
|
-
expect(
|
1108
|
-
vagrantfile).to match(regexify(%{c.vm.box_download_insecure = "false"})
|
1109
|
-
)
|
1110
|
-
end
|
1111
|
-
|
1112
|
-
it "sets vm.box_download_insecure if :box_download_insecure is set" do
|
1113
|
-
config[:box_download_insecure] = "um"
|
1114
|
-
cmd
|
1115
|
-
|
1116
|
-
expect(
|
1117
|
-
vagrantfile).to match(regexify(%{c.vm.box_download_insecure = "um"})
|
1118
|
-
)
|
1119
|
-
end
|
1120
|
-
|
1121
|
-
it "sets no vm.communicator if missing" do
|
1122
|
-
config[:communicator] = nil
|
1123
|
-
cmd
|
1124
|
-
|
1125
|
-
expect(vagrantfile).to_not match(regexify(%{c.vm.communicator}, :partial))
|
1126
|
-
end
|
1127
|
-
|
1128
|
-
it "sets vm.communicator if :communicator is set" do
|
1129
|
-
config[:communicator] = "wat"
|
1130
|
-
cmd
|
1131
|
-
|
1132
|
-
expect(vagrantfile).to match(regexify(%{c.vm.communicator = "wat"}))
|
1133
|
-
end
|
1134
|
-
|
1135
|
-
it "sets no vm.guest if missing" do
|
1136
|
-
config[:guest] = nil
|
1137
|
-
cmd
|
1138
|
-
|
1139
|
-
expect(vagrantfile).to_not match(regexify(%{c.vm.guest}, :partial))
|
1140
|
-
end
|
1141
|
-
|
1142
|
-
it "sets vm.guest if :guest is set" do
|
1143
|
-
config[:guest] = "mac"
|
1144
|
-
cmd
|
1145
|
-
|
1146
|
-
expect(vagrantfile).to match(regexify(%{c.vm.guest = "mac"}))
|
1147
|
-
end
|
1148
|
-
|
1149
|
-
it "sets no ssh.username if missing" do
|
1150
|
-
config[:username] = nil
|
1151
|
-
cmd
|
1152
|
-
|
1153
|
-
expect(vagrantfile).to_not match(regexify(%{c.ssh.username}, :partial))
|
1154
|
-
end
|
1155
|
-
|
1156
|
-
it "sets ssh.username if :username is set" do
|
1157
|
-
config[:username] = "jdoe"
|
1158
|
-
cmd
|
1159
|
-
|
1160
|
-
expect(vagrantfile).to match(regexify(%{c.ssh.username = "jdoe"}))
|
1161
|
-
end
|
1162
|
-
|
1163
|
-
it "sets no ssh.password if missing" do
|
1164
|
-
config[:password] = nil
|
1165
|
-
cmd
|
1166
|
-
|
1167
|
-
expect(vagrantfile).to_not match(regexify(%{c.ssh.password}, :partial))
|
1168
|
-
end
|
1169
|
-
|
1170
|
-
it "sets ssh.password if :password is set" do
|
1171
|
-
config[:password] = "okay"
|
1172
|
-
cmd
|
1173
|
-
|
1174
|
-
expect(vagrantfile).to match(regexify(%{c.ssh.password = "okay"}))
|
1175
|
-
end
|
1176
|
-
|
1177
|
-
it "sets communicator.username if :communicator and :username are set" do
|
1178
|
-
config[:communicator] = "wat"
|
1179
|
-
config[:username] = "jdoe"
|
1180
|
-
cmd
|
1181
|
-
|
1182
|
-
expect(vagrantfile).to match(regexify(%{c.wat.username = "jdoe"}))
|
1183
|
-
end
|
1184
|
-
|
1185
|
-
it "sets communicator.password if :communicator and :password are set" do
|
1186
|
-
config[:communicator] = "wat"
|
1187
|
-
config[:password] = "okay"
|
1188
|
-
cmd
|
1189
|
-
|
1190
|
-
expect(vagrantfile).to match(regexify(%{c.wat.password = "okay"}))
|
1191
|
-
end
|
1192
|
-
|
1193
|
-
it "sets no ssh.private_key_path if missing" do
|
1194
|
-
config[:ssh_key] = nil
|
1195
|
-
cmd
|
1196
|
-
|
1197
|
-
expect(vagrantfile).to_not match(
|
1198
|
-
regexify(%{c.ssh.private_key_path}, :partial)
|
1199
|
-
)
|
1200
|
-
end
|
1201
|
-
|
1202
|
-
it "sets ssh.private_key_path if :ssh_key is set" do
|
1203
|
-
config[:ssh_key] = "okay"
|
1204
|
-
cmd
|
1205
|
-
|
1206
|
-
expect(vagrantfile).to match(regexify(%{c.ssh.private_key_path = "okay"}))
|
1207
|
-
end
|
1208
|
-
|
1209
|
-
it "adds a vm.ssh line for each key/value pair in :ssh" do
|
1210
|
-
config[:ssh] = {
|
1211
|
-
:username => %{jdoe},
|
1212
|
-
:password => %{secret},
|
1213
|
-
:private_key_path => %{/key},
|
1214
|
-
:insert_key => false,
|
1215
|
-
}
|
1216
|
-
cmd
|
1217
|
-
|
1218
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {6}/, "").chomp))
|
1219
|
-
c.ssh.username = "jdoe"
|
1220
|
-
c.ssh.password = "secret"
|
1221
|
-
c.ssh.private_key_path = "/key"
|
1222
|
-
c.ssh.insert_key = false
|
1223
|
-
RUBY
|
1224
|
-
end
|
1225
|
-
|
1226
|
-
it "adds a vm.network line for each element in :network" do
|
1227
|
-
config[:network] = [
|
1228
|
-
["forwarded_port", { :guest => 80, :host => 8080 }],
|
1229
|
-
["private_network", { :ip => "192.168.33.33" }],
|
1230
|
-
]
|
1231
|
-
cmd
|
1232
|
-
|
1233
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {6}/, "").chomp))
|
1234
|
-
c.vm.network(:forwarded_port, {:guest=>80, :host=>8080})
|
1235
|
-
c.vm.network(:private_network, {:ip=>"192.168.33.33"})
|
1236
|
-
RUBY
|
1237
|
-
end
|
1238
|
-
|
1239
|
-
it "adds a vm.synced_folder line for each element in :synced_folders" do
|
1240
|
-
config[:synced_folders] = [
|
1241
|
-
["/a/b", "/opt/instance_data", "nil"],
|
1242
|
-
["/host_path", "/vm_path", "create: true, type: :nfs"],
|
1243
|
-
]
|
1244
|
-
cmd
|
1245
|
-
|
1246
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {6}/, "").chomp))
|
1247
|
-
c.vm.synced_folder "/a/b", "/opt/instance_data", nil
|
1248
|
-
c.vm.synced_folder "/host_path", "/vm_path", create: true, type: :nfs
|
1249
|
-
RUBY
|
1250
|
-
end
|
1251
|
-
|
1252
|
-
it "vm.synced_folder scapes the back slashes for Windows paths" do
|
1253
|
-
config[:synced_folders] = [
|
1254
|
-
["/a/b", "C:\\opt\\instance_data", "nil"],
|
1255
|
-
["Z:\\host_path", "/vm_path", "create: true"],
|
1256
|
-
]
|
1257
|
-
cmd
|
1258
|
-
|
1259
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {6}/, "").chomp))
|
1260
|
-
c.vm.synced_folder "/a/b", "C:\\\\opt\\\\instance_data", nil
|
1261
|
-
c.vm.synced_folder "Z:\\\\host_path", "/vm_path", create: true
|
1262
|
-
RUBY
|
1263
|
-
end
|
1264
|
-
|
1265
|
-
context "for virtualbox provider" do
|
1266
|
-
|
1267
|
-
before { config[:provider] = "virtualbox" }
|
1268
|
-
|
1269
|
-
it "sets :name for virtualbox GUI" do
|
1270
|
-
cmd
|
1271
|
-
|
1272
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1273
|
-
c.vm.provider :virtualbox do |p|
|
1274
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1275
|
-
end
|
1276
|
-
RUBY
|
1277
|
-
end
|
1278
|
-
|
1279
|
-
it "adds a line for each element in :customize" do
|
1280
|
-
config[:customize] = {
|
1281
|
-
:a_key => "some value",
|
1282
|
-
:something => "else",
|
1283
|
-
}
|
1284
|
-
cmd
|
1285
|
-
|
1286
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1287
|
-
c.vm.provider :virtualbox do |p|
|
1288
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1289
|
-
p.customize ["modifyvm", :id, "--a_key", "some value"]
|
1290
|
-
p.customize ["modifyvm", :id, "--something", "else"]
|
1291
|
-
end
|
1292
|
-
RUBY
|
1293
|
-
end
|
1294
|
-
|
1295
|
-
it "does not set :gui to nil" do
|
1296
|
-
config[:gui] = nil
|
1297
|
-
cmd
|
1298
|
-
|
1299
|
-
expect(vagrantfile).to_not match(regexify(%{p.gui = }, :partial))
|
1300
|
-
end
|
1301
|
-
|
1302
|
-
it "sets :gui to false if set" do
|
1303
|
-
config[:gui] = false
|
1304
|
-
cmd
|
1305
|
-
|
1306
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1307
|
-
c.vm.provider :virtualbox do |p|
|
1308
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1309
|
-
p.gui = false
|
1310
|
-
end
|
1311
|
-
RUBY
|
1312
|
-
end
|
1313
|
-
|
1314
|
-
it "sets :gui to true if set" do
|
1315
|
-
config[:gui] = true
|
1316
|
-
cmd
|
1317
|
-
|
1318
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1319
|
-
c.vm.provider :virtualbox do |p|
|
1320
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1321
|
-
p.gui = true
|
1322
|
-
end
|
1323
|
-
RUBY
|
1324
|
-
end
|
1325
|
-
|
1326
|
-
it "does not set :linked_clone to nil" do
|
1327
|
-
config[:linked_clone] = nil
|
1328
|
-
cmd
|
1329
|
-
|
1330
|
-
expect(vagrantfile).to_not match(
|
1331
|
-
regexify(%{p.linked_clone = }, :partial))
|
1332
|
-
end
|
1333
|
-
|
1334
|
-
it "sets :linked_clone to false if set" do
|
1335
|
-
config[:linked_clone] = false
|
1336
|
-
cmd
|
1337
|
-
|
1338
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1339
|
-
c.vm.provider :virtualbox do |p|
|
1340
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1341
|
-
p.linked_clone = false
|
1342
|
-
end
|
1343
|
-
RUBY
|
1344
|
-
end
|
1345
|
-
|
1346
|
-
it "sets :linked_clone to true if set" do
|
1347
|
-
config[:linked_clone] = true
|
1348
|
-
cmd
|
1349
|
-
|
1350
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1351
|
-
c.vm.provider :virtualbox do |p|
|
1352
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1353
|
-
p.linked_clone = true
|
1354
|
-
end
|
1355
|
-
RUBY
|
1356
|
-
end
|
1357
|
-
|
1358
|
-
it "add line for single createhd in :customize" do
|
1359
|
-
config[:customize] = {
|
1360
|
-
:createhd => {
|
1361
|
-
:filename => "./d1.vmdk",
|
1362
|
-
:size => 10 * 1024,
|
1363
|
-
},
|
1364
|
-
}
|
1365
|
-
cmd
|
1366
|
-
|
1367
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1368
|
-
c.vm.provider :virtualbox do |p|
|
1369
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1370
|
-
p.customize ["createhd", "--filename", "./d1.vmdk", "--size", 10240]
|
1371
|
-
end
|
1372
|
-
RUBY
|
1373
|
-
end
|
1374
|
-
|
1375
|
-
it "adds lines for multiple createhd in :customize" do
|
1376
|
-
config[:customize] = {
|
1377
|
-
:createhd => [
|
1378
|
-
{
|
1379
|
-
:filename => "./d1.vmdk",
|
1380
|
-
:size => 10 * 1024,
|
1381
|
-
},
|
1382
|
-
{
|
1383
|
-
:filename => "./d2.vmdk",
|
1384
|
-
:size => 20 * 1024,
|
1385
|
-
},
|
1386
|
-
],
|
1387
|
-
}
|
1388
|
-
cmd
|
1389
|
-
|
1390
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1391
|
-
c.vm.provider :virtualbox do |p|
|
1392
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1393
|
-
p.customize ["createhd", "--filename", "./d1.vmdk", "--size", 10240]
|
1394
|
-
p.customize ["createhd", "--filename", "./d2.vmdk", "--size", 20480]
|
1395
|
-
end
|
1396
|
-
RUBY
|
1397
|
-
end
|
1398
|
-
|
1399
|
-
it "adds lines for single storagectl in :customize" do
|
1400
|
-
config[:customize] = {
|
1401
|
-
:storagectl => {
|
1402
|
-
:name => "Custom SATA Controller",
|
1403
|
-
:add => "sata",
|
1404
|
-
:controller => "IntelAHCI",
|
1405
|
-
:portcount => 4,
|
1406
|
-
},
|
1407
|
-
}
|
1408
|
-
cmd
|
1409
|
-
|
1410
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1411
|
-
c.vm.provider :virtualbox do |p|
|
1412
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1413
|
-
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--add", "sata", "--controller", "IntelAHCI", "--portcount", 4]
|
1414
|
-
end
|
1415
|
-
RUBY
|
1416
|
-
end
|
1417
|
-
|
1418
|
-
it "adds lines for multiple storagectl in :customize" do
|
1419
|
-
config[:customize] = {
|
1420
|
-
:storagectl => [
|
1421
|
-
{
|
1422
|
-
:name => "Custom SATA Controller",
|
1423
|
-
:add => "sata",
|
1424
|
-
:controller => "IntelAHCI",
|
1425
|
-
},
|
1426
|
-
{
|
1427
|
-
:name => "Custom SATA Controller",
|
1428
|
-
:portcount => 4,
|
1429
|
-
},
|
1430
|
-
],
|
1431
|
-
}
|
1432
|
-
cmd
|
1433
|
-
|
1434
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1435
|
-
c.vm.provider :virtualbox do |p|
|
1436
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1437
|
-
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--add", "sata", "--controller", "IntelAHCI"]
|
1438
|
-
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--portcount", 4]
|
1439
|
-
end
|
1440
|
-
RUBY
|
1441
|
-
end
|
1442
|
-
|
1443
|
-
it "adds lines for single storageattach in :customize" do
|
1444
|
-
config[:customize] = {
|
1445
|
-
:storageattach => {
|
1446
|
-
:type => "hdd",
|
1447
|
-
:port => 1,
|
1448
|
-
},
|
1449
|
-
}
|
1450
|
-
cmd
|
1451
|
-
|
1452
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1453
|
-
c.vm.provider :virtualbox do |p|
|
1454
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1455
|
-
p.customize ["storageattach", :id, "--type", "hdd", "--port", 1]
|
1456
|
-
end
|
1457
|
-
RUBY
|
1458
|
-
end
|
1459
|
-
|
1460
|
-
it "adds lines for multiple storageattach in :customize" do
|
1461
|
-
config[:customize] = {
|
1462
|
-
:storageattach => [
|
1463
|
-
{
|
1464
|
-
:storagectl => "SATA Controller",
|
1465
|
-
:port => 1,
|
1466
|
-
:device => 0,
|
1467
|
-
:type => "hdd",
|
1468
|
-
:medium => "./d1.vmdk",
|
1469
|
-
},
|
1470
|
-
{
|
1471
|
-
:storagectl => "SATA Controller",
|
1472
|
-
:port => 1,
|
1473
|
-
:device => 1,
|
1474
|
-
:type => "hdd",
|
1475
|
-
:medium => "./d2.vmdk",
|
1476
|
-
},
|
1477
|
-
],
|
1478
|
-
}
|
1479
|
-
cmd
|
1480
|
-
|
1481
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1482
|
-
c.vm.provider :virtualbox do |p|
|
1483
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1484
|
-
p.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--device", 0, "--type", "hdd", "--medium", "./d1.vmdk"]
|
1485
|
-
p.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--device", 1, "--type", "hdd", "--medium", "./d2.vmdk"]
|
1486
|
-
end
|
1487
|
-
RUBY
|
1488
|
-
end
|
1489
|
-
|
1490
|
-
it "adds a line for cpuidset in :customize" do
|
1491
|
-
config[:customize] = {
|
1492
|
-
:cpuidset => %w{00000001 00000002},
|
1493
|
-
}
|
1494
|
-
cmd
|
1495
|
-
|
1496
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1497
|
-
c.vm.provider :virtualbox do |p|
|
1498
|
-
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
|
1499
|
-
p.customize ["modifyvm", :id, "--cpuidset", "00000001", "00000002"]
|
1500
|
-
end
|
1501
|
-
RUBY
|
1502
|
-
end
|
1503
|
-
end
|
1504
|
-
|
1505
|
-
context "for parallels provider" do
|
1506
|
-
|
1507
|
-
before { config[:provider] = "parallels" }
|
1508
|
-
|
1509
|
-
it "adds a line for each element in :customize" do
|
1510
|
-
config[:customize] = {
|
1511
|
-
:a_key => "some value",
|
1512
|
-
:something => "else",
|
1513
|
-
}
|
1514
|
-
cmd
|
1515
|
-
|
1516
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1517
|
-
c.vm.provider :parallels do |p|
|
1518
|
-
p.customize ["set", :id, "--a-key", "some value"]
|
1519
|
-
p.customize ["set", :id, "--something", "else"]
|
1520
|
-
end
|
1521
|
-
RUBY
|
1522
|
-
end
|
1523
|
-
|
1524
|
-
it "adds a short form of :memory and :cpus elements in :customize" do
|
1525
|
-
config[:customize] = {
|
1526
|
-
:memory => 2048,
|
1527
|
-
:cpus => 4,
|
1528
|
-
}
|
1529
|
-
cmd
|
1530
|
-
|
1531
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1532
|
-
c.vm.provider :parallels do |p|
|
1533
|
-
p.memory = 2048
|
1534
|
-
p.cpus = 4
|
1535
|
-
end
|
1536
|
-
RUBY
|
1537
|
-
end
|
1538
|
-
|
1539
|
-
it "does not set :linked_clone to nil" do
|
1540
|
-
config[:linked_clone] = nil
|
1541
|
-
cmd
|
1542
|
-
|
1543
|
-
expect(vagrantfile).to_not match(
|
1544
|
-
regexify(%{p.linked_clone = }, :partial))
|
1545
|
-
end
|
1546
|
-
|
1547
|
-
it "sets :linked_clone to false if set" do
|
1548
|
-
config[:linked_clone] = false
|
1549
|
-
cmd
|
1550
|
-
|
1551
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1552
|
-
c.vm.provider :parallels do |p|
|
1553
|
-
p.linked_clone = false
|
1554
|
-
end
|
1555
|
-
RUBY
|
1556
|
-
end
|
1557
|
-
|
1558
|
-
it "sets :linked_clone to true if set" do
|
1559
|
-
config[:linked_clone] = true
|
1560
|
-
cmd
|
1561
|
-
|
1562
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1563
|
-
c.vm.provider :parallels do |p|
|
1564
|
-
p.linked_clone = true
|
1565
|
-
end
|
1566
|
-
RUBY
|
1567
|
-
end
|
1568
|
-
end
|
1569
|
-
|
1570
|
-
context "for rackspace provider" do
|
1571
|
-
|
1572
|
-
before { config[:provider] = "rackspace" }
|
1573
|
-
|
1574
|
-
it "adds a line for each element in :customize" do
|
1575
|
-
config[:customize] = {
|
1576
|
-
:a_key => "some value",
|
1577
|
-
:something => "else",
|
1578
|
-
}
|
1579
|
-
cmd
|
1580
|
-
|
1581
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1582
|
-
c.vm.provider :rackspace do |p|
|
1583
|
-
p.a_key = "some value"
|
1584
|
-
p.something = "else"
|
1585
|
-
end
|
1586
|
-
RUBY
|
1587
|
-
end
|
1588
|
-
end
|
1589
|
-
|
1590
|
-
context "for softlayer provider" do
|
1591
|
-
|
1592
|
-
before { config[:provider] = "softlayer" }
|
1593
|
-
|
1594
|
-
it "adds a line for disk_capacity" do
|
1595
|
-
config[:customize] = {
|
1596
|
-
:disk_capacity => {
|
1597
|
-
:"0" => 25,
|
1598
|
-
:"2" => 100,
|
1599
|
-
},
|
1600
|
-
}
|
1601
|
-
cmd
|
1602
|
-
|
1603
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1604
|
-
c.vm.provider :softlayer do |p|
|
1605
|
-
p.disk_capacity = {:"0"=>25, :"2"=>100}
|
1606
|
-
end
|
1607
|
-
RUBY
|
1608
|
-
end
|
1609
|
-
|
1610
|
-
it "adds a line for each element in :customize" do
|
1611
|
-
config[:customize] = {
|
1612
|
-
:a_key => "some value",
|
1613
|
-
:something => "else",
|
1614
|
-
}
|
1615
|
-
cmd
|
1616
|
-
|
1617
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1618
|
-
c.vm.provider :softlayer do |p|
|
1619
|
-
p.a_key = "some value"
|
1620
|
-
p.something = "else"
|
1621
|
-
end
|
1622
|
-
RUBY
|
1623
|
-
end
|
1624
|
-
end
|
1625
|
-
|
1626
|
-
context "for libvirt provider" do
|
1627
|
-
|
1628
|
-
before { config[:provider] = "libvirt" }
|
1629
|
-
|
1630
|
-
it "adds a line for each element in :customize" do
|
1631
|
-
config[:customize] = {
|
1632
|
-
:a_key => "some value",
|
1633
|
-
:something => "else",
|
1634
|
-
:a_number_key => 1024,
|
1635
|
-
}
|
1636
|
-
cmd
|
1637
|
-
|
1638
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1639
|
-
c.vm.provider :libvirt do |p|
|
1640
|
-
p.a_key = "some value"
|
1641
|
-
p.something = "else"
|
1642
|
-
p.a_number_key = 1024
|
1643
|
-
end
|
1644
|
-
RUBY
|
1645
|
-
end
|
1646
|
-
|
1647
|
-
it "adds a single storage definition in :customize" do
|
1648
|
-
config[:customize] = {
|
1649
|
-
:storage => ":file, :size => '32G'",
|
1650
|
-
}
|
1651
|
-
cmd
|
1652
|
-
|
1653
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1654
|
-
c.vm.provider :libvirt do |p|
|
1655
|
-
p.storage :file, :size => '32G'
|
1656
|
-
end
|
1657
|
-
RUBY
|
1658
|
-
end
|
1659
|
-
|
1660
|
-
it "adds a line for each additional storage definition in :customize" do
|
1661
|
-
config[:customize] = {
|
1662
|
-
:storage => [
|
1663
|
-
":file, :size => '1G'",
|
1664
|
-
":file, :size => '128G', :bus => 'sata'",
|
1665
|
-
":file, :size => '64G', :bus => 'sata'",
|
1666
|
-
],
|
1667
|
-
}
|
1668
|
-
cmd
|
1669
|
-
|
1670
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1671
|
-
c.vm.provider :libvirt do |p|
|
1672
|
-
p.storage :file, :size => '1G'
|
1673
|
-
p.storage :file, :size => '128G', :bus => 'sata'
|
1674
|
-
p.storage :file, :size => '64G', :bus => 'sata'
|
1675
|
-
end
|
1676
|
-
RUBY
|
1677
|
-
end
|
1678
|
-
end
|
1679
|
-
|
1680
|
-
context "for lxc provider" do
|
1681
|
-
|
1682
|
-
before { config[:provider] = "lxc" }
|
1683
|
-
|
1684
|
-
it "sets container_name to :machine if set" do
|
1685
|
-
config[:customize] = {
|
1686
|
-
:container_name => ":machine",
|
1687
|
-
}
|
1688
|
-
cmd
|
1689
|
-
|
1690
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1691
|
-
c.vm.provider :lxc do |p|
|
1692
|
-
p.container_name = :machine
|
1693
|
-
end
|
1694
|
-
RUBY
|
1695
|
-
end
|
1696
|
-
|
1697
|
-
it "sets container_name to another value in quotes if set" do
|
1698
|
-
config[:customize] = {
|
1699
|
-
:container_name => "beans",
|
1700
|
-
}
|
1701
|
-
cmd
|
1702
|
-
|
1703
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1704
|
-
c.vm.provider :lxc do |p|
|
1705
|
-
p.container_name = "beans"
|
1706
|
-
end
|
1707
|
-
RUBY
|
1708
|
-
end
|
1709
|
-
|
1710
|
-
it "sets backingstore if set" do
|
1711
|
-
config[:customize] = {
|
1712
|
-
:backingstore => "lvm",
|
1713
|
-
}
|
1714
|
-
cmd
|
1715
|
-
|
1716
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1717
|
-
c.vm.provider :lxc do |p|
|
1718
|
-
p.backingstore = "lvm"
|
1719
|
-
end
|
1720
|
-
RUBY
|
1721
|
-
end
|
1722
|
-
|
1723
|
-
it "sets backingstore_option line for each backingstore_options" do
|
1724
|
-
config[:customize] = {
|
1725
|
-
:backingstore_options => {
|
1726
|
-
:vgname => "schroots",
|
1727
|
-
:fstype => "xfs",
|
1728
|
-
},
|
1729
|
-
}
|
1730
|
-
cmd
|
1731
|
-
|
1732
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1733
|
-
c.vm.provider :lxc do |p|
|
1734
|
-
p.backingstore_option "--vgname", "schroots"
|
1735
|
-
p.backingstore_option "--fstype", "xfs"
|
1736
|
-
end
|
1737
|
-
RUBY
|
1738
|
-
end
|
1739
|
-
|
1740
|
-
it "sets all other options to customize lines" do
|
1741
|
-
config[:customize] = {
|
1742
|
-
:cookies => "cream",
|
1743
|
-
:salt => "vinegar",
|
1744
|
-
}
|
1745
|
-
cmd
|
1746
|
-
|
1747
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1748
|
-
c.vm.provider :lxc do |p|
|
1749
|
-
p.customize "cookies", "cream"
|
1750
|
-
p.customize "salt", "vinegar"
|
1751
|
-
end
|
1752
|
-
RUBY
|
1753
|
-
end
|
1754
|
-
end
|
1755
|
-
|
1756
|
-
context "for vmware_* providers" do
|
1757
|
-
|
1758
|
-
before { config[:provider] = "vmware_desktop" }
|
1759
|
-
|
1760
|
-
it "does not set :gui to nil" do
|
1761
|
-
config[:gui] = nil
|
1762
|
-
cmd
|
1763
|
-
|
1764
|
-
expect(vagrantfile).to_not match(regexify(%{p.gui = }, :partial))
|
1765
|
-
end
|
1766
|
-
|
1767
|
-
it "sets :gui to false if set" do
|
1768
|
-
config[:gui] = false
|
1769
|
-
cmd
|
1770
|
-
|
1771
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1772
|
-
c.vm.provider :vmware_desktop do |p|
|
1773
|
-
p.gui = false
|
1774
|
-
end
|
1775
|
-
RUBY
|
1776
|
-
end
|
1777
|
-
|
1778
|
-
it "sets :gui to true if set" do
|
1779
|
-
config[:gui] = true
|
1780
|
-
cmd
|
1781
|
-
|
1782
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1783
|
-
c.vm.provider :vmware_desktop do |p|
|
1784
|
-
p.gui = true
|
1785
|
-
end
|
1786
|
-
RUBY
|
1787
|
-
end
|
1788
|
-
|
1789
|
-
it "adds a line for each element in :customize" do
|
1790
|
-
config[:customize] = {
|
1791
|
-
:a_key => "some value",
|
1792
|
-
:something => "else",
|
1793
|
-
}
|
1794
|
-
cmd
|
1795
|
-
|
1796
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1797
|
-
c.vm.provider :vmware_desktop do |p|
|
1798
|
-
p.vmx["a_key"] = "some value"
|
1799
|
-
p.vmx["something"] = "else"
|
1800
|
-
end
|
1801
|
-
RUBY
|
1802
|
-
end
|
1803
|
-
|
1804
|
-
it "converts :memory into :memsize" do
|
1805
|
-
config[:customize] = {
|
1806
|
-
:memory => "222",
|
1807
|
-
}
|
1808
|
-
cmd
|
1809
|
-
|
1810
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1811
|
-
c.vm.provider :vmware_desktop do |p|
|
1812
|
-
p.vmx["memsize"] = "222"
|
1813
|
-
end
|
1814
|
-
RUBY
|
1815
|
-
end
|
1816
|
-
|
1817
|
-
it "skips :memory if key :memsize exists" do
|
1818
|
-
config[:customize] = {
|
1819
|
-
:memory => "222",
|
1820
|
-
:memsize => "444",
|
1821
|
-
}
|
1822
|
-
cmd
|
1823
|
-
|
1824
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1825
|
-
c.vm.provider :vmware_desktop do |p|
|
1826
|
-
p.vmx["memsize"] = "444"
|
1827
|
-
end
|
1828
|
-
RUBY
|
1829
|
-
end
|
1830
|
-
|
1831
|
-
it "converts :cpus into :numvcpus" do
|
1832
|
-
config[:customize] = {
|
1833
|
-
:cpus => "2",
|
1834
|
-
}
|
1835
|
-
cmd
|
1836
|
-
|
1837
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1838
|
-
c.vm.provider :vmware_desktop do |p|
|
1839
|
-
p.vmx["numvcpus"] = "2"
|
1840
|
-
end
|
1841
|
-
RUBY
|
1842
|
-
end
|
1843
|
-
|
1844
|
-
it "skips :cpus if key :numvcpus exists" do
|
1845
|
-
config[:customize] = {
|
1846
|
-
:cpus => "2",
|
1847
|
-
:numvcpus => "4",
|
1848
|
-
}
|
1849
|
-
cmd
|
1850
|
-
|
1851
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1852
|
-
c.vm.provider :vmware_desktop do |p|
|
1853
|
-
p.vmx["numvcpus"] = "4"
|
1854
|
-
end
|
1855
|
-
RUBY
|
1856
|
-
end
|
1857
|
-
end
|
1858
|
-
|
1859
|
-
context "for managed provider" do
|
1860
|
-
|
1861
|
-
before { config[:provider] = "managed" }
|
1862
|
-
|
1863
|
-
it "adds a line a server" do
|
1864
|
-
config[:customize] = {
|
1865
|
-
:server => "my_server",
|
1866
|
-
}
|
1867
|
-
cmd
|
1868
|
-
|
1869
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1870
|
-
c.vm.provider :managed do |p|
|
1871
|
-
p.server = "my_server"
|
1872
|
-
end
|
1873
|
-
RUBY
|
1874
|
-
end
|
1875
|
-
|
1876
|
-
it "ignores all other key types than server" do
|
1877
|
-
config[:customize] = {
|
1878
|
-
:other => "stuff",
|
1879
|
-
:is => "ignored",
|
1880
|
-
}
|
1881
|
-
cmd
|
1882
|
-
|
1883
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1884
|
-
c.vm.provider :managed do |p|
|
1885
|
-
end
|
1886
|
-
RUBY
|
1887
|
-
end
|
1888
|
-
end
|
1889
|
-
|
1890
|
-
context "for openstack provider" do
|
1891
|
-
|
1892
|
-
before { config[:provider] = "openstack" }
|
1893
|
-
|
1894
|
-
it "adds a line for each element in :customize" do
|
1895
|
-
config[:customize] = {
|
1896
|
-
:key1 => "some string value",
|
1897
|
-
:key2 => 22,
|
1898
|
-
:key3 => false,
|
1899
|
-
}
|
1900
|
-
cmd
|
1901
|
-
|
1902
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1903
|
-
c.vm.provider :openstack do |p|
|
1904
|
-
p.key1 = "some string value"
|
1905
|
-
p.key2 = 22
|
1906
|
-
p.key3 = false
|
1907
|
-
end
|
1908
|
-
RUBY
|
1909
|
-
end
|
1910
|
-
end
|
1911
|
-
|
1912
|
-
context "for cloudstack provider" do
|
1913
|
-
|
1914
|
-
before { config[:provider] = "cloudstack" }
|
1915
|
-
|
1916
|
-
it "adds a line for each element in :customize" do
|
1917
|
-
config[:customize] = {
|
1918
|
-
:a_key => "some value",
|
1919
|
-
:something => "else",
|
1920
|
-
}
|
1921
|
-
cmd
|
1922
|
-
|
1923
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1924
|
-
c.vm.provider :cloudstack do |p|
|
1925
|
-
p.a_key = "some value"
|
1926
|
-
p.something = "else"
|
1927
|
-
end
|
1928
|
-
RUBY
|
1929
|
-
end
|
1930
|
-
|
1931
|
-
it "builds an array of hashes for firewall rules in :customize" do
|
1932
|
-
config[:customize] = {
|
1933
|
-
:firewall_rules => [
|
1934
|
-
{
|
1935
|
-
:ipaddress => "A.A.A.A",
|
1936
|
-
:cidrlist => "B.B.B.B/24",
|
1937
|
-
:protocol => "tcp",
|
1938
|
-
:startport => 2222,
|
1939
|
-
:endport => 2222,
|
1940
|
-
},
|
1941
|
-
{
|
1942
|
-
:ipaddress => "C.C.C.C",
|
1943
|
-
:cidrlist => "D.D.D.D/32",
|
1944
|
-
:protocol => "tcp",
|
1945
|
-
:startport => 80,
|
1946
|
-
:endport => 81,
|
1947
|
-
},
|
1948
|
-
],
|
1949
|
-
}
|
1950
|
-
cmd
|
1951
|
-
|
1952
|
-
expectation = <<-RUBY.gsub(/^ {8}/, "").gsub(/,\n /, ",").chomp
|
1953
|
-
c.vm.provider :cloudstack do |p|
|
1954
|
-
p.firewall_rules = [{:ipaddress=>"A.A.A.A", :cidrlist=>"B.B.B.B/24",
|
1955
|
-
:protocol=>"tcp", :startport=>2222,
|
1956
|
-
:endport=>2222}, {:ipaddress=>"C.C.C.C", :cidrlist=>"D.D.D.D/32",
|
1957
|
-
:protocol=>"tcp", :startport=>80, :endport=>81}]
|
1958
|
-
end
|
1959
|
-
RUBY
|
1960
|
-
|
1961
|
-
expect(vagrantfile).to match(regexify(expectation))
|
1962
|
-
end
|
1963
|
-
|
1964
|
-
it "builds an array for security group ids in :customize" do
|
1965
|
-
config[:customize] = {
|
1966
|
-
:security_group_ids => ["aaaa-bbbb-cccc-dddd",
|
1967
|
-
"1111-2222-3333-4444"],
|
1968
|
-
}
|
1969
|
-
cmd
|
1970
|
-
|
1971
|
-
expectation = <<-RUBY.gsub(/^ {8}/, "").gsub(/,\n /, ",").chomp
|
1972
|
-
c.vm.provider :cloudstack do |p|
|
1973
|
-
p.security_group_ids = ["aaaa-bbbb-cccc-dddd",
|
1974
|
-
"1111-2222-3333-4444"]
|
1975
|
-
end
|
1976
|
-
RUBY
|
1977
|
-
|
1978
|
-
expect(vagrantfile).to match(regexify(expectation))
|
1979
|
-
end
|
1980
|
-
|
1981
|
-
it "builds an array for security group names in :customize" do
|
1982
|
-
config[:customize] = {
|
1983
|
-
:security_group_names => %w{min_fantastiska_security_group
|
1984
|
-
another_security_group},
|
1985
|
-
}
|
1986
|
-
cmd
|
1987
|
-
|
1988
|
-
expectation = <<-RUBY.gsub(/^ {8}/, "").gsub(/,\n /, ",").chomp
|
1989
|
-
c.vm.provider :cloudstack do |p|
|
1990
|
-
p.security_group_names = ["min_fantastiska_security_group",
|
1991
|
-
"another_security_group"]
|
1992
|
-
end
|
1993
|
-
RUBY
|
1994
|
-
|
1995
|
-
expect(vagrantfile).to match(regexify(expectation))
|
1996
|
-
end
|
1997
|
-
|
1998
|
-
it "builds an array of hashes for security groups in :customize" do
|
1999
|
-
config[:customize] = {
|
2000
|
-
:security_groups => [
|
2001
|
-
{
|
2002
|
-
:name => "Awesome_security_group",
|
2003
|
-
:description => "Created from the Vagrantfile",
|
2004
|
-
:rules => [
|
2005
|
-
{
|
2006
|
-
:type => "ingress",
|
2007
|
-
:protocol => "TCP",
|
2008
|
-
:startport => 22,
|
2009
|
-
:endport => 22,
|
2010
|
-
:cidrlist => "0.0.0.0/0",
|
2011
|
-
},
|
2012
|
-
{
|
2013
|
-
:type => "egress",
|
2014
|
-
:protocol => "TCP",
|
2015
|
-
:startport => 81,
|
2016
|
-
:endport => 82,
|
2017
|
-
:cidrlist => "1.2.3.4/24",
|
2018
|
-
},
|
2019
|
-
],
|
2020
|
-
},
|
2021
|
-
],
|
2022
|
-
}
|
2023
|
-
cmd
|
2024
|
-
|
2025
|
-
expectation = <<-RUBY.gsub(/^ {8}/, "").gsub(/,\n /, ",").chomp
|
2026
|
-
c.vm.provider :cloudstack do |p|
|
2027
|
-
p.security_groups = [{:name=>"Awesome_security_group",
|
2028
|
-
:description=>"Created from the Vagrantfile",
|
2029
|
-
:rules=>[{:type=>"ingress", :protocol=>"TCP", :startport=>22,
|
2030
|
-
:endport=>22, :cidrlist=>"0.0.0.0/0"}, {:type=>"egress",
|
2031
|
-
:protocol=>"TCP", :startport=>81, :endport=>82,
|
2032
|
-
:cidrlist=>"1.2.3.4/24"}]}]
|
2033
|
-
end
|
2034
|
-
RUBY
|
2035
|
-
|
2036
|
-
expect(vagrantfile).to match(regexify(expectation))
|
2037
|
-
end
|
2038
|
-
|
2039
|
-
it "builds an array of hashes for static nat in :customize" do
|
2040
|
-
config[:customize] = {
|
2041
|
-
:static_nat => [{ :idaddress => "A.A.A.A" }],
|
2042
|
-
}
|
2043
|
-
cmd
|
2044
|
-
|
2045
|
-
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
2046
|
-
c.vm.provider :cloudstack do |p|
|
2047
|
-
p.static_nat = [{:idaddress=>"A.A.A.A"}]
|
2048
|
-
end
|
2049
|
-
RUBY
|
2050
|
-
end
|
2051
|
-
|
2052
|
-
it "builds an array of hashes for port forwarding rules in :customize" do
|
2053
|
-
config[:customize] = {
|
2054
|
-
:port_forwarding_rules => [
|
2055
|
-
{
|
2056
|
-
:ipaddress => "X.X.X.X",
|
2057
|
-
:protocol => "tcp",
|
2058
|
-
:publicport => 22,
|
2059
|
-
:privateport => 22,
|
2060
|
-
:openfirewall => false,
|
2061
|
-
},
|
2062
|
-
{
|
2063
|
-
:ipaddress => "X.X.X.X",
|
2064
|
-
:protocol => "tcp",
|
2065
|
-
:publicport => 80,
|
2066
|
-
:privateport => 80,
|
2067
|
-
:openfirewall => false,
|
2068
|
-
},
|
2069
|
-
],
|
2070
|
-
}
|
2071
|
-
cmd
|
2072
|
-
|
2073
|
-
expectation = <<-RUBY.gsub(/^ {8}/, "").gsub(/,\n /, ",").chomp
|
2074
|
-
c.vm.provider :cloudstack do |p|
|
2075
|
-
p.port_forwarding_rules = [{:ipaddress=>"X.X.X.X",
|
2076
|
-
:protocol=>"tcp", :publicport=>22, :privateport=>22,
|
2077
|
-
:openfirewall=>false}, {:ipaddress=>"X.X.X.X", :protocol=>"tcp",
|
2078
|
-
:publicport=>80, :privateport=>80, :openfirewall=>false}]
|
2079
|
-
end
|
2080
|
-
RUBY
|
2081
|
-
|
2082
|
-
expect(vagrantfile).to match(regexify(expectation))
|
2083
|
-
end
|
2084
|
-
end
|
2085
|
-
end
|
2086
|
-
|
2087
|
-
def debug_lines
|
2088
|
-
regex = %r{^D, .* : }
|
2089
|
-
logged_output.string.lines.
|
2090
|
-
select { |l| l =~ regex }.map { |l| l.sub(regex, "") }.join
|
2091
|
-
end
|
2092
|
-
|
2093
|
-
def with_modern_vagrant
|
2094
|
-
with_vagrant("1.7.2")
|
2095
|
-
end
|
2096
|
-
|
2097
|
-
def with_unsupported_vagrant
|
2098
|
-
with_vagrant("1.0.5")
|
2099
|
-
end
|
2100
|
-
|
2101
|
-
def with_vagrant(version)
|
2102
|
-
allow(driver_object).to receive(:run_command).
|
2103
|
-
with("vagrant --version", any_args).and_return("Vagrant #{version}")
|
2104
|
-
end
|
2105
|
-
|
2106
|
-
def regexify(str, line = :whole_line)
|
2107
|
-
r = Regexp.escape(str)
|
2108
|
-
r = "^\s*#{r}$" if line == :whole_line
|
2109
|
-
Regexp.new(r)
|
2110
|
-
end
|
2111
|
-
|
2112
|
-
def vagrantfile
|
2113
|
-
IO.read(File.join(vagrant_root, "Vagrantfile"))
|
2114
|
-
end
|
2115
|
-
end
|