test-kitchen 1.14.1 → 1.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Berksfile +1 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/Guardfile +5 -5
- data/Rakefile +5 -5
- data/bin/kitchen +1 -1
- data/features/step_definitions/gem_steps.rb +6 -6
- data/features/support/env.rb +6 -7
- data/lib/kitchen.rb +5 -7
- data/lib/kitchen/base64_stream.rb +2 -8
- data/lib/kitchen/cli.rb +76 -80
- data/lib/kitchen/collection.rb +0 -2
- data/lib/kitchen/color.rb +7 -9
- data/lib/kitchen/command.rb +0 -4
- data/lib/kitchen/command/action.rb +0 -3
- data/lib/kitchen/command/console.rb +4 -7
- data/lib/kitchen/command/diagnose.rb +7 -14
- data/lib/kitchen/command/driver_discover.rb +1 -4
- data/lib/kitchen/command/exec.rb +0 -3
- data/lib/kitchen/command/list.rb +9 -12
- data/lib/kitchen/command/login.rb +0 -3
- data/lib/kitchen/command/package.rb +0 -3
- data/lib/kitchen/command/sink.rb +6 -9
- data/lib/kitchen/command/test.rb +1 -4
- data/lib/kitchen/config.rb +25 -27
- data/lib/kitchen/configurable.rb +26 -31
- data/lib/kitchen/data_munger.rb +34 -36
- data/lib/kitchen/diagnostic.rb +5 -7
- data/lib/kitchen/driver.rb +3 -5
- data/lib/kitchen/driver/base.rb +0 -3
- data/lib/kitchen/driver/dummy.rb +0 -3
- data/lib/kitchen/driver/proxy.rb +0 -3
- data/lib/kitchen/driver/ssh_base.rb +13 -16
- data/lib/kitchen/errors.rb +11 -16
- data/lib/kitchen/generator/driver_create.rb +18 -21
- data/lib/kitchen/generator/init.rb +21 -26
- data/lib/kitchen/instance.rb +19 -23
- data/lib/kitchen/lazy_hash.rb +1 -2
- data/lib/kitchen/loader/yaml.rb +22 -25
- data/lib/kitchen/logger.rb +9 -14
- data/lib/kitchen/logging.rb +0 -3
- data/lib/kitchen/login_command.rb +0 -2
- data/lib/kitchen/metadata_chopper.rb +0 -2
- data/lib/kitchen/platform.rb +1 -3
- data/lib/kitchen/provisioner.rb +3 -5
- data/lib/kitchen/provisioner/base.rb +2 -5
- data/lib/kitchen/provisioner/chef/berkshelf.rb +1 -5
- data/lib/kitchen/provisioner/chef/common_sandbox.rb +24 -29
- data/lib/kitchen/provisioner/chef/librarian.rb +2 -6
- data/lib/kitchen/provisioner/chef/policyfile.rb +4 -8
- data/lib/kitchen/provisioner/chef_apply.rb +14 -17
- data/lib/kitchen/provisioner/chef_base.rb +43 -46
- data/lib/kitchen/provisioner/chef_solo.rb +10 -13
- data/lib/kitchen/provisioner/chef_zero.rb +22 -29
- data/lib/kitchen/provisioner/dummy.rb +0 -3
- data/lib/kitchen/provisioner/shell.rb +6 -9
- data/lib/kitchen/rake_tasks.rb +4 -6
- data/lib/kitchen/shell_out.rb +3 -5
- data/lib/kitchen/ssh.rb +16 -22
- data/lib/kitchen/state_file.rb +3 -5
- data/lib/kitchen/suite.rb +0 -2
- data/lib/kitchen/thor_tasks.rb +2 -4
- data/lib/kitchen/transport.rb +3 -5
- data/lib/kitchen/transport/base.rb +1 -7
- data/lib/kitchen/transport/dummy.rb +0 -4
- data/lib/kitchen/transport/ssh.rb +41 -47
- data/lib/kitchen/transport/winrm.rb +41 -40
- data/lib/kitchen/util.rb +1 -3
- data/lib/kitchen/verifier.rb +3 -5
- data/lib/kitchen/verifier/base.rb +2 -5
- data/lib/kitchen/verifier/busser.rb +24 -24
- data/lib/kitchen/verifier/dummy.rb +0 -3
- data/lib/kitchen/verifier/shell.rb +1 -3
- data/lib/kitchen/version.rb +1 -1
- data/lib/vendor/hash_recursive_merge.rb +0 -2
- data/spec/kitchen/base64_stream_spec.rb +3 -6
- data/spec/kitchen/cli_spec.rb +0 -2
- data/spec/kitchen/collection_spec.rb +4 -8
- data/spec/kitchen/color_spec.rb +0 -3
- data/spec/kitchen/config_spec.rb +91 -106
- data/spec/kitchen/configurable_spec.rb +44 -76
- data/spec/kitchen/data_munger_spec.rb +1178 -1247
- data/spec/kitchen/diagnostic_spec.rb +37 -38
- data/spec/kitchen/driver/base_spec.rb +7 -14
- data/spec/kitchen/driver/dummy_spec.rb +1 -7
- data/spec/kitchen/driver/proxy_spec.rb +2 -7
- data/spec/kitchen/driver/ssh_base_spec.rb +128 -149
- data/spec/kitchen/driver_spec.rb +7 -13
- data/spec/kitchen/errors_spec.rb +50 -60
- data/spec/kitchen/instance_spec.rb +217 -294
- data/spec/kitchen/lazy_hash_spec.rb +14 -18
- data/spec/kitchen/loader/yaml_spec.rb +201 -227
- data/spec/kitchen/logger_spec.rb +7 -15
- data/spec/kitchen/logging_spec.rb +1 -4
- data/spec/kitchen/login_command_spec.rb +3 -4
- data/spec/kitchen/metadata_chopper_spec.rb +0 -3
- data/spec/kitchen/platform_spec.rb +31 -32
- data/spec/kitchen/provisioner/base_spec.rb +22 -41
- data/spec/kitchen/provisioner/chef/policyfile_spec.rb +15 -15
- data/spec/kitchen/provisioner/chef_apply_spec.rb +8 -13
- data/spec/kitchen/provisioner/chef_base_spec.rb +150 -182
- data/spec/kitchen/provisioner/chef_solo_spec.rb +58 -72
- data/spec/kitchen/provisioner/chef_zero_spec.rb +99 -125
- data/spec/kitchen/provisioner/dummy_spec.rb +8 -11
- data/spec/kitchen/provisioner/shell_spec.rb +86 -103
- data/spec/kitchen/provisioner_spec.rb +5 -11
- data/spec/kitchen/shell_out_spec.rb +15 -19
- data/spec/kitchen/ssh_spec.rb +16 -35
- data/spec/kitchen/state_file_spec.rb +6 -11
- data/spec/kitchen/suite_spec.rb +5 -6
- data/spec/kitchen/transport/base_spec.rb +6 -14
- data/spec/kitchen/transport/ssh_spec.rb +39 -64
- data/spec/kitchen/transport/winrm_spec.rb +99 -127
- data/spec/kitchen/transport_spec.rb +7 -13
- data/spec/kitchen/util_spec.rb +17 -26
- data/spec/kitchen/verifier/base_spec.rb +24 -40
- data/spec/kitchen/verifier/busser_spec.rb +38 -68
- data/spec/kitchen/verifier/dummy_spec.rb +8 -11
- data/spec/kitchen/verifier/shell_spec.rb +14 -17
- data/spec/kitchen/verifier_spec.rb +7 -13
- data/spec/kitchen_spec.rb +4 -6
- data/spec/spec_helper.rb +1 -1
- data/spec/support/powershell_max_size_spec.rb +1 -2
- data/support/chef-client-zero.rb +3 -4
- data/test-kitchen.gemspec +4 -6
- metadata +9 -9
data/lib/kitchen/driver/base.rb
CHANGED
data/lib/kitchen/driver/dummy.rb
CHANGED
|
@@ -19,9 +19,7 @@
|
|
|
19
19
|
require "kitchen"
|
|
20
20
|
|
|
21
21
|
module Kitchen
|
|
22
|
-
|
|
23
22
|
module Driver
|
|
24
|
-
|
|
25
23
|
# Dummy driver for Kitchen. This driver does nothing but report what would
|
|
26
24
|
# happen if this driver did anything of consequence. As a result it may
|
|
27
25
|
# be a useful driver to use when debugging or developing new features or
|
|
@@ -29,7 +27,6 @@ module Kitchen
|
|
|
29
27
|
#
|
|
30
28
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
|
31
29
|
class Dummy < Kitchen::Driver::Base
|
|
32
|
-
|
|
33
30
|
kitchen_driver_api_version 2
|
|
34
31
|
|
|
35
32
|
plugin_version Kitchen::VERSION
|
data/lib/kitchen/driver/proxy.rb
CHANGED
|
@@ -22,9 +22,7 @@ require "kitchen"
|
|
|
22
22
|
require "kitchen/version"
|
|
23
23
|
|
|
24
24
|
module Kitchen
|
|
25
|
-
|
|
26
25
|
module Driver
|
|
27
|
-
|
|
28
26
|
# Simple driver that proxies commands through to a test instance whose
|
|
29
27
|
# lifecycle is not managed by Test Kitchen. This driver is useful for long-
|
|
30
28
|
# lived non-ephemeral test instances that are simply "reset" between test
|
|
@@ -33,7 +31,6 @@ module Kitchen
|
|
|
33
31
|
#
|
|
34
32
|
# @author Seth Chisamore <schisamo@opscode.com>
|
|
35
33
|
class Proxy < Kitchen::Driver::SSHBase
|
|
36
|
-
|
|
37
34
|
plugin_version Kitchen::VERSION
|
|
38
35
|
|
|
39
36
|
required_config :host
|
|
@@ -22,9 +22,7 @@ require "kitchen/lazy_hash"
|
|
|
22
22
|
require "benchmark"
|
|
23
23
|
|
|
24
24
|
module Kitchen
|
|
25
|
-
|
|
26
25
|
module Driver
|
|
27
|
-
|
|
28
26
|
# Legacy base class for a driver that uses SSH to communication with an
|
|
29
27
|
# instance. This class has been updated to use the Instance's Transport to
|
|
30
28
|
# issue commands and transfer files and no longer uses the `Kitchen:SSH`
|
|
@@ -46,7 +44,6 @@ module Kitchen
|
|
|
46
44
|
# Drivers. When legacy Driver::SSHBase support is removed, this class
|
|
47
45
|
# will no longer be available.
|
|
48
46
|
class SSHBase
|
|
49
|
-
|
|
50
47
|
include ShellOut
|
|
51
48
|
include Configurable
|
|
52
49
|
include Logging
|
|
@@ -138,8 +135,8 @@ module Kitchen
|
|
|
138
135
|
|
|
139
136
|
# (see Base#login_command)
|
|
140
137
|
def login_command(state)
|
|
141
|
-
instance.transport.connection(backcompat_merged_state(state))
|
|
142
|
-
|
|
138
|
+
instance.transport.connection(backcompat_merged_state(state))
|
|
139
|
+
.login_command
|
|
143
140
|
end
|
|
144
141
|
|
|
145
142
|
# Executes an arbitrary command on an instance over an SSH connection.
|
|
@@ -160,7 +157,7 @@ module Kitchen
|
|
|
160
157
|
# @deprecated This method should no longer be called directly and exists
|
|
161
158
|
# to support very old drivers. This will be removed in the future.
|
|
162
159
|
def ssh(ssh_args, command)
|
|
163
|
-
pseudo_state = { :
|
|
160
|
+
pseudo_state = { hostname: ssh_args[0], username: ssh_args[1] }
|
|
164
161
|
pseudo_state.merge!(ssh_args[2])
|
|
165
162
|
connection_state = backcompat_merged_state(pseudo_state)
|
|
166
163
|
|
|
@@ -226,9 +223,9 @@ module Kitchen
|
|
|
226
223
|
private
|
|
227
224
|
|
|
228
225
|
def backcompat_merged_state(state)
|
|
229
|
-
driver_ssh_keys = %w
|
|
226
|
+
driver_ssh_keys = %w{
|
|
230
227
|
forward_agent hostname password port ssh_key username
|
|
231
|
-
|
|
228
|
+
}.map(&:to_sym)
|
|
232
229
|
config.select { |key, _| driver_ssh_keys.include?(key) }.rmerge(state)
|
|
233
230
|
end
|
|
234
231
|
|
|
@@ -240,7 +237,7 @@ module Kitchen
|
|
|
240
237
|
def build_ssh_args(state)
|
|
241
238
|
combined = config.to_hash.merge(state)
|
|
242
239
|
|
|
243
|
-
opts =
|
|
240
|
+
opts = {}
|
|
244
241
|
opts[:user_known_hosts_file] = "/dev/null"
|
|
245
242
|
opts[:paranoid] = false
|
|
246
243
|
opts[:keys_only] = true if combined[:ssh_key]
|
|
@@ -272,8 +269,8 @@ module Kitchen
|
|
|
272
269
|
no_proxy = if (!config[:http_proxy] && http_proxy) ||
|
|
273
270
|
(!config[:https_proxy] && https_proxy) ||
|
|
274
271
|
(!config[:ftp_proxy] && ftp_proxy)
|
|
275
|
-
|
|
276
|
-
|
|
272
|
+
ENV["no_proxy"] || ENV["NO_PROXY"]
|
|
273
|
+
end
|
|
277
274
|
env << " http_proxy=#{http_proxy}" if http_proxy
|
|
278
275
|
env << " https_proxy=#{https_proxy}" if https_proxy
|
|
279
276
|
env << " ftp_proxy=#{ftp_proxy}" if ftp_proxy
|
|
@@ -335,12 +332,12 @@ module Kitchen
|
|
|
335
332
|
# @param options [Hash] configuration hash (default: `{}`)
|
|
336
333
|
# @api private
|
|
337
334
|
def wait_for_sshd(hostname, username = nil, options = {})
|
|
338
|
-
pseudo_state = { :
|
|
335
|
+
pseudo_state = { hostname: hostname }
|
|
339
336
|
pseudo_state[:username] = username if username
|
|
340
337
|
pseudo_state.merge!(options)
|
|
341
338
|
|
|
342
|
-
instance.transport.connection(backcompat_merged_state(pseudo_state))
|
|
343
|
-
|
|
339
|
+
instance.transport.connection(backcompat_merged_state(pseudo_state))
|
|
340
|
+
.wait_until_ready
|
|
344
341
|
end
|
|
345
342
|
|
|
346
343
|
# Intercepts any bare #puts calls in subclasses and issues an INFO log
|
|
@@ -370,8 +367,8 @@ module Kitchen
|
|
|
370
367
|
# @see ShellOut#run_command
|
|
371
368
|
def run_command(cmd, options = {})
|
|
372
369
|
base_options = {
|
|
373
|
-
:
|
|
374
|
-
:
|
|
370
|
+
use_sudo: config[:use_sudo],
|
|
371
|
+
log_subject: Thor::Util.snake_case(self.class.to_s),
|
|
375
372
|
}.merge(options)
|
|
376
373
|
super(cmd, base_options)
|
|
377
374
|
end
|
data/lib/kitchen/errors.rb
CHANGED
|
@@ -19,12 +19,10 @@
|
|
|
19
19
|
require "English"
|
|
20
20
|
|
|
21
21
|
module Kitchen
|
|
22
|
-
|
|
23
22
|
# All Kitchen errors and exceptions.
|
|
24
23
|
#
|
|
25
24
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
|
26
25
|
module Error
|
|
27
|
-
|
|
28
26
|
# Creates an array of strings, representing a formatted exception,
|
|
29
27
|
# containing backtrace and nested exception info as necessary, that can
|
|
30
28
|
# be viewed by a human.
|
|
@@ -49,15 +47,15 @@ module Kitchen
|
|
|
49
47
|
|
|
50
48
|
if exception.respond_to?(:original) && exception.original
|
|
51
49
|
arr += if exception.original.is_a? Array
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
exception.original.map do |composite_exception|
|
|
51
|
+
formatted_trace(composite_exception, "Composite Exception").flatten
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
[
|
|
55
|
+
formatted_exception(exception.original, "Nested Exception"),
|
|
56
|
+
formatted_backtrace(exception),
|
|
57
|
+
].flatten
|
|
58
|
+
end
|
|
61
59
|
end
|
|
62
60
|
arr.flatten
|
|
63
61
|
end
|
|
@@ -69,7 +67,7 @@ module Kitchen
|
|
|
69
67
|
[
|
|
70
68
|
"Backtrace".center(22, "-"),
|
|
71
69
|
exception.backtrace,
|
|
72
|
-
"End Backtrace".center(22, "-")
|
|
70
|
+
"End Backtrace".center(22, "-"),
|
|
73
71
|
]
|
|
74
72
|
end
|
|
75
73
|
end
|
|
@@ -94,7 +92,7 @@ module Kitchen
|
|
|
94
92
|
title.center(22, "-"),
|
|
95
93
|
"Class: #{exception.class}",
|
|
96
94
|
"Message: #{exception.message}",
|
|
97
|
-
"".center(22, "-")
|
|
95
|
+
"".center(22, "-"),
|
|
98
96
|
]
|
|
99
97
|
end
|
|
100
98
|
end
|
|
@@ -102,7 +100,6 @@ module Kitchen
|
|
|
102
100
|
# Base exception class from which all Kitchen exceptions derive. This class
|
|
103
101
|
# nests an exception when this class is re-raised from a rescue block.
|
|
104
102
|
class StandardError < ::StandardError
|
|
105
|
-
|
|
106
103
|
include Error
|
|
107
104
|
|
|
108
105
|
# @return [::StandardError] the original (wrapped) exception
|
|
@@ -184,8 +181,6 @@ module Kitchen
|
|
|
184
181
|
exit 20
|
|
185
182
|
end
|
|
186
183
|
|
|
187
|
-
private
|
|
188
|
-
|
|
189
184
|
# Writes an array of lines to the common Kitchen logger's file device at the
|
|
190
185
|
# given severity level. If the Kitchen logger is set to debug severity, then
|
|
191
186
|
# the array of lines will also be written to the console output.
|
|
@@ -20,22 +20,19 @@ require "thor/group"
|
|
|
20
20
|
require "thor/util"
|
|
21
21
|
|
|
22
22
|
module Kitchen
|
|
23
|
-
|
|
24
23
|
module Generator
|
|
25
|
-
|
|
26
24
|
# A generator to create a new Kitchen Driver gem project.
|
|
27
25
|
#
|
|
28
26
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
|
29
27
|
class DriverCreate < Thor::Group
|
|
30
|
-
|
|
31
28
|
include Thor::Actions
|
|
32
29
|
|
|
33
|
-
argument :name, :
|
|
30
|
+
argument :name, type: :string
|
|
34
31
|
|
|
35
32
|
class_option :license,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
aliases: "-l",
|
|
34
|
+
default: "apachev2",
|
|
35
|
+
desc: "License type for gem (apachev2, mit, lgplv3, reserved)"
|
|
39
36
|
|
|
40
37
|
# Invoke the command.
|
|
41
38
|
def create
|
|
@@ -87,8 +84,8 @@ module Kitchen
|
|
|
87
84
|
# @api private
|
|
88
85
|
def initialize_git
|
|
89
86
|
inside(target_dir) do
|
|
90
|
-
run("git init", :
|
|
91
|
-
run("git add .", :
|
|
87
|
+
run("git init", capture: true)
|
|
88
|
+
run("git add .", capture: true)
|
|
92
89
|
end
|
|
93
90
|
end
|
|
94
91
|
|
|
@@ -112,16 +109,16 @@ module Kitchen
|
|
|
112
109
|
# @api private
|
|
113
110
|
def config
|
|
114
111
|
@config ||= {
|
|
115
|
-
:
|
|
116
|
-
:
|
|
117
|
-
:
|
|
118
|
-
:
|
|
119
|
-
:
|
|
120
|
-
:
|
|
121
|
-
:
|
|
122
|
-
:
|
|
123
|
-
:
|
|
124
|
-
:
|
|
112
|
+
name: name,
|
|
113
|
+
gem_name: "kitchen-#{name}",
|
|
114
|
+
gemspec: "kitchen-#{name}.gemspec",
|
|
115
|
+
klass_name: ::Thor::Util.camel_case(name),
|
|
116
|
+
constant_name: ::Thor::Util.snake_case(name).upcase,
|
|
117
|
+
author: author,
|
|
118
|
+
email: email,
|
|
119
|
+
license: options[:license],
|
|
120
|
+
license_string: license_string,
|
|
121
|
+
year: Time.now.year,
|
|
125
122
|
}
|
|
126
123
|
end
|
|
127
124
|
|
|
@@ -169,8 +166,8 @@ module Kitchen
|
|
|
169
166
|
# @return [String] the license comment/preamble
|
|
170
167
|
# @api private
|
|
171
168
|
def license_comment
|
|
172
|
-
@license_comment ||= IO.read(File.join(target_dir, license_filename))
|
|
173
|
-
|
|
169
|
+
@license_comment ||= IO.read(File.join(target_dir, license_filename))
|
|
170
|
+
.gsub(/^/, "# ").gsub(/\s+$/, "")
|
|
174
171
|
end
|
|
175
172
|
end
|
|
176
173
|
end
|
|
@@ -20,38 +20,35 @@ require "rubygems/gem_runner"
|
|
|
20
20
|
require "thor/group"
|
|
21
21
|
|
|
22
22
|
module Kitchen
|
|
23
|
-
|
|
24
23
|
module Generator
|
|
25
|
-
|
|
26
24
|
# A project initialization generator, to help prepare a cookbook project
|
|
27
25
|
# for testing with Kitchen.
|
|
28
26
|
#
|
|
29
27
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
|
30
28
|
class Init < Thor::Group
|
|
31
|
-
|
|
32
29
|
include Thor::Actions
|
|
33
30
|
|
|
34
31
|
class_option :driver,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
type: :array,
|
|
33
|
+
aliases: "-D",
|
|
34
|
+
default: %w{kitchen-vagrant},
|
|
35
|
+
desc: <<-D.gsub(/^\s+/, "").tr("\n", " ")
|
|
39
36
|
One or more Kitchen Driver gems to be installed or added to a
|
|
40
37
|
Gemfile
|
|
41
38
|
D
|
|
42
39
|
|
|
43
40
|
class_option :provisioner,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
type: :string,
|
|
42
|
+
aliases: "-P",
|
|
43
|
+
default: "chef_solo",
|
|
44
|
+
desc: <<-D.gsub(/^\s+/, "").tr("\n", " ")
|
|
48
45
|
The default Kitchen Provisioner to use
|
|
49
46
|
D
|
|
50
47
|
|
|
51
48
|
class_option :create_gemfile,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
type: :boolean,
|
|
50
|
+
default: false,
|
|
51
|
+
desc: <<-D.gsub(/^\s+/, "").tr("\n", " ")
|
|
55
52
|
Whether or not to create a Gemfile if one does not exist.
|
|
56
53
|
Default: false
|
|
57
54
|
D
|
|
@@ -78,18 +75,16 @@ module Kitchen
|
|
|
78
75
|
# @api private
|
|
79
76
|
def create_kitchen_yaml
|
|
80
77
|
cookbook_name = if File.exist?(File.expand_path("metadata.rb"))
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
nil
|
|
84
|
-
end
|
|
78
|
+
MetadataChopper.extract("metadata.rb").first
|
|
79
|
+
end
|
|
85
80
|
run_list = cookbook_name ? "recipe[#{cookbook_name}::default]" : nil
|
|
86
81
|
driver_plugin = Array(options[:driver]).first || "dummy"
|
|
87
82
|
|
|
88
83
|
template("kitchen.yml.erb", ".kitchen.yml",
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
driver_plugin: driver_plugin.sub(/^kitchen-/, ""),
|
|
85
|
+
provisioner: options[:provisioner],
|
|
86
|
+
run_list: Array(run_list)
|
|
87
|
+
)
|
|
93
88
|
end
|
|
94
89
|
|
|
95
90
|
# Creates the `chefignore` file.
|
|
@@ -193,7 +188,7 @@ module Kitchen
|
|
|
193
188
|
def append_to_gitignore(line)
|
|
194
189
|
create_file(".gitignore") unless File.exist?(File.join(destination_root, ".gitignore"))
|
|
195
190
|
|
|
196
|
-
if IO.readlines(File.join(destination_root, ".gitignore")).grep(
|
|
191
|
+
if IO.readlines(File.join(destination_root, ".gitignore")).grep(/^#{line}/).empty?
|
|
197
192
|
append_to_file(".gitignore", "#{line}\n")
|
|
198
193
|
end
|
|
199
194
|
end
|
|
@@ -221,7 +216,7 @@ module Kitchen
|
|
|
221
216
|
#
|
|
222
217
|
# @api private
|
|
223
218
|
def add_gem_to_gemfile
|
|
224
|
-
if not_in_file?("Gemfile",
|
|
219
|
+
if not_in_file?("Gemfile", /gem ('|")test-kitchen('|")/)
|
|
225
220
|
append_to_file("Gemfile", %{gem "test-kitchen"\n})
|
|
226
221
|
@display_bundle_msg = true
|
|
227
222
|
end
|
|
@@ -246,7 +241,7 @@ module Kitchen
|
|
|
246
241
|
#
|
|
247
242
|
# @api private
|
|
248
243
|
def add_driver_to_gemfile(driver_gem)
|
|
249
|
-
if not_in_file?("Gemfile",
|
|
244
|
+
if not_in_file?("Gemfile", /gem ('|")#{driver_gem}('|")/)
|
|
250
245
|
append_to_file("Gemfile", %{gem "#{driver_gem}"\n})
|
|
251
246
|
@display_bundle_msg = true
|
|
252
247
|
end
|
|
@@ -285,7 +280,7 @@ module Kitchen
|
|
|
285
280
|
#
|
|
286
281
|
# @api private
|
|
287
282
|
def unbundlerize
|
|
288
|
-
keys = ENV.keys.select { |key| key =~ /^BUNDLER?_/ } + %w
|
|
283
|
+
keys = ENV.keys.select { |key| key =~ /^BUNDLER?_/ } + %w{RUBYOPT}
|
|
289
284
|
|
|
290
285
|
keys.each { |key| ENV["__#{key}"] = ENV[key]; ENV.delete(key) }
|
|
291
286
|
yield
|
data/lib/kitchen/instance.rb
CHANGED
|
@@ -20,18 +20,15 @@ require "benchmark"
|
|
|
20
20
|
require "fileutils"
|
|
21
21
|
|
|
22
22
|
module Kitchen
|
|
23
|
-
|
|
24
23
|
# An instance of a suite running on a platform. A created instance may be a
|
|
25
24
|
# local virtual machine, cloud instance, container, or even a bare metal
|
|
26
25
|
# server, which is determined by the platform's driver.
|
|
27
26
|
#
|
|
28
27
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
|
29
28
|
class Instance
|
|
30
|
-
|
|
31
29
|
include Logging
|
|
32
30
|
|
|
33
31
|
class << self
|
|
34
|
-
|
|
35
32
|
# @return [Hash] a hash of mutxes, arranged by Driver class names
|
|
36
33
|
# @api private
|
|
37
34
|
attr_accessor :mutexes
|
|
@@ -42,7 +39,7 @@ module Kitchen
|
|
|
42
39
|
# @param platform [Platform,#name] a Platform
|
|
43
40
|
# @return [String] a normalized, consistent name for an instance
|
|
44
41
|
def name_for(suite, platform)
|
|
45
|
-
"#{suite.name}-#{platform.name}".gsub(%r{[_,/]}, "-").
|
|
42
|
+
"#{suite.name}-#{platform.name}".gsub(%r{[_,/]}, "-").delete(".")
|
|
46
43
|
end
|
|
47
44
|
end
|
|
48
45
|
|
|
@@ -210,12 +207,12 @@ module Kitchen
|
|
|
210
207
|
end
|
|
211
208
|
|
|
212
209
|
lc = if legacy_ssh_base_driver?
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
legacy_ssh_base_login(state)
|
|
211
|
+
else
|
|
212
|
+
transport.connection(state).login_command
|
|
213
|
+
end
|
|
217
214
|
|
|
218
|
-
debug(%{Login command: #{lc.command} #{lc.arguments.join(
|
|
215
|
+
debug(%{Login command: #{lc.command} #{lc.arguments.join(' ')} } \
|
|
219
216
|
"(Options: #{lc.options})")
|
|
220
217
|
Kernel.exec(*lc.exec_args)
|
|
221
218
|
end
|
|
@@ -240,7 +237,7 @@ module Kitchen
|
|
|
240
237
|
#
|
|
241
238
|
# @return [Hash] a diagnostic hash
|
|
242
239
|
def diagnose
|
|
243
|
-
result =
|
|
240
|
+
result = {}
|
|
244
241
|
[
|
|
245
242
|
:platform, :state_file, :driver, :provisioner, :transport, :verifier
|
|
246
243
|
].each do |sym|
|
|
@@ -255,14 +252,14 @@ module Kitchen
|
|
|
255
252
|
#
|
|
256
253
|
# @return [Hash] a diagnostic hash
|
|
257
254
|
def diagnose_plugins
|
|
258
|
-
result =
|
|
255
|
+
result = {}
|
|
259
256
|
[:driver, :provisioner, :verifier, :transport].each do |sym|
|
|
260
257
|
obj = send(sym)
|
|
261
258
|
result[sym] = if obj.respond_to?(:diagnose_plugin)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
259
|
+
obj.diagnose_plugin
|
|
260
|
+
else
|
|
261
|
+
:unknown
|
|
262
|
+
end
|
|
266
263
|
end
|
|
267
264
|
result
|
|
268
265
|
end
|
|
@@ -321,7 +318,7 @@ module Kitchen
|
|
|
321
318
|
|
|
322
319
|
if driver.class.serial_actions
|
|
323
320
|
Kitchen.mutex.synchronize do
|
|
324
|
-
self.class.mutexes ||=
|
|
321
|
+
self.class.mutexes ||= {}
|
|
325
322
|
self.class.mutexes[driver.class] = Mutex.new
|
|
326
323
|
end
|
|
327
324
|
end
|
|
@@ -499,12 +496,12 @@ module Kitchen
|
|
|
499
496
|
state[:last_error] = e.class.name
|
|
500
497
|
raise(InstanceFailure, failure_message(what) +
|
|
501
498
|
" Please see .kitchen/logs/#{name}.log for more details",
|
|
502
|
-
|
|
499
|
+
e.backtrace)
|
|
503
500
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
504
501
|
log_failure(what, e)
|
|
505
502
|
state[:last_error] = e.class.name
|
|
506
503
|
raise ActionFailed,
|
|
507
|
-
|
|
504
|
+
"Failed to complete ##{what} action: [#{e.message}]", e.backtrace
|
|
508
505
|
ensure
|
|
509
506
|
state_file.write(state)
|
|
510
507
|
end
|
|
@@ -519,15 +516,15 @@ module Kitchen
|
|
|
519
516
|
# @param state [Hash] a mutable state hash for this instance
|
|
520
517
|
# @param block [Proc] a block to be called
|
|
521
518
|
# @api private
|
|
522
|
-
def synchronize_or_call(what, state
|
|
519
|
+
def synchronize_or_call(what, state)
|
|
523
520
|
if Array(driver.class.serial_actions).include?(what)
|
|
524
521
|
debug("#{to_str} is synchronizing on #{driver.class}##{what}")
|
|
525
522
|
self.class.mutexes[driver.class].synchronize do
|
|
526
523
|
debug("#{to_str} is messaging #{driver.class}##{what}")
|
|
527
|
-
|
|
524
|
+
yield(state)
|
|
528
525
|
end
|
|
529
526
|
else
|
|
530
|
-
|
|
527
|
+
yield(state)
|
|
531
528
|
end
|
|
532
529
|
end
|
|
533
530
|
|
|
@@ -639,7 +636,6 @@ module Kitchen
|
|
|
639
636
|
# @api private
|
|
640
637
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
|
641
638
|
class FSM
|
|
642
|
-
|
|
643
639
|
# Returns an Array of all transitions to bring an Instance from its last
|
|
644
640
|
# reported transistioned state into the desired transitioned state.
|
|
645
641
|
#
|
|
@@ -660,7 +656,7 @@ module Kitchen
|
|
|
660
656
|
end
|
|
661
657
|
end
|
|
662
658
|
|
|
663
|
-
TRANSITIONS = [:destroy, :create, :converge, :setup, :verify]
|
|
659
|
+
TRANSITIONS = [:destroy, :create, :converge, :setup, :verify].freeze
|
|
664
660
|
|
|
665
661
|
# Determines the index of a state in the state lifecycle vector. Woah.
|
|
666
662
|
#
|