test-kitchen 3.2.0 → 3.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: 6ca7e5ea2276e74e8d5d6555731377aa0aacce64482f3ff810f18bca54095616
4
- data.tar.gz: a726dfed16b6c6177559ed80a6450573fda9b9d3777aa008b3d639a81f152201
3
+ metadata.gz: c0f0f59e09f9a2d65a94c33e6c0e833b7fc86958d88d42ef71f4934196cd809f
4
+ data.tar.gz: aa0bcc30665a7628da122d74354f113965dbdc86e0b68faa1b275fd30cdbbeb5
5
5
  SHA512:
6
- metadata.gz: 69456998d9b85ad5d28f522a98d7668279081c67a5c8dbdf17b299de2a8364d65064a641088d32f0dd820305beb07263ca0f2c66c49f6e433b9b9a3c49fe2b9b
7
- data.tar.gz: c24f12f481427bf8a259afaaf09b93efe23c2d27632083fc3b78a25182a35e37f2fcfabf8344a7f0b30745a27b205904e21e247540e486e13f9810b8831db039
6
+ metadata.gz: 726d1016370af32c8a40f8877a51a9ff5c3bc4e7f57952318bdfdb3cd8356c0fe3b326ea67596299447cdbd9c5cf915f1c3f2ec41ea0b88b4427526ff0c99a32
7
+ data.tar.gz: 40d835a7607f6de437bbdb8cd03c720891bc6d8e9417c986f2e9ef5abeded7c7c4957ef0fff727d16152d0e4a967cfe76e9507b02bfff9489498d02d31c6447a
data/Gemfile CHANGED
@@ -17,5 +17,5 @@ group :debug do
17
17
  end
18
18
 
19
19
  group :chefstyle do
20
- gem "chefstyle", "2.1.0"
20
+ gem "chefstyle", "2.2.2"
21
21
  end
@@ -241,7 +241,7 @@ module Kitchen
241
241
  #{deprecated_config.keys.join("\n")}
242
242
  Run 'kitchen doctor' for details.
243
243
  MSG
244
- warn(warning)
244
+ Error.warn_on_stderr(warning)
245
245
 
246
246
  # Set global var that the deprecation message has been printed
247
247
  @@has_been_warned_of_deprecations = true
@@ -70,7 +70,7 @@ module Kitchen
70
70
  def converge(state) # rubocop:disable Metrics/AbcSize
71
71
  provisioner = instance.provisioner
72
72
  provisioner.create_sandbox
73
- sandbox_dirs = Util.list_directory(provisioner.sandbox_path)
73
+ sandbox_dirs = provisioner.sandbox_dirs
74
74
 
75
75
  instance.transport.connection(backcompat_merged_state(state)) do |conn|
76
76
  conn.execute(env_cmd(provisioner.install_command))
@@ -94,6 +94,19 @@ module Kitchen
94
94
  "".center(22, "-"),
95
95
  ]
96
96
  end
97
+
98
+ # Log a warn message on STDERR device.
99
+ # This will help to distinguish between the errors and
100
+ # output when parsing the output from the commands like
101
+ # kitchen diagnose.
102
+ #
103
+ # @params lines [Array<String>] Array of lines that needs to be printed
104
+ def self.warn_on_stderr(lines)
105
+ Array(lines).each do |line|
106
+ line = Color.colorize(line, :blue) if Kitchen.tty?
107
+ $stderr.puts(line)
108
+ end
109
+ end
97
110
  end
98
111
 
99
112
  # Base exception class from which all Kitchen exceptions derive. This class
@@ -70,7 +70,6 @@ module Kitchen
70
70
  # rubocop:disable Metrics/AbcSize
71
71
  def call(state)
72
72
  create_sandbox
73
- sandbox_dirs = Util.list_directory(sandbox_path)
74
73
 
75
74
  instance.transport.connection(state) do |conn|
76
75
  config[:uploads].to_h.each do |locals, remote|
@@ -182,6 +181,13 @@ module Kitchen
182
181
  "trying to access the path."
183
182
  end
184
183
 
184
+ # Returns the list of items in the sandbox directory
185
+ #
186
+ # @return [String] path of items in the sandbox directory
187
+ def sandbox_dirs
188
+ Util.list_directory(sandbox_path)
189
+ end
190
+
185
191
  # Deletes the sandbox path. Without calling this method, the sandbox path
186
192
  # will persist after the process terminates. In other words, cleanup is
187
193
  # explicit. This method is safe to call multiple times.
@@ -289,7 +289,8 @@ module Kitchen
289
289
  policyfile, sandbox_path,
290
290
  logger: logger,
291
291
  always_update: config[:always_update_cookbooks],
292
- policy_group: policy_group
292
+ policy_group: policy_group,
293
+ license: config[:chef_license]
293
294
  )
294
295
  Kitchen.mutex.synchronize do
295
296
  policy.compile
@@ -308,7 +309,8 @@ module Kitchen
308
309
  policyfile, sandbox_path,
309
310
  logger: logger,
310
311
  always_update: config[:always_update_cookbooks],
311
- policy_group: config[:policy_group]
312
+ policy_group: config[:policy_group],
313
+ license: config[:chef_license]
312
314
  ).resolve
313
315
  end
314
316
  end
@@ -41,12 +41,13 @@ module Kitchen
41
41
  # cookbooks
42
42
  # @param logger [Kitchen::Logger] a logger to use for output, defaults
43
43
  # to `Kitchen.logger`
44
- def initialize(policyfile, path, logger: Kitchen.logger, always_update: false, policy_group: nil)
44
+ def initialize(policyfile, path, license: nil, logger: Kitchen.logger, always_update: false, policy_group: nil)
45
45
  @policyfile = policyfile
46
46
  @path = path
47
47
  @logger = logger
48
48
  @always_update = always_update
49
49
  @policy_group = policy_group
50
+ @license = license
50
51
  end
51
52
 
52
53
  # Loads the library code required to use the resolver.
@@ -62,10 +63,10 @@ module Kitchen
62
63
  def resolve
63
64
  if policy_group
64
65
  info("Exporting cookbook dependencies from Policyfile #{path} with policy_group #{policy_group} using `#{cli_path} export`...")
65
- run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --policy_group #{policy_group} --force")
66
+ run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --policy_group #{policy_group} --force --chef-license #{license}")
66
67
  else
67
68
  info("Exporting cookbook dependencies from Policyfile #{path} using `#{cli_path} export`...")
68
- run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --force")
69
+ run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --force --chef-license #{license}")
69
70
  end
70
71
  end
71
72
 
@@ -77,11 +78,11 @@ module Kitchen
77
78
  else
78
79
  info("Policy lock file doesn't exist, running `#{cli_path} install` for Policyfile #{policyfile}...")
79
80
  end
80
- run_command("#{cli_path} install #{escape_path(policyfile)}")
81
+ run_command("#{cli_path} install #{escape_path(policyfile)} --chef-license #{license}")
81
82
 
82
83
  if always_update
83
84
  info("Updating policy lock using `#{cli_path} update`")
84
- run_command("#{cli_path} update #{escape_path(policyfile)}")
85
+ run_command("#{cli_path} update #{escape_path(policyfile)} --chef-license #{license}")
85
86
  end
86
87
  end
87
88
 
@@ -114,6 +115,10 @@ module Kitchen
114
115
  # @api private
115
116
  attr_reader :policy_group
116
117
 
118
+ # @return [String] name of the chef_license
119
+ # @api private
120
+ attr_reader :license
121
+
117
122
  # Escape spaces in a path in way that works with both Sh (Unix) and
118
123
  # Windows.
119
124
  #
@@ -152,7 +157,7 @@ module Kitchen
152
157
  def no_cli_found_error
153
158
  @logger.fatal("The `chef` or `chef-cli` executables cannot be found in your " \
154
159
  "PATH. Ensure you have installed Chef Workstation " \
155
- "from https://downloads.chef.io and that your PATH " \
160
+ "from https://www.chef.io/downloads/ and that your PATH " \
156
161
  "setting includes the path to the `chef` or `chef-cli` commands.")
157
162
  raise UserError, "Could not find the chef or chef-cli executables in your PATH."
158
163
  end
@@ -681,25 +681,42 @@ module Kitchen
681
681
  chef_cmds(base_cmd).join(separator)
682
682
  end
683
683
 
684
- # Gives an array of command
684
+ # Gives an array of commands
685
685
  # @api private
686
686
  def chef_cmds(base_cmd)
687
- cmd = prefix_command(wrap_shell_code(
688
- [base_cmd, *chef_args(config_filename), last_exit_code].join(" ")
689
- .tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
690
- ))
691
-
692
- cmds = [cmd].cycle(config[:multiple_converge].to_i).to_a
693
-
694
- if config[:enforce_idempotency]
695
- idempotent_cmd = prefix_command(wrap_shell_code(
696
- [base_cmd, *chef_args("client_no_updated_resources.rb"), last_exit_code].join(" ")
697
- .tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
698
- ))
699
- cmds[-1] = idempotent_cmd
687
+ cmds = []
688
+ num_converges = config[:multiple_converge].to_i
689
+ idempotency = config[:enforce_idempotency]
690
+
691
+ # Execute Chef Client n-1 times, without exiting
692
+ (num_converges - 1).times do
693
+ cmds << wrapped_chef_cmd(base_cmd, config_filename)
700
694
  end
695
+
696
+ # Append another execution with Windows specific Exit code helper or (for
697
+ # idempotency check) a specific config file which assures no changed resources.
698
+ cmds << unless idempotency
699
+ wrapped_chef_cmd(base_cmd, config_filename, append: last_exit_code)
700
+ else
701
+ wrapped_chef_cmd(base_cmd, "client_no_updated_resources.rb", append: last_exit_code)
702
+ end
701
703
  cmds
702
704
  end
705
+
706
+ # Concatenate all arguments and wrap it with shell-specifics
707
+ # @api private
708
+ def wrapped_chef_cmd(base_cmd, configfile, append: "")
709
+ args = []
710
+
711
+ args << base_cmd
712
+ args << chef_args(configfile)
713
+ args << append
714
+
715
+ shell_cmd = args.flatten.join(" ")
716
+ shell_cmd = shell_cmd.prepend(reload_ps1_path) if windows_os?
717
+
718
+ prefix_command(wrap_shell_code(shell_cmd))
719
+ end
703
720
  end
704
721
  end
705
722
  end
@@ -128,8 +128,8 @@ module Kitchen
128
128
  tries += 1
129
129
  debug("Attempting to execute command - try #{tries} of #{max_retries}.")
130
130
  execute(command)
131
- rescue Kitchen::Transport::TransportFailed => e
132
- if retry?(tries, max_retries, retryable_exit_codes, e.exit_code)
131
+ rescue Exception => e
132
+ if retry?(tries, max_retries, retryable_exit_codes, e)
133
133
  close
134
134
  sleep wait_time
135
135
  retry
@@ -139,10 +139,14 @@ module Kitchen
139
139
  end
140
140
  end
141
141
 
142
- def retry?(current_try, max_retries, retryable_exit_codes, exit_code)
143
- current_try <= max_retries &&
144
- !retryable_exit_codes.nil? &&
145
- retryable_exit_codes.flatten.include?(exit_code)
142
+ def retry?(current_try, max_retries, retryable_exit_codes, exception)
143
+ if exception.is_a?(Kitchen::Transport::TransportFailed)
144
+ return current_try <= max_retries &&
145
+ !retryable_exit_codes.nil? &&
146
+ retryable_exit_codes.flatten.include?(exception.exit_code)
147
+ end
148
+
149
+ false
146
150
  end
147
151
 
148
152
  # Builds a LoginCommand which can be used to open an interactive
@@ -21,6 +21,7 @@ require "rbconfig" unless defined?(RbConfig)
21
21
  require "uri" unless defined?(URI)
22
22
  require_relative "../../kitchen"
23
23
  require "winrm" unless defined?(WinRM::Connection)
24
+ require "winrm/exceptions" unless defined?(WinRM::WinRMHTTPTransportError)
24
25
 
25
26
  module Kitchen
26
27
  module Transport
@@ -118,6 +119,22 @@ module Kitchen
118
119
  end
119
120
  end
120
121
 
122
+ def retry?(current_try, max_retries, retryable_exit_codes, exception)
123
+ # Avoid duplicating Kitchen::Transport::Base#retry?
124
+ result = super
125
+ return result if result == true
126
+
127
+ case exception
128
+ when WinRM::WinRMHTTPTransportError
129
+ return current_try <= max_retries &&
130
+ [400, 500].include?(exception.status_code)
131
+ when WinRM::WinRMWSManFault
132
+ return current_try <= max_retries
133
+ end
134
+
135
+ false
136
+ end
137
+
121
138
  # (see Base::Connection#login_command)
122
139
  def login_command
123
140
  case RbConfig::CONFIG["host_os"]
@@ -65,7 +65,6 @@ module Kitchen
65
65
  # @raise [ActionFailed] if the action could not be completed
66
66
  def call(state)
67
67
  create_sandbox
68
- sandbox_dirs = Util.list_directory(sandbox_path)
69
68
 
70
69
  instance.transport.connection(state) do |conn|
71
70
  conn.execute(install_command)
@@ -174,6 +173,13 @@ module Kitchen
174
173
  "trying to access the path."
175
174
  end
176
175
 
176
+ # Returns the list of items in the sandbox directory
177
+ #
178
+ # @return [String] the absolute path of sandbox directory files
179
+ def sandbox_dirs
180
+ Util.list_directory(sandbox_path)
181
+ end
182
+
177
183
  # Sets the API version for this verifier. If the verifier does not set
178
184
  # this value, then `nil` will be used and reported.
179
185
  #
@@ -16,5 +16,5 @@
16
16
  # limitations under the License.
17
17
 
18
18
  module Kitchen
19
- VERSION = "3.2.0".freeze
19
+ VERSION = "3.3.0".freeze
20
20
  end
@@ -58,7 +58,7 @@ Created and maintained by [<%= config[:author] %>][author] (<<%= config[:email]
58
58
 
59
59
  [author]: https://github.com/enter-github-user
60
60
  [issues]: https://github.com/enter-github-user/<%= config[:gem_name] %>/issues
61
- [license]: https://github.com/enter-github-user/<%= config[:gem_name] %>/blob/master/LICENSE
61
+ [license]: https://github.com/enter-github-user/<%= config[:gem_name] %>/blob/main/LICENSE
62
62
  [repo]: https://github.com/enter-github-user/<%= config[:gem_name] %>
63
- [driver_usage]: http://docs.kitchen-ci.org/drivers/usage
63
+ [driver_usage]: https://kitchen.ci/docs/drivers/
64
64
  [chef_omnibus_dl]: http://www.chef.io/chef/install/
data/test-kitchen.gemspec CHANGED
@@ -42,9 +42,9 @@ Gem::Specification.new do |gem|
42
42
  gem.add_development_dependency "bundler"
43
43
  gem.add_development_dependency "rake"
44
44
 
45
- gem.add_development_dependency "aruba", "~> 0.11", "< 1.0"
45
+ gem.add_development_dependency "aruba", ">= 0.11", "< 3.0"
46
46
  gem.add_development_dependency "fakefs", "~> 1.0"
47
- gem.add_development_dependency "minitest", "~> 5.3", "< 5.15"
47
+ gem.add_development_dependency "minitest", "~> 5.3", "< 5.16"
48
48
  gem.add_development_dependency "mocha", "~> 1.1"
49
49
  gem.add_development_dependency "cucumber", ">= 2.1", "< 8.0"
50
50
  gem.add_development_dependency "countloc", "~> 0.4"
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: 3.2.0
4
+ version: 3.3.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: 2021-11-17 00:00:00.000000000 Z
11
+ date: 2022-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -274,22 +274,22 @@ dependencies:
274
274
  name: aruba
275
275
  requirement: !ruby/object:Gem::Requirement
276
276
  requirements:
277
- - - "~>"
277
+ - - ">="
278
278
  - !ruby/object:Gem::Version
279
279
  version: '0.11'
280
280
  - - "<"
281
281
  - !ruby/object:Gem::Version
282
- version: '1.0'
282
+ version: '3.0'
283
283
  type: :development
284
284
  prerelease: false
285
285
  version_requirements: !ruby/object:Gem::Requirement
286
286
  requirements:
287
- - - "~>"
287
+ - - ">="
288
288
  - !ruby/object:Gem::Version
289
289
  version: '0.11'
290
290
  - - "<"
291
291
  - !ruby/object:Gem::Version
292
- version: '1.0'
292
+ version: '3.0'
293
293
  - !ruby/object:Gem::Dependency
294
294
  name: fakefs
295
295
  requirement: !ruby/object:Gem::Requirement
@@ -313,7 +313,7 @@ dependencies:
313
313
  version: '5.3'
314
314
  - - "<"
315
315
  - !ruby/object:Gem::Version
316
- version: '5.15'
316
+ version: '5.16'
317
317
  type: :development
318
318
  prerelease: false
319
319
  version_requirements: !ruby/object:Gem::Requirement
@@ -323,7 +323,7 @@ dependencies:
323
323
  version: '5.3'
324
324
  - - "<"
325
325
  - !ruby/object:Gem::Version
326
- version: '5.15'
326
+ version: '5.16'
327
327
  - !ruby/object:Gem::Dependency
328
328
  name: mocha
329
329
  requirement: !ruby/object:Gem::Requirement
@@ -520,7 +520,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
520
520
  - !ruby/object:Gem::Version
521
521
  version: '0'
522
522
  requirements: []
523
- rubygems_version: 3.2.22
523
+ rubygems_version: 3.3.7
524
524
  signing_key:
525
525
  specification_version: 4
526
526
  summary: Test Kitchen is an integration tool for developing and testing infrastructure