test-kitchen 2.5.1 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -11
  3. data/Rakefile +1 -3
  4. data/bin/kitchen +1 -3
  5. data/lib/kitchen.rb +1 -2
  6. data/lib/kitchen/base64_stream.rb +0 -1
  7. data/lib/kitchen/cli.rb +2 -2
  8. data/lib/kitchen/collection.rb +0 -1
  9. data/lib/kitchen/color.rb +0 -1
  10. data/lib/kitchen/command.rb +0 -1
  11. data/lib/kitchen/command/action.rb +1 -2
  12. data/lib/kitchen/command/console.rb +0 -1
  13. data/lib/kitchen/command/diagnose.rb +1 -2
  14. data/lib/kitchen/command/doctor.rb +0 -1
  15. data/lib/kitchen/command/exec.rb +0 -1
  16. data/lib/kitchen/command/list.rb +1 -2
  17. data/lib/kitchen/command/login.rb +0 -1
  18. data/lib/kitchen/command/package.rb +0 -1
  19. data/lib/kitchen/command/sink.rb +0 -1
  20. data/lib/kitchen/command/test.rb +1 -2
  21. data/lib/kitchen/config.rb +0 -1
  22. data/lib/kitchen/configurable.rb +0 -1
  23. data/lib/kitchen/data_munger.rb +0 -1
  24. data/lib/kitchen/diagnostic.rb +0 -1
  25. data/lib/kitchen/driver.rb +0 -1
  26. data/lib/kitchen/driver/base.rb +2 -39
  27. data/lib/kitchen/driver/dummy.rb +0 -1
  28. data/lib/kitchen/driver/exec.rb +0 -1
  29. data/lib/kitchen/driver/proxy.rb +0 -1
  30. data/lib/kitchen/driver/ssh_base.rb +3 -40
  31. data/lib/kitchen/errors.rb +0 -1
  32. data/lib/kitchen/generator/init.rb +0 -1
  33. data/lib/kitchen/instance.rb +41 -15
  34. data/lib/kitchen/lazy_hash.rb +0 -1
  35. data/lib/kitchen/lifecycle_hooks.rb +0 -1
  36. data/lib/kitchen/loader/yaml.rb +2 -3
  37. data/lib/kitchen/logger.rb +1 -2
  38. data/lib/kitchen/logging.rb +0 -1
  39. data/lib/kitchen/login_command.rb +0 -1
  40. data/lib/kitchen/metadata_chopper.rb +0 -1
  41. data/lib/kitchen/platform.rb +0 -1
  42. data/lib/kitchen/plugin.rb +0 -1
  43. data/lib/kitchen/plugin_base.rb +60 -0
  44. data/lib/kitchen/provisioner.rb +0 -1
  45. data/lib/kitchen/provisioner/base.rb +2 -2
  46. data/lib/kitchen/provisioner/chef/berkshelf.rb +0 -1
  47. data/lib/kitchen/provisioner/chef/common_sandbox.rb +1 -2
  48. data/lib/kitchen/provisioner/chef/policyfile.rb +2 -3
  49. data/lib/kitchen/provisioner/chef_apply.rb +2 -3
  50. data/lib/kitchen/provisioner/chef_base.rb +29 -19
  51. data/lib/kitchen/provisioner/chef_solo.rb +0 -1
  52. data/lib/kitchen/provisioner/chef_zero.rb +0 -1
  53. data/lib/kitchen/provisioner/dummy.rb +0 -1
  54. data/lib/kitchen/provisioner/shell.rb +1 -2
  55. data/lib/kitchen/rake_tasks.rb +0 -1
  56. data/lib/kitchen/shell_out.rb +1 -2
  57. data/lib/kitchen/ssh.rb +2 -3
  58. data/lib/kitchen/state_file.rb +1 -2
  59. data/lib/kitchen/suite.rb +0 -1
  60. data/lib/kitchen/thor_tasks.rb +1 -2
  61. data/lib/kitchen/transport.rb +0 -1
  62. data/lib/kitchen/transport/base.rb +2 -2
  63. data/lib/kitchen/transport/dummy.rb +0 -1
  64. data/lib/kitchen/transport/exec.rb +1 -2
  65. data/lib/kitchen/transport/ssh.rb +4 -5
  66. data/lib/kitchen/transport/winrm.rb +3 -4
  67. data/lib/kitchen/util.rb +0 -1
  68. data/lib/kitchen/verifier.rb +0 -1
  69. data/lib/kitchen/verifier/base.rb +2 -2
  70. data/lib/kitchen/verifier/busser.rb +2 -3
  71. data/lib/kitchen/verifier/dummy.rb +0 -1
  72. data/lib/kitchen/verifier/shell.rb +1 -2
  73. data/lib/kitchen/version.rb +1 -2
  74. data/lib/vendor/hash_recursive_merge.rb +0 -1
  75. data/templates/init/kitchen.yml.erb +2 -2
  76. data/test-kitchen.gemspec +4 -5
  77. metadata +21 -14
@@ -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"
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: SAWANOBORI Yukihiko <sawanoboriyu@higanworks.com>)
4
3
  #
@@ -30,8 +29,8 @@
30
29
  # name: chef_apply
31
30
  #
32
31
  # platforms:
33
- # - name: ubuntu-16.04
34
- # - name: centos-7
32
+ # - name: ubuntu-20.04
33
+ # - name: centos-8
35
34
  #
36
35
  # suites:
37
36
  # - name: default
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,10 +15,10 @@
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"
@@ -154,7 +153,7 @@ module Kitchen
154
153
 
155
154
  # New Usage #
156
155
  provisioner:
157
- product_name: <chef or chefdk>
156
+ product_name: <chef or chef-workstation>
158
157
  install_strategy: skip
159
158
  MSG
160
159
  when provisioner[:require_chef_omnibus].to_s.match(/\d/)
@@ -167,7 +166,7 @@ module Kitchen
167
166
 
168
167
  # New Usage #
169
168
  provisioner:
170
- product_name: <chef or chefdk>
169
+ product_name: <chef or chef-workstation>
171
170
  product_version: #{provisioner[:require_chef_omnibus]}
172
171
  MSG
173
172
  when provisioner[:require_chef_omnibus] == "latest"
@@ -180,7 +179,7 @@ module Kitchen
180
179
 
181
180
  # New Usage #
182
181
  provisioner:
183
- product_name: <chef or chefdk>
182
+ product_name: <chef or chef-workstation>
184
183
  install_strategy: always
185
184
  MSG
186
185
  end
@@ -200,11 +199,11 @@ module Kitchen
200
199
 
201
200
  # Deprecated Example #
202
201
  provisioner:
203
- chef_omnibus_install_options: -P chefdk -c current
202
+ chef_omnibus_install_options: -P chef-workstation -c current
204
203
 
205
204
  # New Usage #
206
205
  provisioner:
207
- product_name: chefdk
206
+ product_name: chef-workstation
208
207
  channel: current
209
208
  MSG
210
209
 
@@ -217,7 +216,7 @@ module Kitchen
217
216
 
218
217
  # New Usage #
219
218
  provisioner:
220
- product_name: <chef or chefdk>
219
+ product_name: <chef or chef-workstation>
221
220
  download_url: http://direct-download-url
222
221
  MSG
223
222
 
@@ -226,9 +225,9 @@ module Kitchen
226
225
  fully managed by using attribute settings.
227
226
  MSG
228
227
 
229
- # Reads the local Chef::Config object (if present). We do this because
230
- # we want to start bring Chef config and ChefDK tool config closer
231
- # together. For example, we want to configure proxy settings in 1
228
+ # Reads the local Chef::Config object (if present). We do this because
229
+ # we want to start bring Chef config and Chef Workstation config closer
230
+ # together. For example, we want to configure proxy settings in 1
232
231
  # location instead of 3 configuration files.
233
232
  #
234
233
  # @param config [Hash] initial provided configuration
@@ -329,7 +328,7 @@ module Kitchen
329
328
  return unless config[:require_chef_omnibus] || config[:product_name]
330
329
  return if config[:product_name] && config[:install_strategy] == "skip"
331
330
 
332
- prefix_command(sudo(install_script_contents))
331
+ prefix_command(install_script_contents)
333
332
  end
334
333
 
335
334
  private
@@ -517,6 +516,12 @@ module Kitchen
517
516
  opts[key] = config[key] if config[key]
518
517
  end
519
518
 
519
+ unless windows_os?
520
+ # omnitruck installer does not currently support a tmp dir option on windows
521
+ opts[:install_command_options][:tmp_dir] = config[:root_path]
522
+ opts[:install_command_options]["TMPDIR"] = config[:root_path]
523
+ end
524
+
520
525
  if config[:download_url]
521
526
  opts[:install_command_options][:download_url_override] = config[:download_url]
522
527
  opts[:install_command_options][:checksum] = config[:checksum] if config[:checksum]
@@ -535,7 +540,6 @@ module Kitchen
535
540
  # install.ps1 only supports http_proxy
536
541
  prox.delete_if { |p| %i{https_proxy ftp_proxy no_proxy}.include?(p) } if powershell_shell?
537
542
  end
538
-
539
543
  opts[:install_command_options].merge!(proxies)
540
544
  end)
541
545
  config[:chef_omnibus_root] = installer.root
@@ -554,8 +558,14 @@ module Kitchen
554
558
  end
555
559
 
556
560
  def install_from_file(command)
557
- install_file = "/tmp/chef-installer.sh"
558
- script = ["cat > #{install_file} <<\"EOL\""]
561
+ install_file = "#{config[:root_path]}/chef-installer.sh"
562
+ script = []
563
+ script << "mkdir -p #{config[:root_path]}"
564
+ script << "if [ $? -ne 0 ]; then"
565
+ script << " echo Kitchen config setting root_path: '#{config[:root_path]}' not creatable by regular user "
566
+ script << " exit 1"
567
+ script << "fi"
568
+ script << "cat > #{install_file} <<\"EOL\""
559
569
  script << command
560
570
  script << "EOL"
561
571
  script << "chmod +x #{install_file}"
@@ -570,7 +580,7 @@ module Kitchen
570
580
  config[:require_chef_omnibus], powershell_shell?, install_options
571
581
  )
572
582
  config[:chef_omnibus_root] = installer.root
573
- installer.install_command
583
+ sudo(installer.install_command)
574
584
  end
575
585
 
576
586
  # Hook used in subclasses to indicate support for policyfiles.
@@ -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:: 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,9 @@
17
16
  # limitations under the License.
18
17
 
19
18
  require "logger"
20
- require "net/ssh"
19
+ require "net/ssh" unless defined?(Net::SSH)
21
20
  require "net/scp"
22
- require "socket"
21
+ require "socket" unless defined?(Socket)
23
22
 
24
23
  require_relative "errors"
25
24
  require_relative "login_command"
@@ -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
+ require "yaml" unless defined?(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