test-kitchen 2.6.0 → 2.7.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: fbc194fbd762658d4d989813aa6eb5aff36dda3859ee7d65eaf080fe033b1fad
4
- data.tar.gz: f4afc61cf21085c167952eadae6867ffc242c616d283dbfdff8c7e87085d5dfb
3
+ metadata.gz: f6ccfe0fbf72b2850671e2e1782c9b8477dd2134a3582d8087dd61c77a7414c7
4
+ data.tar.gz: 74b6c95a6bc563f846ae54f6c1f62661b4cb1128aa278535e8234e95c2be3ce1
5
5
  SHA512:
6
- metadata.gz: 7278defbe363816e09a07eaa757bc7108d7e87bbbf93dc8f30e1d93d4eda5aebe2b5a826d817a8be20cd123ffaa917f890458568245860d8f0e7ae233428c38b
7
- data.tar.gz: 509577b9063d96342cfd1491aeae633930ca88dbf18be3b2bee23145850ee8eba1fd8e8581fd11ce583216797eaf9d9f9dff78e8e38997c2f614ba3159a12e10
6
+ metadata.gz: 7a01947ea6e91991646128a65733f0b9b9a7c1d50cb76cb2b373288dbc2b2b3e631d3a217cbbbcec09b21331ef21545dfb89af3ec595ea69ca3b82e367febccc
7
+ data.tar.gz: 2735785eb1b12548353a38da11ff74484daa403fd4672d196d30915807f937b7dab0760cccf502d32ceb4620cabf5274f7f12a07efe85d179c0a3ce8d1e165f6
data/Rakefile CHANGED
@@ -42,7 +42,7 @@ desc "Run all quality tasks"
42
42
  task quality: %i{style stats}
43
43
 
44
44
  begin
45
- require "yard"
45
+ require "yard" unless defined?(YARD)
46
46
  YARD::Rake::YardocTask.new
47
47
  rescue LoadError
48
48
  puts "yard is not available. (sudo) gem install yard to generate yard documentation."
@@ -4,7 +4,7 @@
4
4
  Signal.trap("INT") { exit 1 }
5
5
 
6
6
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), %w{.. lib})
7
- require "rubygems"
7
+ require "rubygems" unless defined?(Gem)
8
8
  require "kitchen/cli"
9
9
  require "kitchen/errors"
10
10
 
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "pathname"
18
+ require "pathname" unless defined?(Pathname)
19
19
  require "thread"
20
20
 
21
21
  require_relative "kitchen/errors"
@@ -15,7 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "thor"
18
+ # CI tests fail without an explicit unconditional require of Thor
19
+ require "thor" # rubocop:disable ChefRuby/UnlessDefinedRequire
19
20
 
20
21
  require_relative "../kitchen"
21
22
  require_relative "generator/init"
@@ -17,7 +17,7 @@
17
17
 
18
18
  require_relative "../command"
19
19
 
20
- require "benchmark"
20
+ require "benchmark" unless defined?(Benchmark)
21
21
 
22
22
  module Kitchen
23
23
  module Command
@@ -18,7 +18,7 @@
18
18
  require_relative "../command"
19
19
  require_relative "../diagnostic"
20
20
 
21
- require "yaml"
21
+ require "yaml" unless defined?(YAML)
22
22
 
23
23
  module Kitchen
24
24
  module Command
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require_relative "../command"
19
- require "json"
19
+ require "json" unless defined?(JSON)
20
20
 
21
21
  module Kitchen
22
22
  module Command
@@ -17,7 +17,7 @@
17
17
 
18
18
  require_relative "../command"
19
19
 
20
- require "benchmark"
20
+ require "benchmark" unless defined?(Benchmark)
21
21
 
22
22
  module Kitchen
23
23
  module Command
@@ -19,6 +19,7 @@ require_relative "../configurable"
19
19
  require_relative "../errors"
20
20
  require_relative "../lazy_hash"
21
21
  require_relative "../logging"
22
+ require_relative "../plugin_base"
22
23
  require_relative "../shell_out"
23
24
 
24
25
  module Kitchen
@@ -26,7 +27,7 @@ module Kitchen
26
27
  # Base class for a driver.
27
28
  #
28
29
  # @author Fletcher Nichol <fnichol@nichol.ca>
29
- class Base
30
+ class Base < Kitchen::Plugin::Base
30
31
  include Configurable
31
32
  include Logging
32
33
  include ShellOut
@@ -69,43 +70,6 @@ module Kitchen
69
70
  false
70
71
  end
71
72
 
72
- class << self
73
- # @return [Array<Symbol>] an array of action method names that cannot
74
- # be run concurrently and must be run in serial via a shared mutex
75
- attr_reader :serial_actions
76
- end
77
-
78
- # Registers certain driver actions that cannot be safely run concurrently
79
- # in threads across multiple instances. Typically this might be used
80
- # for create or destroy actions that use an underlying resource that
81
- # cannot be used at the same time.
82
- #
83
- # A shared mutex for this driver object will be used to synchronize all
84
- # registered methods.
85
- #
86
- # @example a single action method that cannot be run concurrently
87
- #
88
- # no_parallel_for :create
89
- #
90
- # @example multiple action methods that cannot be run concurrently
91
- #
92
- # no_parallel_for :create, :destroy
93
- #
94
- # @param methods [Array<Symbol>] one or more actions as symbols
95
- # @raise [ClientError] if any method is not a valid action method name
96
- def self.no_parallel_for(*methods)
97
- action_methods = %i{create setup converge verify destroy}
98
-
99
- Array(methods).each do |meth|
100
- next if action_methods.include?(meth)
101
-
102
- raise ClientError, "##{meth} is not a valid no_parallel_for method"
103
- end
104
-
105
- @serial_actions ||= []
106
- @serial_actions += methods
107
- end
108
-
109
73
  # Sets the API version for this driver. If the driver does not set this
110
74
  # value, then `nil` will be used and reported.
111
75
  #
@@ -18,7 +18,8 @@
18
18
  require "thor/util"
19
19
 
20
20
  require_relative "../lazy_hash"
21
- require "benchmark"
21
+ require_relative "../plugin_base"
22
+ require "benchmark" unless defined?(Benchmark)
22
23
 
23
24
  module Kitchen
24
25
  module Driver
@@ -42,7 +43,7 @@ module Kitchen
42
43
  # Transport, and Verifier subsystems may not be picked up in these
43
44
  # Drivers. When legacy Driver::SSHBase support is removed, this class
44
45
  # will no longer be available.
45
- class SSHBase
46
+ class SSHBase < Kitchen::Plugin::Base
46
47
  include ShellOut
47
48
  include Configurable
48
49
  include Logging
@@ -179,43 +180,6 @@ module Kitchen
179
180
  # documented dependency is missing from the system
180
181
  def verify_dependencies; end
181
182
 
182
- class << self
183
- # @return [Array<Symbol>] an array of action method names that cannot
184
- # be run concurrently and must be run in serial via a shared mutex
185
- attr_reader :serial_actions
186
- end
187
-
188
- # Registers certain driver actions that cannot be safely run concurrently
189
- # in threads across multiple instances. Typically this might be used
190
- # for create or destroy actions that use an underlying resource that
191
- # cannot be used at the same time.
192
- #
193
- # A shared mutex for this driver object will be used to synchronize all
194
- # registered methods.
195
- #
196
- # @example a single action method that cannot be run concurrently
197
- #
198
- # no_parallel_for :create
199
- #
200
- # @example multiple action methods that cannot be run concurrently
201
- #
202
- # no_parallel_for :create, :destroy
203
- #
204
- # @param methods [Array<Symbol>] one or more actions as symbols
205
- # @raise [ClientError] if any method is not a valid action method name
206
- def self.no_parallel_for(*methods)
207
- action_methods = %i{create converge setup verify destroy}
208
-
209
- Array(methods).each do |meth|
210
- next if action_methods.include?(meth)
211
-
212
- raise ClientError, "##{meth} is not a valid no_parallel_for method"
213
- end
214
-
215
- @serial_actions ||= []
216
- @serial_actions += methods
217
- end
218
-
219
183
  # Cache directory that a driver could implement to inform the provisioner
220
184
  # that it can leverage it internally
221
185
  #
@@ -15,8 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "benchmark"
19
- require "fileutils"
18
+ require "benchmark" unless defined?(Benchmark)
19
+ require "fileutils" unless defined?(FileUtils)
20
20
 
21
21
  module Kitchen
22
22
  # An instance of a suite running on a platform. A created instance may be a
@@ -28,7 +28,7 @@ module Kitchen
28
28
  include Logging
29
29
 
30
30
  class << self
31
- # @return [Hash] a hash of mutxes, arranged by Driver class names
31
+ # @return [Hash] a hash of mutexes, arranged by Plugin class names
32
32
  # @api private
33
33
  attr_accessor :mutexes
34
34
 
@@ -322,21 +322,29 @@ module Kitchen
322
322
  end
323
323
  end
324
324
 
325
- # Perform any final configuration or preparation needed for the driver
326
- # object carry out its duties.
325
+ # If a plugin has declared via .no_parallel_for that it is not
326
+ # thread-safe for certain actions, create a mutex to track it.
327
327
  #
328
+ # @param plugin_class[Class] Kitchen::Plugin::Base
328
329
  # @api private
329
- def setup_driver
330
- @driver.finalize_config!(self)
331
-
332
- if driver.class.serial_actions
330
+ def setup_plugin_mutexes(plugin_class)
331
+ if plugin_class.serial_actions
333
332
  Kitchen.mutex.synchronize do
334
333
  self.class.mutexes ||= {}
335
- self.class.mutexes[driver.class] = Mutex.new
334
+ self.class.mutexes[plugin_class] = Mutex.new
336
335
  end
337
336
  end
338
337
  end
339
338
 
339
+ # Perform any final configuration or preparation needed for the driver
340
+ # object carry out its duties.
341
+ #
342
+ # @api private
343
+ def setup_driver
344
+ @driver.finalize_config!(self)
345
+ setup_plugin_mutexes(driver.class)
346
+ end
347
+
340
348
  # Perform any final configuration or preparation needed for the lifecycle hooks
341
349
  # object carry out its duties.
342
350
  #
@@ -351,6 +359,7 @@ module Kitchen
351
359
  # @api private
352
360
  def setup_provisioner
353
361
  @provisioner.finalize_config!(self)
362
+ setup_plugin_mutexes(provisioner.class)
354
363
  end
355
364
 
356
365
  # Perform any final configuration or preparation needed for the transport
@@ -359,6 +368,7 @@ module Kitchen
359
368
  # @api private
360
369
  def setup_transport
361
370
  transport.finalize_config!(self)
371
+ setup_plugin_mutexes(transport.class)
362
372
  end
363
373
 
364
374
  # Perform any final configuration or preparation needed for the verifier
@@ -367,6 +377,7 @@ module Kitchen
367
377
  # @api private
368
378
  def setup_verifier
369
379
  verifier.finalize_config!(self)
380
+ setup_plugin_mutexes(verifier.class)
370
381
  end
371
382
 
372
383
  # Perform all actions in order from last state to desired state.
@@ -541,10 +552,11 @@ module Kitchen
541
552
  # @param block [Proc] a block to be called
542
553
  # @api private
543
554
  def synchronize_or_call(what, state)
544
- if Array(driver.class.serial_actions).include?(what)
545
- debug("#{to_str} is synchronizing on #{driver.class}##{what}")
546
- self.class.mutexes[driver.class].synchronize do
547
- debug("#{to_str} is messaging #{driver.class}##{what}")
555
+ plugin_class = plugin_class_for_action(what)
556
+ if Array(plugin_class.serial_actions).include?(what)
557
+ debug("#{to_str} is synchronizing on #{plugin_class}##{what}")
558
+ self.class.mutexes[plugin_class].synchronize do
559
+ debug("#{to_str} is messaging #{plugin_class}##{what}")
548
560
  yield(state)
549
561
  end
550
562
  else
@@ -552,6 +564,21 @@ module Kitchen
552
564
  end
553
565
  end
554
566
 
567
+ # Maps the given action to the plugin class associated with the action
568
+ #
569
+ # @param what[Symbol] action
570
+ # @return [Class] Kitchen::Plugin::Base
571
+ # @api private
572
+ def plugin_class_for_action(what)
573
+ {
574
+ create: driver,
575
+ setup: transport,
576
+ converge: provisioner,
577
+ verify: verifier,
578
+ destroy: driver,
579
+ }[what].class
580
+ end
581
+
555
582
  # Writes a high level message for logging and/or output.
556
583
  #
557
584
  # In this case, all instance banner messages will be written to the common
@@ -15,9 +15,9 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "erb"
18
+ require "erb" unless defined?(Erb)
19
19
  require_relative "../../vendor/hash_recursive_merge"
20
- require "yaml"
20
+ require "yaml" unless defined?(YAML)
21
21
 
22
22
  module Kitchen
23
23
  module Loader
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "fileutils"
18
+ require "fileutils" unless defined?(FileUtils)
19
19
  require "logger"
20
20
 
21
21
  module Kitchen
@@ -0,0 +1,60 @@
1
+ #
2
+ # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
3
+ #
4
+ # Copyright (C) 2014, Fletcher Nichol
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ module Kitchen
19
+ module Plugin
20
+ class Base
21
+ class << self
22
+ # @return [Array<Symbol>] an array of action method names that cannot
23
+ # be run concurrently and must be run in serial via a shared mutex
24
+ attr_reader :serial_actions
25
+ end
26
+
27
+ # Registers certain driver actions that cannot be safely run concurrently
28
+ # in threads across multiple instances. Typically this might be used
29
+ # for create or destroy actions that use an underlying resource that
30
+ # cannot be used at the same time.
31
+ #
32
+ # A shared mutex for this driver object will be used to synchronize all
33
+ # registered methods.
34
+ #
35
+ # @example a single action method that cannot be run concurrently
36
+ #
37
+ # no_parallel_for :create
38
+ #
39
+ # @example multiple action methods that cannot be run concurrently
40
+ #
41
+ # no_parallel_for :create, :destroy
42
+ #
43
+ # @param methods [Array<Symbol>] one or more actions as symbols
44
+ # @raise [ClientError] if any method is not a valid action method name
45
+ def self.no_parallel_for(*methods)
46
+ action_methods = %i{create setup converge verify destroy}
47
+
48
+ Array(methods).each do |meth|
49
+ next if action_methods.include?(meth)
50
+
51
+ raise ClientError, "##{meth} is not a valid no_parallel_for method"
52
+ end
53
+
54
+ @serial_actions ||= []
55
+ @serial_actions += methods
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -18,13 +18,14 @@
18
18
  require_relative "../configurable"
19
19
  require_relative "../errors"
20
20
  require_relative "../logging"
21
+ require_relative "../plugin_base"
21
22
 
22
23
  module Kitchen
23
24
  module Provisioner
24
25
  # Base class for a provisioner.
25
26
  #
26
27
  # @author Fletcher Nichol <fnichol@nichol.ca>
27
- class Base
28
+ class Base < Kitchen::Plugin::Base
28
29
  include Configurable
29
30
  include Logging
30
31
 
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "json"
18
+ require "json" unless defined?(JSON)
19
19
 
20
20
  module Kitchen
21
21
  module Provisioner
@@ -15,8 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "shellwords"
19
- require "rbconfig"
18
+ require "shellwords" unless defined?(Shellwords)
19
+ require "rbconfig" unless defined?(RbConfig)
20
20
 
21
21
  require_relative "../../errors"
22
22
  require_relative "../../logging"
@@ -15,10 +15,10 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "fileutils"
19
- require "pathname"
20
- require "json"
21
- require "cgi"
18
+ require "fileutils" unless defined?(FileUtils)
19
+ require "pathname" unless defined?(Pathname)
20
+ require "json" unless defined?(JSON)
21
+ require "cgi" unless defined?(CGI)
22
22
 
23
23
  require_relative "chef/policyfile"
24
24
  require_relative "chef/berkshelf"
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "shellwords"
18
+ require "shellwords" unless defined?(Shellwords)
19
19
 
20
20
  require_relative "base"
21
21
  require_relative "../version"
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "mixlib/shellout"
18
+ require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
19
19
 
20
20
  module Kitchen
21
21
  # Mixin that wraps a command shell out invocation, providing a #run_command
@@ -16,9 +16,9 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require "logger"
19
- require "net/ssh"
19
+ require "net/ssh" unless defined?(Net::SSH)
20
20
  require "net/scp"
21
- require "socket"
21
+ require "socket" unless defined?(Socket)
22
22
 
23
23
  require_relative "errors"
24
24
  require_relative "login_command"
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "yaml"
18
+ require "yaml" unless defined?(YAML)
19
19
 
20
20
  module Kitchen
21
21
  # Exception class for any exceptions raised when reading and parsing a state
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "thor"
18
+ require "thor" unless defined?(Thor)
19
19
 
20
20
  require_relative "../kitchen"
21
21
 
@@ -21,6 +21,7 @@ require_relative "../errors"
21
21
  require_relative "../lazy_hash"
22
22
  require_relative "../logging"
23
23
  require_relative "../login_command"
24
+ require_relative "../plugin_base"
24
25
 
25
26
  module Kitchen
26
27
  module Transport
@@ -40,7 +41,7 @@ module Kitchen
40
41
  #
41
42
  # @author Salim Afiune <salim@afiunemaya.com.mx>
42
43
  # @author Fletcher Nichol <fnichol@nichol.ca>
43
- class Base
44
+ class Base < Kitchen::Plugin::Base
44
45
  include Configurable
45
46
  include Logging
46
47
 
@@ -11,7 +11,7 @@
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
13
 
14
- require "fileutils"
14
+ require "fileutils" unless defined?(FileUtils)
15
15
 
16
16
  require_relative "../shell_out"
17
17
  require_relative "base"
@@ -17,13 +17,13 @@
17
17
 
18
18
  require_relative "../../kitchen"
19
19
 
20
- require "fileutils"
21
- require "net/ssh"
20
+ require "fileutils" unless defined?(FileUtils)
21
+ require "net/ssh" unless defined?(Net::SSH)
22
22
  require "net/ssh/gateway"
23
23
  require "net/ssh/proxy/http"
24
24
  require "net/scp"
25
- require "timeout"
26
- require "benchmark"
25
+ require "timeout" unless defined?(Timeout)
26
+ require "benchmark" unless defined?(Benchmark)
27
27
 
28
28
  module Kitchen
29
29
  module Transport
@@ -17,10 +17,10 @@
17
17
  # See the License for the specific language governing permissions and
18
18
  # limitations under the License.
19
19
 
20
- require "rbconfig"
21
- require "uri"
20
+ require "rbconfig" unless defined?(RbConfig)
21
+ require "uri" unless defined?(URI)
22
22
  require_relative "../../kitchen"
23
- require "winrm"
23
+ require "winrm" unless defined?(WinRM::Connection)
24
24
 
25
25
  module Kitchen
26
26
  module Transport
@@ -18,13 +18,14 @@
18
18
  require_relative "../errors"
19
19
  require_relative "../configurable"
20
20
  require_relative "../logging"
21
+ require_relative "../plugin_base"
21
22
 
22
23
  module Kitchen
23
24
  module Verifier
24
25
  # Base class for a verifier.
25
26
  #
26
27
  # @author Fletcher Nichol <fnichol@nichol.ca>
27
- class Base
28
+ class Base < Kitchen::Plugin::Base
28
29
  include Configurable
29
30
  include Logging
30
31
 
@@ -15,8 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "base64"
19
- require "digest"
18
+ require "base64" unless defined?(Base64)
19
+ require "digest" unless defined?(Digest)
20
20
 
21
21
  require_relative "base"
22
22
 
@@ -23,7 +23,7 @@ module Kitchen
23
23
  #
24
24
  # @author SAWANOBORI Yukihiko (<sawanoboriyu@higanworks.com>)
25
25
  class Shell < Kitchen::Verifier::Base
26
- require "mixlib/shellout"
26
+ require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
27
27
 
28
28
  kitchen_verifier_api_version 1
29
29
 
@@ -16,5 +16,5 @@
16
16
  # limitations under the License.
17
17
 
18
18
  module Kitchen
19
- VERSION = "2.6.0".freeze
19
+ VERSION = "2.7.0".freeze
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-13 00:00:00.000000000 Z
11
+ date: 2020-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -423,6 +423,7 @@ files:
423
423
  - lib/kitchen/metadata_chopper.rb
424
424
  - lib/kitchen/platform.rb
425
425
  - lib/kitchen/plugin.rb
426
+ - lib/kitchen/plugin_base.rb
426
427
  - lib/kitchen/provisioner.rb
427
428
  - lib/kitchen/provisioner/base.rb
428
429
  - lib/kitchen/provisioner/chef/berkshelf.rb