test-kitchen 2.2.5 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25783a8b110ce3743a0da21ee576b2a83dd9cc218bfba75e0f86e350d5a429cb
4
- data.tar.gz: 8dc2c81284b6a7152b95155225078d8e85ccd0b3742e40a4b0c4daef3ecb1151
3
+ metadata.gz: 42bf489a9ab86a4c1c88cc74e8a257ce2b6241a199fcd337b59a1b7ee32f321f
4
+ data.tar.gz: 1c89f445f99ceec9e677ba75cdbbd662b150b36ebbecaadccbf1378d57edca0d
5
5
  SHA512:
6
- metadata.gz: 4d7270665bf6fbab9f7876a5347f97bb821a0bc9ece8a14378ce625fea305e3b7145de6f6409c9b7cf20f27ca481f368671a66c48ba694777056d80ce6fe11a9
7
- data.tar.gz: 4d072e0b670d1b9b583f746b5850885bfa0484ece4f8b6826e33019110685e6be3daea984067801182fcdf75d45d93937e9a8b09103b83551f2374b6c4c37fd9
6
+ metadata.gz: f81c55631f7f772e3f0a3a1d6ef25116632b5500ad3e782f8f2e97dfcb691c6c397f2a5589248dac7a90a95459558cde767398e052c322b48525dd896f389388
7
+ data.tar.gz: 57e8f9a2ea674ee43f2e589a52b5e259c749840f122a9094a997c6968bf4e35143c4fc20d8e4accf44454c1d03d252429c8b4272c205328a01f56be6d16dcce5
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ rescue LoadError
20
20
  end
21
21
 
22
22
  desc "Run all test suites"
23
- task test: [:unit, :features]
23
+ task test: %i{unit features}
24
24
 
25
25
  desc "Display LOC stats"
26
26
  task :stats do
@@ -41,7 +41,7 @@ rescue LoadError
41
41
  end
42
42
 
43
43
  desc "Run all quality tasks"
44
- task quality: [:style, :stats]
44
+ task quality: %i{style stats}
45
45
 
46
46
  begin
47
47
  require "yard"
@@ -50,7 +50,7 @@ rescue LoadError
50
50
  puts "yard is not available. (sudo) gem install yard to generate yard documentation."
51
51
  end
52
52
 
53
- task default: [:test, :quality]
53
+ task default: %i{test quality}
54
54
 
55
55
  begin
56
56
  require "github_changelog_generator/task"
@@ -82,38 +82,38 @@ module Kitchen
82
82
  # @api private
83
83
  def self.log_options
84
84
  method_option :log_level,
85
- aliases: "-l",
86
- desc: "Set the log level (debug, info, warn, error, fatal)"
85
+ aliases: "-l",
86
+ desc: "Set the log level (debug, info, warn, error, fatal)"
87
87
  method_option :log_overwrite,
88
- desc: "Set to false to prevent log overwriting each time Test Kitchen runs",
89
- type: :boolean
88
+ desc: "Set to false to prevent log overwriting each time Test Kitchen runs",
89
+ type: :boolean
90
90
  method_option :color,
91
- type: :boolean,
92
- lazy_default: $stdout.tty?,
93
- desc: "Toggle color output for STDOUT logger"
91
+ type: :boolean,
92
+ lazy_default: $stdout.tty?,
93
+ desc: "Toggle color output for STDOUT logger"
94
94
  end
95
95
 
96
96
  # Sets the test_base_path method_options
97
97
  # @api private
98
98
  def self.test_base_path
99
99
  method_option :test_base_path,
100
- aliases: "-t",
101
- desc: "Set the base path of the tests"
100
+ aliases: "-t",
101
+ desc: "Set the base path of the tests"
102
102
  end
103
103
 
104
104
  desc "list [INSTANCE|REGEXP|all]", "Lists one or more instances"
105
105
  method_option :bare,
106
- aliases: "-b",
107
- type: :boolean,
108
- desc: "List the name of each instance only, one per line"
106
+ aliases: "-b",
107
+ type: :boolean,
108
+ desc: "List the name of each instance only, one per line"
109
109
  method_option :json,
110
- aliases: "-j",
111
- type: :boolean,
112
- desc: "Print data as JSON"
110
+ aliases: "-j",
111
+ type: :boolean,
112
+ desc: "Print data as JSON"
113
113
  method_option :debug,
114
- aliases: "-d",
115
- type: :boolean,
116
- desc: "[Deprecated] Please use `kitchen diagnose'"
114
+ aliases: "-d",
115
+ type: :boolean,
116
+ desc: "[Deprecated] Please use `kitchen diagnose'"
117
117
  log_options
118
118
  def list(*args)
119
119
  update_config!
@@ -123,18 +123,18 @@ module Kitchen
123
123
 
124
124
  desc "diagnose [INSTANCE|REGEXP|all]", "Show computed diagnostic configuration"
125
125
  method_option :loader,
126
- type: :boolean,
127
- desc: "Include data loader diagnostics"
126
+ type: :boolean,
127
+ desc: "Include data loader diagnostics"
128
128
  method_option :plugins,
129
- type: :boolean,
130
- desc: "Include plugin diagnostics"
129
+ type: :boolean,
130
+ desc: "Include plugin diagnostics"
131
131
  method_option :instances,
132
- type: :boolean,
133
- default: true,
134
- desc: "Include instances diagnostics"
132
+ type: :boolean,
133
+ default: true,
134
+ desc: "Include instances diagnostics"
135
135
  method_option :all,
136
- type: :boolean,
137
- desc: "Include all diagnostics"
136
+ type: :boolean,
137
+ desc: "Include all diagnostics"
138
138
  log_options
139
139
  test_base_path
140
140
  def diagnose(*args)
@@ -165,27 +165,32 @@ module Kitchen
165
165
  intermediate states will be executed. See http://kitchen.ci for further explanation.
166
166
  DESC
167
167
  method_option :concurrency,
168
- aliases: "-c",
169
- type: :numeric,
170
- lazy_default: MAX_CONCURRENCY,
171
- desc: <<-DESC.gsub(/^\s+/, "").tr("\n", " ")
168
+ aliases: "-c",
169
+ type: :numeric,
170
+ lazy_default: MAX_CONCURRENCY,
171
+ desc: <<-DESC.gsub(/^\s+/, "").tr("\n", " ")
172
172
  Run a #{action} against all matching instances concurrently. Only N
173
173
  instances will run at the same time if a number is given.
174
- DESC
174
+ DESC
175
175
  method_option :parallel,
176
- aliases: "-p",
177
- type: :boolean,
178
- desc: <<-DESC.gsub(/^\s+/, "").tr("\n", " ")
176
+ aliases: "-p",
177
+ type: :boolean,
178
+ desc: <<-DESC.gsub(/^\s+/, "").tr("\n", " ")
179
179
  [Future DEPRECATION, use --concurrency]
180
180
  Run a #{action} against all matching instances concurrently.
181
- DESC
181
+ DESC
182
182
  if action == :converge || action == :verify
183
183
  method_option :debug,
184
- aliases: "-D",
185
- type: :boolean,
186
- default: false,
187
- desc: "Run the #{action} with debugging enabled."
184
+ aliases: "-D",
185
+ type: :boolean,
186
+ default: false,
187
+ desc: "Run the #{action} with debugging enabled."
188
188
  end
189
+ method_option :fail_fast,
190
+ aliases: "-f",
191
+ type: :boolean,
192
+ desc: "Fail immediately when errors occur in concurrency mode"
193
+
189
194
  test_base_path
190
195
  log_options
191
196
  define_method(action) do |*args|
@@ -195,7 +200,7 @@ module Kitchen
195
200
  end
196
201
 
197
202
  desc "test [INSTANCE|REGEXP|all]",
198
- "Test (destroy, create, converge, setup, verify and destroy) one or more instances"
203
+ "Test (destroy, create, converge, setup, verify and destroy) one or more instances"
199
204
  long_desc <<-DESC
200
205
  The instance states are in order: destroy, create, converge, setup, verify, destroy.
201
206
  Test changes the state of one or more instances to destroyed, then executes
@@ -210,33 +215,33 @@ module Kitchen
210
215
  * never: instances will never be destroyed afterwards.
211
216
  DESC
212
217
  method_option :concurrency,
213
- aliases: "-c",
214
- type: :numeric,
215
- lazy_default: MAX_CONCURRENCY,
216
- desc: <<-DESC.gsub(/^\s+/, "").tr("\n", " ")
218
+ aliases: "-c",
219
+ type: :numeric,
220
+ lazy_default: MAX_CONCURRENCY,
221
+ desc: <<-DESC.gsub(/^\s+/, "").tr("\n", " ")
217
222
  Run a test against all matching instances concurrently. Only N
218
223
  instances will run at the same time if a number is given.
219
- DESC
224
+ DESC
220
225
  method_option :parallel,
221
- aliases: "-p",
222
- type: :boolean,
223
- desc: <<-DESC.gsub(/^\s+/, "").tr("\n", " ")
226
+ aliases: "-p",
227
+ type: :boolean,
228
+ desc: <<-DESC.gsub(/^\s+/, "").tr("\n", " ")
224
229
  [Future DEPRECATION, use --concurrency]
225
230
  Run a test against all matching instances concurrently.
226
- DESC
231
+ DESC
227
232
  method_option :destroy,
228
- aliases: "-d",
229
- default: "passing",
230
- desc: "Destroy strategy to use after testing (passing, always, never)."
233
+ aliases: "-d",
234
+ default: "passing",
235
+ desc: "Destroy strategy to use after testing (passing, always, never)."
231
236
  method_option :auto_init,
232
- type: :boolean,
233
- default: false,
234
- desc: "Invoke init command if .kitchen.yml is missing"
237
+ type: :boolean,
238
+ default: false,
239
+ desc: "Invoke init command if .kitchen.yml is missing"
235
240
  method_option :debug,
236
- aliases: "-D",
237
- type: :boolean,
238
- default: false,
239
- desc: "Run the converge and verify with debugging enabled."
241
+ aliases: "-D",
242
+ type: :boolean,
243
+ default: false,
244
+ desc: "Run the converge and verify with debugging enabled."
240
245
  test_base_path
241
246
  log_options
242
247
  def test(*args)
@@ -262,18 +267,18 @@ module Kitchen
262
267
  desc "doctor INSTANCE|REGEXP", "Check for common system problems"
263
268
  log_options
264
269
  method_option :all,
265
- aliases: "-a",
266
- desc: "Check all instances"
270
+ aliases: "-a",
271
+ desc: "Check all instances"
267
272
  def doctor(*args)
268
273
  update_config!
269
274
  perform("doctor", "doctor", args)
270
275
  end
271
276
 
272
277
  desc "exec INSTANCE|REGEXP -c REMOTE_COMMAND",
273
- "Execute command on one or more instance"
278
+ "Execute command on one or more instance"
274
279
  method_option :command,
275
- aliases: "-c",
276
- desc: "execute via ssh"
280
+ aliases: "-c",
281
+ desc: "execute via ssh"
277
282
  log_options
278
283
  def exec(*args)
279
284
  update_config!
@@ -297,7 +302,7 @@ module Kitchen
297
302
  end
298
303
 
299
304
  register Kitchen::Generator::Init, "init",
300
- "init", "Adds some configuration to your cookbook so Kitchen can rock"
305
+ "init", "Adds some configuration to your cookbook so Kitchen can rock"
301
306
  long_desc <<-D, for: "init"
302
307
  Init will add Test Kitchen support to an existing project for
303
308
  convergence integration testing. A default kitchen.yml file (which is
@@ -45,6 +45,7 @@ module Kitchen
45
45
  def self.escape(name)
46
46
  return "" if name.nil?
47
47
  return "" unless ANSI[name]
48
+
48
49
  "\e[#{ANSI[name]}m"
49
50
  end
50
51
 
@@ -170,6 +170,7 @@ module Kitchen
170
170
  end
171
171
  end
172
172
  end
173
+ Thread.abort_on_exception = true if options[:fail_fast]
173
174
  threads.map(&:join)
174
175
  report_errors
175
176
  end
@@ -121,14 +121,16 @@ module Kitchen
121
121
  # in convergence integration
122
122
  def platforms
123
123
  @platforms ||= Collection.new(
124
- data.platform_data.map { |pdata| Platform.new(pdata) })
124
+ data.platform_data.map { |pdata| Platform.new(pdata) }
125
+ )
125
126
  end
126
127
 
127
128
  # @return [Collection<Suite>] all defined suites which will be used in
128
129
  # convergence integration
129
130
  def suites
130
131
  @suites ||= Collection.new(
131
- data.suite_data.map { |sdata| Suite.new(sdata) })
132
+ data.suite_data.map { |sdata| Suite.new(sdata) }
133
+ )
132
134
  end
133
135
 
134
136
  private
@@ -236,7 +236,7 @@ module Kitchen
236
236
  # Remove items from hash when not provided in the loaded config or when the rendered message is nil
237
237
  @deprecated_config = deprecated_attributes.delete_if { |attr, obj| !provided_config.key?(attr) || obj.nil? }
238
238
 
239
- if !deprecated_config.empty?
239
+ unless deprecated_config.empty?
240
240
  warning = Util.outdent!(<<-MSG)
241
241
  Deprecated configuration detected:
242
242
  #{deprecated_config.keys.join("\n")}
@@ -341,6 +341,7 @@ module Kitchen
341
341
  # @api private
342
342
  def wrap_shell_code(code)
343
343
  return env_wrapped(code) if powershell_shell?
344
+
344
345
  Util.wrap_command((env_wrapped code))
345
346
  end
346
347
 
@@ -353,7 +354,7 @@ module Kitchen
353
354
  end
354
355
 
355
356
  def proxy_setting_keys
356
- [:http_proxy, :https_proxy, :ftp_proxy, :no_proxy]
357
+ %i{http_proxy https_proxy ftp_proxy no_proxy}
357
358
  end
358
359
 
359
360
  def resolve_proxy_settings_from_config
@@ -156,8 +156,8 @@ module Kitchen
156
156
  def combine_arrays!(root, key, *namespaces)
157
157
  if root.key?(key)
158
158
  root[key] = namespaces
159
- .map { |namespace| root.fetch(key).fetch(namespace, []) }.flatten
160
- .compact
159
+ .map { |namespace| root.fetch(key).fetch(namespace, []) }.flatten
160
+ .compact
161
161
  end
162
162
  end
163
163
 
@@ -299,7 +299,7 @@ module Kitchen
299
299
  data data_bags encrypted_data_bag_secret_key
300
300
  environments nodes roles
301
301
  }.each do |key|
302
- move_chef_data_to_provisioner_at!(suite, "#{key}_path".to_sym)
302
+ move_data_to!(:provisioner, suite, "#{key}_path".to_sym)
303
303
  end
304
304
  end
305
305
  end
@@ -507,7 +507,7 @@ module Kitchen
507
507
  def convert_legacy_driver_http_proxy_format_at!(root)
508
508
  ddata = root.fetch(:driver, {})
509
509
 
510
- [:http_proxy, :https_proxy].each do |key|
510
+ %i{http_proxy https_proxy}.each do |key|
511
511
  next unless ddata.is_a?(Hash) && ddata.key?(key)
512
512
 
513
513
  pdata = root.fetch(:provisioner, {})
@@ -718,15 +718,15 @@ module Kitchen
718
718
  # @api private
719
719
  def move_chef_data_to_provisioner!
720
720
  data.fetch(:suites, []).each do |suite|
721
- move_chef_data_to_provisioner_at!(suite, :attributes)
722
- move_chef_data_to_provisioner_at!(suite, :run_list)
723
- move_chef_data_to_provisioner_at!(suite, :named_run_list)
721
+ move_data_to!(:provisioner, suite, :attributes)
722
+ move_data_to!(:provisioner, suite, :run_list)
723
+ move_data_to!(:provisioner, suite, :named_run_list)
724
724
  end
725
725
 
726
726
  data.fetch(:platforms, []).each do |platform|
727
- move_chef_data_to_provisioner_at!(platform, :attributes)
728
- move_chef_data_to_provisioner_at!(platform, :run_list)
729
- move_chef_data_to_provisioner_at!(platform, :named_run_list)
727
+ move_data_to!(:provisioner, platform, :attributes)
728
+ move_data_to!(:provisioner, platform, :run_list)
729
+ move_data_to!(:provisioner, platform, :named_run_list)
730
730
  end
731
731
  end
732
732
 
@@ -738,12 +738,12 @@ module Kitchen
738
738
  # @param key [Symbol] a key in the root hash to move into a `:provisioner`
739
739
  # sub-hash block
740
740
  # @api private
741
- def move_chef_data_to_provisioner_at!(root, key)
741
+ def move_data_to!(to, root, key)
742
742
  if root.key?(key)
743
- pdata = root.fetch(:provisioner, {})
743
+ pdata = root.fetch(to, {})
744
744
  pdata = { name: pdata } if pdata.is_a?(String)
745
745
  unless root.fetch(key, nil).nil?
746
- root[:provisioner] = pdata.rmerge(key => root.delete(key))
746
+ root[to] = pdata.rmerge(key => root.delete(key))
747
747
  end
748
748
  end
749
749
  end
@@ -984,7 +984,7 @@ module Kitchen
984
984
  # Hash if not found
985
985
  # @api private
986
986
  def platform_data_for(name)
987
- data.fetch(:platforms, {}).find(-> { Hash.new }) do |platform|
987
+ data.fetch(:platforms, {}).find(-> { {} }) do |platform|
988
988
  platform.fetch(:name, nil) == name
989
989
  end
990
990
  end
@@ -1015,7 +1015,7 @@ module Kitchen
1015
1015
  # Hash if not found
1016
1016
  # @api private
1017
1017
  def suite_data_for(name)
1018
- data.fetch(:suites, {}).find(-> { Hash.new }) do |suite|
1018
+ data.fetch(:suites, {}).find(-> { {} }) do |suite|
1019
1019
  suite.fetch(:name, nil) == name
1020
1020
  end
1021
1021
  end
@@ -54,15 +54,13 @@ module Kitchen
54
54
  #
55
55
  # @param state [Hash] mutable instance and driver state
56
56
  # @raise [ActionFailed] if the action could not be completed
57
- def destroy(state) # rubocop:disable Lint/UnusedMethodArgument
58
- end
57
+ def destroy(state); end
59
58
 
60
59
  # Package an instance.
61
60
  #
62
61
  # @param state [Hash] mutable instance and driver state
63
62
  # @raise [ActionFailed] if the action could not be completed
64
- def package(state) # rubocop:disable Lint/UnusedMethodArgument
65
- end
63
+ def package(state); end
66
64
 
67
65
  # Check system and configuration for common errors.
68
66
  #
@@ -97,7 +95,7 @@ module Kitchen
97
95
  # @param methods [Array<Symbol>] one or more actions as symbols
98
96
  # @raise [ClientError] if any method is not a valid action method name
99
97
  def self.no_parallel_for(*methods)
100
- action_methods = [:create, :setup, :converge, :verify, :destroy]
98
+ action_methods = %i{create setup converge verify destroy}
101
99
 
102
100
  Array(methods).each do |meth|
103
101
  next if action_methods.include?(meth)
@@ -136,8 +134,7 @@ module Kitchen
136
134
  # that it can leverage it internally
137
135
  #
138
136
  # @return path [String] a path of the cache directory
139
- def cache_directory
140
- end
137
+ def cache_directory; end
141
138
 
142
139
  private
143
140
 
@@ -48,6 +48,7 @@ module Kitchen
48
48
  # (see Base#destroy)
49
49
  def destroy(state)
50
50
  return if state[:hostname].nil?
51
+
51
52
  reset_instance(state)
52
53
  state.delete(:hostname)
53
54
  end