test-kitchen 2.5.3 → 2.7.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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -3
  3. data/bin/kitchen +1 -3
  4. data/lib/kitchen.rb +2 -5
  5. data/lib/kitchen/base64_stream.rb +0 -1
  6. data/lib/kitchen/cli.rb +2 -2
  7. data/lib/kitchen/collection.rb +0 -1
  8. data/lib/kitchen/color.rb +0 -1
  9. data/lib/kitchen/command.rb +0 -3
  10. data/lib/kitchen/command/action.rb +1 -2
  11. data/lib/kitchen/command/console.rb +0 -1
  12. data/lib/kitchen/command/diagnose.rb +3 -4
  13. data/lib/kitchen/command/doctor.rb +0 -1
  14. data/lib/kitchen/command/exec.rb +0 -1
  15. data/lib/kitchen/command/list.rb +1 -2
  16. data/lib/kitchen/command/login.rb +0 -1
  17. data/lib/kitchen/command/package.rb +0 -1
  18. data/lib/kitchen/command/sink.rb +0 -1
  19. data/lib/kitchen/command/test.rb +1 -2
  20. data/lib/kitchen/config.rb +1 -2
  21. data/lib/kitchen/configurable.rb +0 -1
  22. data/lib/kitchen/data_munger.rb +0 -1
  23. data/lib/kitchen/diagnostic.rb +0 -1
  24. data/lib/kitchen/driver.rb +0 -1
  25. data/lib/kitchen/driver/base.rb +2 -39
  26. data/lib/kitchen/driver/dummy.rb +0 -1
  27. data/lib/kitchen/driver/exec.rb +0 -1
  28. data/lib/kitchen/driver/proxy.rb +0 -1
  29. data/lib/kitchen/driver/ssh_base.rb +3 -40
  30. data/lib/kitchen/errors.rb +0 -1
  31. data/lib/kitchen/generator/init.rb +0 -1
  32. data/lib/kitchen/instance.rb +41 -15
  33. data/lib/kitchen/lazy_hash.rb +0 -1
  34. data/lib/kitchen/lifecycle_hooks.rb +0 -1
  35. data/lib/kitchen/loader/yaml.rb +2 -3
  36. data/lib/kitchen/logger.rb +1 -2
  37. data/lib/kitchen/logging.rb +0 -1
  38. data/lib/kitchen/login_command.rb +0 -1
  39. data/lib/kitchen/metadata_chopper.rb +0 -1
  40. data/lib/kitchen/platform.rb +0 -1
  41. data/lib/kitchen/plugin.rb +0 -1
  42. data/lib/kitchen/plugin_base.rb +60 -0
  43. data/lib/kitchen/provisioner.rb +0 -1
  44. data/lib/kitchen/provisioner/base.rb +2 -2
  45. data/lib/kitchen/provisioner/chef/berkshelf.rb +0 -1
  46. data/lib/kitchen/provisioner/chef/common_sandbox.rb +1 -2
  47. data/lib/kitchen/provisioner/chef/policyfile.rb +5 -6
  48. data/lib/kitchen/provisioner/chef_apply.rb +0 -1
  49. data/lib/kitchen/provisioner/chef_base.rb +16 -11
  50. data/lib/kitchen/provisioner/chef_solo.rb +4 -1
  51. data/lib/kitchen/provisioner/chef_zero.rb +0 -1
  52. data/lib/kitchen/provisioner/dummy.rb +0 -1
  53. data/lib/kitchen/provisioner/shell.rb +1 -2
  54. data/lib/kitchen/rake_tasks.rb +0 -1
  55. data/lib/kitchen/shell_out.rb +1 -2
  56. data/lib/kitchen/ssh.rb +6 -4
  57. data/lib/kitchen/state_file.rb +1 -2
  58. data/lib/kitchen/suite.rb +0 -1
  59. data/lib/kitchen/thor_tasks.rb +1 -2
  60. data/lib/kitchen/transport.rb +0 -1
  61. data/lib/kitchen/transport/base.rb +2 -2
  62. data/lib/kitchen/transport/dummy.rb +0 -1
  63. data/lib/kitchen/transport/exec.rb +1 -2
  64. data/lib/kitchen/transport/ssh.rb +4 -5
  65. data/lib/kitchen/transport/winrm.rb +3 -4
  66. data/lib/kitchen/util.rb +1 -2
  67. data/lib/kitchen/verifier.rb +0 -1
  68. data/lib/kitchen/verifier/base.rb +2 -2
  69. data/lib/kitchen/verifier/busser.rb +3 -4
  70. data/lib/kitchen/verifier/dummy.rb +0 -1
  71. data/lib/kitchen/verifier/shell.rb +1 -2
  72. data/lib/kitchen/version.rb +1 -2
  73. data/lib/vendor/hash_recursive_merge.rb +0 -1
  74. data/test-kitchen.gemspec +4 -5
  75. metadata +13 -12
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Noah Kantrowitz <noah@coderanger.net>
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,9 +15,9 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "erb"
18
+ require "erb" unless defined?(Erb)
20
19
  require_relative "../../vendor/hash_recursive_merge"
21
- require "yaml"
20
+ require "yaml" unless defined?(YAML)
22
21
 
23
22
  module Kitchen
24
23
  module Loader
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,7 +15,7 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "fileutils"
18
+ require "fileutils" unless defined?(FileUtils)
20
19
  require "logger"
21
20
 
22
21
  module Kitchen
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -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
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -19,13 +18,14 @@
19
18
  require_relative "../configurable"
20
19
  require_relative "../errors"
21
20
  require_relative "../logging"
21
+ require_relative "../plugin_base"
22
22
 
23
23
  module Kitchen
24
24
  module Provisioner
25
25
  # Base class for a provisioner.
26
26
  #
27
27
  # @author Fletcher Nichol <fnichol@nichol.ca>
28
- class Base
28
+ class Base < Kitchen::Plugin::Base
29
29
  include Configurable
30
30
  include Logging
31
31
 
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,7 +15,7 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "json"
18
+ require "json" unless defined?(JSON)
20
19
 
21
20
  module Kitchen
22
21
  module Provisioner
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,8 +15,8 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "shellwords"
20
- require "rbconfig"
18
+ require "shellwords" unless defined?(Shellwords)
19
+ require "rbconfig" unless defined?(RbConfig)
21
20
 
22
21
  require_relative "../../errors"
23
22
  require_relative "../../logging"
@@ -111,13 +110,13 @@ module Kitchen
111
110
  # @return [String]
112
111
  # @api private
113
112
  def escape_path(path)
114
- if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
113
+ if /mswin|mingw/.match?(RbConfig::CONFIG["host_os"])
115
114
  # I know what you're thinking: "just use Shellwords.escape". That
116
115
  # method produces incorrect results on Windows with certain input
117
116
  # which would be a metacharacter in Sh but is not for one or more of
118
117
  # Windows command line parsing libraries. This covers the 99% case of
119
118
  # spaces in the path without breaking other stuff.
120
- if path =~ /[ \t\n\v"]/
119
+ if /[ \t\n\v"]/.match?(path)
121
120
  "\"#{path.gsub(/[ \t\n\v\"\\]/) { |m| '\\' + m[0] }}\""
122
121
  else
123
122
  path
@@ -137,7 +136,7 @@ module Kitchen
137
136
  # @api private
138
137
  def detect_chef_command!(logger)
139
138
  unless ENV["PATH"].split(File::PATH_SEPARATOR).any? do |path|
140
- if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
139
+ if /mswin|mingw/.match?(RbConfig::CONFIG["host_os"])
141
140
  # Windows could have different extentions: BAT, EXE or NONE
142
141
  %w{chef chef.exe chef.bat}.each do |bin|
143
142
  File.exist?(File.join(path, bin))
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: SAWANOBORI Yukihiko <sawanoboriyu@higanworks.com>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,18 +15,18 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "fileutils"
20
- require "pathname"
21
- require "json"
22
- 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)
23
22
 
24
23
  require_relative "chef/policyfile"
25
24
  require_relative "chef/berkshelf"
26
25
  require_relative "chef/common_sandbox"
27
26
  require_relative "../util"
28
- require "mixlib/install"
29
- require "mixlib/install/script_generator"
30
- require "license_acceptance/acceptor"
27
+ module LicenseAcceptance
28
+ autoload :Acceptor, "license_acceptance/acceptor"
29
+ end
31
30
 
32
31
  begin
33
32
  require "chef-config/config"
@@ -157,7 +156,7 @@ module Kitchen
157
156
  product_name: <chef or chef-workstation>
158
157
  install_strategy: skip
159
158
  MSG
160
- when provisioner[:require_chef_omnibus].to_s.match(/\d/)
159
+ when provisioner[:require_chef_omnibus].to_s.match?(/\d/)
161
160
  Util.outdent!(<<-MSG)
162
161
  The 'require_chef_omnibus' attribute with version values will change
163
162
  to use the new 'product_version' attribute.
@@ -504,14 +503,13 @@ module Kitchen
504
503
  # @return [String] contents of product based install script
505
504
  # @api private
506
505
  def script_for_product
506
+ require "mixlib/install"
507
507
  installer = Mixlib::Install.new({
508
508
  product_name: config[:product_name],
509
509
  product_version: config[:product_version],
510
510
  channel: config[:channel].to_sym,
511
511
  install_command_options: {
512
512
  install_strategy: config[:install_strategy],
513
- tmp_dir: config[:root_path],
514
- "TMPDIR" => config[:root_path],
515
513
  },
516
514
  }.tap do |opts|
517
515
  opts[:shell_type] = :ps1 if powershell_shell?
@@ -519,6 +517,12 @@ module Kitchen
519
517
  opts[key] = config[key] if config[key]
520
518
  end
521
519
 
520
+ unless windows_os?
521
+ # omnitruck installer does not currently support a tmp dir option on windows
522
+ opts[:install_command_options][:tmp_dir] = config[:root_path]
523
+ opts[:install_command_options]["TMPDIR"] = config[:root_path]
524
+ end
525
+
522
526
  if config[:download_url]
523
527
  opts[:install_command_options][:download_url_override] = config[:download_url]
524
528
  opts[:install_command_options][:checksum] = config[:checksum] if config[:checksum]
@@ -573,6 +577,7 @@ module Kitchen
573
577
  # @return [String] contents of version based install script
574
578
  # @api private
575
579
  def script_for_omnibus_version
580
+ require "mixlib/install/script_generator"
576
581
  installer = Mixlib::Install::ScriptGenerator.new(
577
582
  config[:require_chef_omnibus], powershell_shell?, install_options
578
583
  )
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -28,6 +27,10 @@ module Kitchen
28
27
 
29
28
  plugin_version Kitchen::VERSION
30
29
 
30
+ # ChefSolo is dependent on Berkshelf, which is not thread-safe.
31
+ # See discussion on https://github.com/test-kitchen/test-kitchen/issues/1307
32
+ no_parallel_for :converge
33
+
31
34
  default_config :solo_rb, {}
32
35
 
33
36
  default_config :chef_solo_path do |provisioner|
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Chris Lundquist (<chris.lundquist@github.com>)
4
3
  #
@@ -16,7 +15,7 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "shellwords"
18
+ require "shellwords" unless defined?(Shellwords)
20
19
 
21
20
  require_relative "base"
22
21
  require_relative "../version"
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,7 +15,7 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "mixlib/shellout"
18
+ require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
20
19
 
21
20
  module Kitchen
22
21
  # Mixin that wraps a command shell out invocation, providing a #run_command
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -17,9 +16,10 @@
17
16
  # limitations under the License.
18
17
 
19
18
  require "logger"
20
- require "net/ssh"
21
- require "net/scp"
22
- require "socket"
19
+ module Net
20
+ autoload :SSH, "net/ssh"
21
+ end
22
+ require "socket" unless defined?(Socket)
23
23
 
24
24
  require_relative "errors"
25
25
  require_relative "login_command"
@@ -91,6 +91,7 @@ module Kitchen
91
91
  # `Net::SCP.upload`
92
92
  # @see http://net-ssh.github.io/net-scp/classes/Net/SCP.html#method-i-upload
93
93
  def upload!(local, remote, options = {}, &progress)
94
+ require "net/scp" unless defined?(Net::SCP)
94
95
  if progress.nil?
95
96
  progress = lambda do |_ch, name, sent, total|
96
97
  logger.debug("Uploaded #{name} (#{total} bytes)") if sent == total
@@ -101,6 +102,7 @@ module Kitchen
101
102
  end
102
103
 
103
104
  def upload(local, remote, options = {}, &progress)
105
+ require "net/scp" unless defined?(Net::SCP)
104
106
  if progress.nil?
105
107
  progress = lambda do |_ch, name, sent, total|
106
108
  if sent == total
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,7 +15,7 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "yaml"
18
+ autoload :YAML, "yaml"
20
19
 
21
20
  module Kitchen
22
21
  # Exception class for any exceptions raised when reading and parsing a state
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,7 +15,7 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "thor"
18
+ require "thor" unless defined?(Thor)
20
19
 
21
20
  require_relative "../kitchen"
22
21
 
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Salim Afiune (<salim@afiunemaya.com.mx>)
4
3
  #
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Salim Afiune (<salim@afiunemaya.com.mx>)
4
3
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
@@ -22,6 +21,7 @@ require_relative "../errors"
22
21
  require_relative "../lazy_hash"
23
22
  require_relative "../logging"
24
23
  require_relative "../login_command"
24
+ require_relative "../plugin_base"
25
25
 
26
26
  module Kitchen
27
27
  module Transport
@@ -41,7 +41,7 @@ module Kitchen
41
41
  #
42
42
  # @author Salim Afiune <salim@afiunemaya.com.mx>
43
43
  # @author Fletcher Nichol <fnichol@nichol.ca>
44
- class Base
44
+ class Base < Kitchen::Plugin::Base
45
45
  include Configurable
46
46
  include Logging
47
47