test-kitchen 1.3.1 → 1.4.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cane +2 -0
- data/.gitignore +4 -0
- data/CHANGELOG.md +45 -0
- data/Rakefile +15 -0
- data/features/kitchen_action_commands.feature +12 -9
- data/features/kitchen_defaults.feature +38 -0
- data/features/kitchen_init_command.feature +0 -1
- data/features/kitchen_list_command.feature +2 -2
- data/features/kitchen_login_command.feature +7 -1
- data/features/kitchen_test_command.feature +4 -4
- data/lib/kitchen.rb +40 -11
- data/lib/kitchen/cli.rb +38 -22
- data/lib/kitchen/command/list.rb +5 -2
- data/lib/kitchen/config.rb +45 -18
- data/lib/kitchen/configurable.rb +137 -1
- data/lib/kitchen/data_munger.rb +248 -17
- data/lib/kitchen/driver.rb +1 -1
- data/lib/kitchen/driver/base.rb +1 -83
- data/lib/kitchen/driver/dummy.rb +0 -5
- data/lib/kitchen/driver/ssh_base.rb +177 -22
- data/lib/kitchen/instance.rb +140 -20
- data/lib/kitchen/logger.rb +43 -8
- data/lib/kitchen/login_command.rb +14 -5
- data/lib/kitchen/platform.rb +19 -0
- data/lib/kitchen/provisioner.rb +5 -3
- data/lib/kitchen/provisioner/base.rb +46 -48
- data/lib/kitchen/provisioner/chef/common_sandbox.rb +322 -0
- data/lib/kitchen/provisioner/chef_base.rb +179 -286
- data/lib/kitchen/provisioner/chef_solo.rb +11 -5
- data/lib/kitchen/provisioner/chef_zero.rb +108 -94
- data/lib/kitchen/provisioner/dummy.rb +47 -0
- data/lib/kitchen/provisioner/shell.rb +45 -12
- data/lib/kitchen/rake_tasks.rb +1 -1
- data/lib/kitchen/ssh.rb +1 -1
- data/lib/kitchen/thor_tasks.rb +1 -1
- data/lib/kitchen/transport.rb +54 -0
- data/lib/kitchen/transport/base.rb +146 -0
- data/lib/kitchen/transport/dummy.rb +75 -0
- data/lib/kitchen/transport/ssh.rb +325 -0
- data/lib/kitchen/transport/winrm.rb +508 -0
- data/lib/kitchen/transport/winrm/command_executor.rb +188 -0
- data/lib/kitchen/transport/winrm/file_transporter.rb +454 -0
- data/lib/kitchen/transport/winrm/logging.rb +50 -0
- data/lib/kitchen/transport/winrm/template.rb +74 -0
- data/lib/kitchen/transport/winrm/tmp_zip.rb +187 -0
- data/lib/kitchen/verifier.rb +55 -0
- data/lib/kitchen/verifier/base.rb +191 -0
- data/lib/kitchen/verifier/busser.rb +266 -0
- data/lib/kitchen/verifier/dummy.rb +75 -0
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/cli_spec.rb +56 -0
- data/spec/kitchen/config_spec.rb +61 -20
- data/spec/kitchen/configurable_spec.rb +327 -1
- data/spec/kitchen/data_munger_spec.rb +777 -14
- data/spec/kitchen/driver/base_spec.rb +7 -38
- data/spec/kitchen/driver/dummy_spec.rb +0 -29
- data/spec/kitchen/driver/ssh_base_spec.rb +580 -236
- data/spec/kitchen/driver_spec.rb +1 -0
- data/spec/kitchen/instance_spec.rb +383 -83
- data/spec/kitchen/login_command_spec.rb +29 -10
- data/spec/kitchen/platform_spec.rb +58 -2
- data/spec/kitchen/provisioner/base_spec.rb +170 -18
- data/spec/kitchen/provisioner/chef_base_spec.rb +454 -104
- data/spec/kitchen/provisioner/chef_solo_spec.rb +307 -104
- data/spec/kitchen/provisioner/chef_zero_spec.rb +561 -230
- data/spec/kitchen/provisioner/dummy_spec.rb +91 -0
- data/spec/kitchen/provisioner/shell_spec.rb +158 -56
- data/spec/kitchen/provisioner_spec.rb +37 -0
- data/spec/kitchen/ssh_spec.rb +19 -19
- data/spec/kitchen/transport/base_spec.rb +89 -0
- data/spec/kitchen/transport/ssh_spec.rb +1147 -0
- data/spec/kitchen/transport/winrm/command_executor_spec.rb +400 -0
- data/spec/kitchen/transport/winrm/file_transporter_spec.rb +876 -0
- data/spec/kitchen/transport/winrm/logging_spec.rb +92 -0
- data/spec/kitchen/transport/winrm/template_spec.rb +51 -0
- data/spec/kitchen/transport/winrm/tmp_zip_spec.rb +132 -0
- data/spec/kitchen/transport/winrm_spec.rb +1069 -0
- data/spec/kitchen/transport_spec.rb +112 -0
- data/spec/kitchen/verifier/base_spec.rb +310 -0
- data/spec/kitchen/verifier/busser_spec.rb +540 -0
- data/spec/kitchen/verifier/dummy_spec.rb +91 -0
- data/spec/kitchen/verifier_spec.rb +120 -0
- data/spec/kitchen_spec.rb +7 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/powershell_max_size_spec.rb +40 -0
- data/support/busser_install_command.ps1 +14 -0
- data/support/busser_install_command.sh +15 -0
- data/support/check_files.ps1.erb +48 -0
- data/support/chef_base_init_command.ps1 +18 -0
- data/support/chef_base_init_command.sh +2 -0
- data/support/chef_base_install_command.ps1 +76 -0
- data/support/chef_base_install_command.sh +137 -0
- data/support/chef_zero_prepare_command_legacy.ps1 +9 -0
- data/support/chef_zero_prepare_command_legacy.sh +10 -0
- data/support/decode_files.ps1.erb +61 -0
- data/test-kitchen.gemspec +2 -0
- metadata +97 -8
- data/lib/kitchen/busser.rb +0 -316
- data/spec/kitchen/busser_spec.rb +0 -490
- data/support/chef_helpers.sh +0 -16
@@ -0,0 +1,266 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2012, 2013, 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 "base64"
|
20
|
+
require "digest"
|
21
|
+
|
22
|
+
require "kitchen/verifier/base"
|
23
|
+
|
24
|
+
module Kitchen
|
25
|
+
|
26
|
+
module Verifier
|
27
|
+
|
28
|
+
# Command string generator to interface with Busser. The commands that are
|
29
|
+
# generated are safe to pass to an SSH command or as an unix command
|
30
|
+
# argument (escaped in single quotes).
|
31
|
+
#
|
32
|
+
# @author Fletcher Nichol <fnichol@nichol.ca>
|
33
|
+
class Busser < Kitchen::Verifier::Base
|
34
|
+
|
35
|
+
default_config :busser_bin do |verifier|
|
36
|
+
verifier.
|
37
|
+
remote_path_join(%W[#{verifier[:root_path]} bin busser]).
|
38
|
+
tap { |path| path.concat(".bat") if verifier.windows_os? }
|
39
|
+
end
|
40
|
+
|
41
|
+
default_config :ruby_bindir do |verifier|
|
42
|
+
if verifier.windows_os?
|
43
|
+
"$env:systemdrive\\opscode\\chef\\embedded\\bin"
|
44
|
+
else
|
45
|
+
"/opt/chef/embedded/bin"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
default_config :version, "busser"
|
50
|
+
|
51
|
+
expand_path_for :test_base_path
|
52
|
+
|
53
|
+
# Creates a new Busser object using the provided configuration data
|
54
|
+
# which will be merged with any default configuration.
|
55
|
+
#
|
56
|
+
# @param config [Hash] provided driver configuration
|
57
|
+
def initialize(config = {})
|
58
|
+
init_config(config)
|
59
|
+
end
|
60
|
+
|
61
|
+
# (see Base#create_sandbox)
|
62
|
+
def create_sandbox
|
63
|
+
super
|
64
|
+
prepare_helpers
|
65
|
+
prepare_suites
|
66
|
+
end
|
67
|
+
|
68
|
+
# (see Base#init_command)
|
69
|
+
def init_command
|
70
|
+
return if local_suite_files.empty?
|
71
|
+
|
72
|
+
cmd = sudo(config[:busser_bin]).dup.
|
73
|
+
tap { |str| str.insert(0, "& ") if powershell_shell? }
|
74
|
+
|
75
|
+
wrap_shell_code(Util.outdent!(<<-CMD))
|
76
|
+
#{busser_env}
|
77
|
+
|
78
|
+
#{cmd} suite cleanup
|
79
|
+
CMD
|
80
|
+
end
|
81
|
+
|
82
|
+
# (see Base#install_command)
|
83
|
+
def install_command
|
84
|
+
return if local_suite_files.empty?
|
85
|
+
|
86
|
+
vars = install_command_vars
|
87
|
+
|
88
|
+
shell_code_from_file(vars, "busser_install_command")
|
89
|
+
end
|
90
|
+
|
91
|
+
# (see Base#run_command)
|
92
|
+
def run_command
|
93
|
+
return if local_suite_files.empty?
|
94
|
+
|
95
|
+
cmd = sudo(config[:busser_bin]).dup.
|
96
|
+
tap { |str| str.insert(0, "& ") if powershell_shell? }
|
97
|
+
|
98
|
+
wrap_shell_code(Util.outdent!(<<-CMD))
|
99
|
+
#{busser_env}
|
100
|
+
|
101
|
+
#{cmd} test
|
102
|
+
CMD
|
103
|
+
end
|
104
|
+
|
105
|
+
# Legacy method stub for `#setup_cmd` which calls `#install_command`.
|
106
|
+
#
|
107
|
+
# @return [String] command string
|
108
|
+
# @deprecated When backwards compatibility for old Busser methods is
|
109
|
+
# removed, this method will no longer be available. Use
|
110
|
+
# `#install_command` in its place.
|
111
|
+
define_method(:setup_cmd) { install_command }
|
112
|
+
|
113
|
+
# Legacy method stub for `#run_cmd` which calls `#run_command`.
|
114
|
+
#
|
115
|
+
# @return [String] command string
|
116
|
+
# @deprecated When backwards compatibility for old Busser methods is
|
117
|
+
# removed, this method will no longer be available. Use
|
118
|
+
# `#run_command` in its place.
|
119
|
+
define_method(:run_cmd) { run_command }
|
120
|
+
|
121
|
+
# Legacy method stub for `#sync_cmd`.
|
122
|
+
#
|
123
|
+
# @deprecated When backwards compatibility for old Busser methods is
|
124
|
+
# removed, this method will no longer be available. Use
|
125
|
+
# `transport#upload` to transfer test files in its place.
|
126
|
+
def sync_cmd
|
127
|
+
warn("Legacy call to #sync_cmd cannot be preserved, meaning that " \
|
128
|
+
"test files will not be uploaded. " \
|
129
|
+
"Code that calls #sync_cmd can now use the transport#upload " \
|
130
|
+
"method to transfer files.")
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
# Returns a command string that sets appropriate environment variables for
|
136
|
+
# busser commands.
|
137
|
+
#
|
138
|
+
# @return [String] command string
|
139
|
+
# @api private
|
140
|
+
def busser_env
|
141
|
+
root = config[:root_path]
|
142
|
+
gem_home = gem_path = remote_path_join(root, "gems")
|
143
|
+
gem_cache = remote_path_join(gem_home, "cache")
|
144
|
+
|
145
|
+
[
|
146
|
+
shell_env_var("BUSSER_ROOT", root),
|
147
|
+
shell_env_var("GEM_HOME", gem_home),
|
148
|
+
shell_env_var("GEM_PATH", gem_path),
|
149
|
+
shell_env_var("GEM_CACHE", gem_cache)
|
150
|
+
].join("\n")
|
151
|
+
end
|
152
|
+
|
153
|
+
# Determines whether or not a local workstation file exists under a
|
154
|
+
# Chef-related directory.
|
155
|
+
#
|
156
|
+
# @return [truthy,falsey] whether or not a given file is some kind of
|
157
|
+
# Chef-related file
|
158
|
+
# @api private
|
159
|
+
def chef_data_dir?(base, file)
|
160
|
+
file =~ %r{^#{base}/(data|data_bags|environments|nodes|roles)/}
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns arguments to a `gem install` command, suitable to install the
|
164
|
+
# Busser gem.
|
165
|
+
#
|
166
|
+
# @return [String] arguments string
|
167
|
+
# @api private
|
168
|
+
def gem_install_args
|
169
|
+
gem, version = config[:version].split("@")
|
170
|
+
gem, version = "busser", gem if gem =~ /^\d+\.\d+\.\d+/
|
171
|
+
|
172
|
+
args = gem
|
173
|
+
args += " --version #{version}" if version
|
174
|
+
args += " --no-rdoc --no-ri"
|
175
|
+
args
|
176
|
+
end
|
177
|
+
|
178
|
+
# Returns an Array of common helper filenames currently residing on the
|
179
|
+
# local workstation.
|
180
|
+
#
|
181
|
+
# @return [Array<String>] array of helper files
|
182
|
+
# @api private
|
183
|
+
def helper_files
|
184
|
+
glob = File.join(config[:test_base_path], "helpers", "*/**/*")
|
185
|
+
Dir.glob(glob).reject { |f| File.directory?(f) }
|
186
|
+
end
|
187
|
+
|
188
|
+
def install_command_vars
|
189
|
+
ruby = remote_path_join(config[:ruby_bindir], "ruby").
|
190
|
+
tap { |path| path.concat(".exe") if windows_os? }
|
191
|
+
gem = remote_path_join(config[:ruby_bindir], "gem")
|
192
|
+
|
193
|
+
[
|
194
|
+
busser_env,
|
195
|
+
shell_var("ruby", ruby),
|
196
|
+
shell_var("gem", gem),
|
197
|
+
shell_var("version", config[:version]),
|
198
|
+
shell_var("gem_install_args", gem_install_args),
|
199
|
+
shell_var("busser", sudo(config[:busser_bin])),
|
200
|
+
shell_var("plugins", plugins.join(" "))
|
201
|
+
].join("\n")
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns an Array of test suite filenames for the related suite currently
|
205
|
+
# residing on the local workstation. Any special provisioner-specific
|
206
|
+
# directories (such as a Chef roles/ directory) are excluded.
|
207
|
+
#
|
208
|
+
# @return [Array<String>] array of suite files
|
209
|
+
# @api private
|
210
|
+
def local_suite_files
|
211
|
+
base = File.join(config[:test_base_path], config[:suite_name])
|
212
|
+
glob = File.join(base, "*/**/*")
|
213
|
+
Dir.glob(glob).reject do |f|
|
214
|
+
chef_data_dir?(base, f) || File.directory?(f)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
# Returns a uniquely sorted Array of Busser plugin gems that need to
|
219
|
+
# be installed for the related suite.
|
220
|
+
#
|
221
|
+
# @return [Array<String>] a lexically sorted, unique item array of Busser
|
222
|
+
# plugin gem names
|
223
|
+
# @api private
|
224
|
+
def plugins
|
225
|
+
non_suite_dirs = %w[data data_bags environments nodes roles]
|
226
|
+
glob = File.join(config[:test_base_path], config[:suite_name], "*")
|
227
|
+
Dir.glob(glob).reject { |d|
|
228
|
+
!File.directory?(d) || non_suite_dirs.include?(File.basename(d))
|
229
|
+
}.map { |d| "busser-#{File.basename(d)}" }.sort.uniq
|
230
|
+
end
|
231
|
+
|
232
|
+
# Copies all common testing helper files into the suites directory in
|
233
|
+
# the sandbox.
|
234
|
+
#
|
235
|
+
# @api private
|
236
|
+
def prepare_helpers
|
237
|
+
base = File.join(config[:test_base_path], "helpers")
|
238
|
+
|
239
|
+
helper_files.each do |src|
|
240
|
+
dest = File.join(sandbox_suites_dir, src.sub("#{base}/", ""))
|
241
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
242
|
+
FileUtils.cp(src, dest, :preserve => true)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
# Copies all test suite files into the suites directory in the sandbox.
|
247
|
+
#
|
248
|
+
# @api private
|
249
|
+
def prepare_suites
|
250
|
+
base = File.join(config[:test_base_path], config[:suite_name])
|
251
|
+
|
252
|
+
local_suite_files.each do |src|
|
253
|
+
dest = File.join(sandbox_suites_dir, src.sub("#{base}/", ""))
|
254
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
255
|
+
FileUtils.cp(src, dest, :preserve => true)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
# @return [String] path to suites directory under sandbox path
|
260
|
+
# @api private
|
261
|
+
def sandbox_suites_dir
|
262
|
+
File.join(sandbox_path, "suites")
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
@@ -0,0 +1,75 @@
|
|
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 "kitchen/verifier/base"
|
20
|
+
|
21
|
+
module Kitchen
|
22
|
+
|
23
|
+
module Verifier
|
24
|
+
|
25
|
+
# Dummy verifier for Kitchen. This verifier does nothing but report what
|
26
|
+
# would happen if this verifier did anything of consequence. As a result
|
27
|
+
# it may be a useful verifier to use when debugging or developing new
|
28
|
+
# features or plugins.
|
29
|
+
#
|
30
|
+
# @author Fletcher Nichol <fnichol@nichol.ca>
|
31
|
+
class Dummy < Kitchen::Verifier::Base
|
32
|
+
|
33
|
+
default_config :sleep, 0
|
34
|
+
default_config :random_failure, false
|
35
|
+
|
36
|
+
# (see Base#call)
|
37
|
+
def call(state)
|
38
|
+
info("[#{name}] Verify on instance=#{instance} with state=#{state}")
|
39
|
+
sleep_if_set
|
40
|
+
failure_if_set
|
41
|
+
debug("[#{name}] Verify completed (#{config[:sleep]}s).")
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# Sleep for a period of time, if a value is set in the config.
|
47
|
+
#
|
48
|
+
# @api private
|
49
|
+
def sleep_if_set
|
50
|
+
sleep(config[:sleep].to_f) if config[:sleep].to_f > 0.0
|
51
|
+
end
|
52
|
+
|
53
|
+
# Simulate a failure in an action, if set in the config.
|
54
|
+
#
|
55
|
+
# @api private
|
56
|
+
def failure_if_set
|
57
|
+
if config[:"fail"]
|
58
|
+
debug("Failure for Verifier #{name}.")
|
59
|
+
raise ActionFailed, "Action #verify failed for #{instance.to_str}."
|
60
|
+
elsif config[:random_failure] && randomly_fail?
|
61
|
+
debug("Random failure for Verifier #{name}.")
|
62
|
+
raise ActionFailed, "Action #verify failed for #{instance.to_str}."
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Determine whether or not to randomly fail.
|
67
|
+
#
|
68
|
+
# @return [true, false]
|
69
|
+
# @api private
|
70
|
+
def randomly_fail?
|
71
|
+
[true, false].sample
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/kitchen/version.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Tyler Ball (<tball@chef.io>)
|
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 "kitchen/cli"
|
22
|
+
require "kitchen"
|
23
|
+
|
24
|
+
module Kitchen
|
25
|
+
describe CLI do
|
26
|
+
|
27
|
+
let(:cli) { CLI.new }
|
28
|
+
|
29
|
+
before do
|
30
|
+
@orig_env = ENV.to_hash
|
31
|
+
end
|
32
|
+
|
33
|
+
after do
|
34
|
+
ENV.clear
|
35
|
+
@orig_env.each do |k, v|
|
36
|
+
ENV[k] = v
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#initialize" do
|
41
|
+
it "does not set logging config when environment variables are missing" do
|
42
|
+
assert_equal Kitchen::DEFAULT_LOG_LEVEL, cli.config.log_level
|
43
|
+
assert_equal Kitchen::DEFAULT_LOG_OVERWRITE, cli.config.log_overwrite
|
44
|
+
end
|
45
|
+
|
46
|
+
it "does set logging config when environment variables are present" do
|
47
|
+
ENV["KITCHEN_LOG"] = "warn"
|
48
|
+
ENV["KITCHEN_LOG_OVERWRITE"] = "false"
|
49
|
+
|
50
|
+
assert_equal :warn, cli.config.log_level
|
51
|
+
assert_equal false, cli.config.log_overwrite
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
data/spec/kitchen/config_spec.rb
CHANGED
@@ -27,7 +27,9 @@ require "kitchen/instance"
|
|
27
27
|
require "kitchen/platform"
|
28
28
|
require "kitchen/provisioner"
|
29
29
|
require "kitchen/suite"
|
30
|
+
require "kitchen/transport"
|
30
31
|
require "kitchen/util"
|
32
|
+
require "kitchen/verifier"
|
31
33
|
|
32
34
|
module Kitchen
|
33
35
|
|
@@ -52,7 +54,8 @@ describe Kitchen::Config do
|
|
52
54
|
:kitchen_root => "/tmp/that/place",
|
53
55
|
:log_root => "/tmp/logs",
|
54
56
|
:test_base_path => "/testing/yo",
|
55
|
-
:log_level => :debug
|
57
|
+
:log_level => :debug,
|
58
|
+
:log_overwrite => false
|
56
59
|
}
|
57
60
|
end
|
58
61
|
|
@@ -60,11 +63,14 @@ describe Kitchen::Config do
|
|
60
63
|
{
|
61
64
|
:defaults => {
|
62
65
|
:driver => "dummy",
|
63
|
-
:provisioner => "chef_solo"
|
66
|
+
:provisioner => "chef_solo",
|
67
|
+
:transport => "ssh",
|
68
|
+
:verifier => "busser"
|
64
69
|
},
|
65
70
|
:kitchen_root => "/tmp/that/place",
|
66
71
|
:test_base_path => "/testing/yo",
|
67
|
-
:log_level => :debug
|
72
|
+
:log_level => :debug,
|
73
|
+
:log_overwrite => false
|
68
74
|
}
|
69
75
|
end
|
70
76
|
|
@@ -133,6 +139,19 @@ describe Kitchen::Config do
|
|
133
139
|
end
|
134
140
|
end
|
135
141
|
|
142
|
+
describe "#log_overwrite" do
|
143
|
+
|
144
|
+
it "returns its log level" do
|
145
|
+
config.log_overwrite.must_equal false
|
146
|
+
end
|
147
|
+
|
148
|
+
it "uses :info by default" do
|
149
|
+
opts.delete(:log_overwrite)
|
150
|
+
|
151
|
+
config.log_overwrite.must_equal true
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
136
155
|
describe "#platforms" do
|
137
156
|
|
138
157
|
before do
|
@@ -152,11 +171,13 @@ describe Kitchen::Config do
|
|
152
171
|
config.platforms
|
153
172
|
end
|
154
173
|
|
155
|
-
it "
|
174
|
+
it "constructs a munger with loader data and defaults" do
|
156
175
|
loader.stubs(:read).returns("datum")
|
157
176
|
|
158
|
-
Kitchen::DataMunger.expects(:new).with
|
159
|
-
|
177
|
+
Kitchen::DataMunger.expects(:new).with { |data, kitchen_config|
|
178
|
+
data.must_equal "datum"
|
179
|
+
kitchen_config.is_a?(Hash).must_equal true
|
180
|
+
}.returns(munger)
|
160
181
|
|
161
182
|
config.platforms
|
162
183
|
end
|
@@ -206,8 +227,10 @@ describe Kitchen::Config do
|
|
206
227
|
it "constucts a munger with loader data and defaults" do
|
207
228
|
loader.stubs(:read).returns("datum")
|
208
229
|
|
209
|
-
Kitchen::DataMunger.expects(:new).with
|
210
|
-
|
230
|
+
Kitchen::DataMunger.expects(:new).with { |data, kitchen_config|
|
231
|
+
data.must_equal "datum"
|
232
|
+
kitchen_config.is_a?(Hash).must_equal true
|
233
|
+
}.returns(munger)
|
211
234
|
|
212
235
|
config.suites
|
213
236
|
end
|
@@ -247,17 +270,19 @@ describe Kitchen::Config do
|
|
247
270
|
|
248
271
|
let(:munger) do
|
249
272
|
stub(
|
250
|
-
:busser_data_for => { "junk" => true },
|
251
273
|
:driver_data_for => { "junk" => true },
|
252
|
-
:provisioner_data_for => { "junk" => true }
|
274
|
+
:provisioner_data_for => { "junk" => true },
|
275
|
+
:transport_data_for => { "junk" => true },
|
276
|
+
:verifier_data_for => { "junk" => true }
|
253
277
|
)
|
254
278
|
end
|
255
279
|
|
256
280
|
before do
|
257
281
|
Kitchen::Instance.stubs(:new).returns("instance")
|
258
|
-
Kitchen::Busser.stubs(:new).returns("busser")
|
259
282
|
Kitchen::Driver.stubs(:for_plugin).returns("driver")
|
260
283
|
Kitchen::Provisioner.stubs(:for_plugin).returns("provisioner")
|
284
|
+
Kitchen::Transport.stubs(:for_plugin).returns("transport")
|
285
|
+
Kitchen::Verifier.stubs(:for_plugin).returns("verifier")
|
261
286
|
Kitchen::Logger.stubs(:new).returns("logger")
|
262
287
|
Kitchen::StateFile.stubs(:new).returns("state_file")
|
263
288
|
|
@@ -266,14 +291,6 @@ describe Kitchen::Config do
|
|
266
291
|
config.stubs(:suites).returns(suites)
|
267
292
|
end
|
268
293
|
|
269
|
-
it "constructs a Busser object" do
|
270
|
-
munger.expects(:busser_data_for).with("tiny", "unax").returns("datum")
|
271
|
-
Kitchen::Busser.unstub(:new)
|
272
|
-
Kitchen::Busser.expects(:new).with("tiny", "datum")
|
273
|
-
|
274
|
-
config.instances
|
275
|
-
end
|
276
|
-
|
277
294
|
it "constructs a Driver object" do
|
278
295
|
munger.expects(:driver_data_for).with("tiny", "unax").
|
279
296
|
returns(:name => "drivey", :datum => "lots")
|
@@ -294,12 +311,33 @@ describe Kitchen::Config do
|
|
294
311
|
config.instances
|
295
312
|
end
|
296
313
|
|
314
|
+
it "constructs a Transport object" do
|
315
|
+
munger.expects(:transport_data_for).with("tiny", "unax").
|
316
|
+
returns(:name => "transey", :datum => "lots")
|
317
|
+
Kitchen::Transport.unstub(:for_plugin)
|
318
|
+
Kitchen::Transport.expects(:for_plugin).
|
319
|
+
with("transey", :name => "transey", :datum => "lots")
|
320
|
+
|
321
|
+
config.instances
|
322
|
+
end
|
323
|
+
|
324
|
+
it "constructs a Verifier object" do
|
325
|
+
munger.expects(:verifier_data_for).with("tiny", "unax").
|
326
|
+
returns(:name => "vervey", :datum => "lots")
|
327
|
+
Kitchen::Verifier.unstub(:for_plugin)
|
328
|
+
Kitchen::Verifier.expects(:for_plugin).
|
329
|
+
with("vervey", :name => "vervey", :datum => "lots")
|
330
|
+
|
331
|
+
config.instances
|
332
|
+
end
|
333
|
+
|
297
334
|
it "constructs a Logger object" do
|
298
335
|
Kitchen::Logger.unstub(:new)
|
299
336
|
Kitchen::Logger.expects(:new).with(
|
300
337
|
:stdout => STDOUT,
|
301
338
|
:color => :cyan,
|
302
339
|
:logdev => "/tmp/logs/tiny-unax.log",
|
340
|
+
:log_overwrite => false,
|
303
341
|
:level => 0,
|
304
342
|
:progname => "tiny-unax"
|
305
343
|
)
|
@@ -316,15 +354,18 @@ describe Kitchen::Config do
|
|
316
354
|
|
317
355
|
it "constructs an Instance object from all built objects" do
|
318
356
|
Kitchen::Instance.unstub(:new)
|
357
|
+
|
319
358
|
Kitchen::Instance.expects(:new).with(
|
320
|
-
:busser => "busser",
|
321
359
|
:driver => "driver",
|
322
360
|
:logger => "logger",
|
323
361
|
:suite => suites.first,
|
324
362
|
:platform => platforms.first,
|
325
363
|
:provisioner => "provisioner",
|
364
|
+
:transport => "transport",
|
365
|
+
:verifier => "verifier",
|
326
366
|
:state_file => "state_file"
|
327
367
|
)
|
368
|
+
|
328
369
|
config.instances
|
329
370
|
end
|
330
371
|
end
|