test-kitchen 1.2.0 → 1.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3c4db1c478015e6304dfe1664f758171403be58
4
- data.tar.gz: 61c4f294a642cf6d300e9388a97919f712875be5
3
+ metadata.gz: ded765291266ac1c8c46c55e66b5f939b840a5d2
4
+ data.tar.gz: 725bb4f06f42cb37defa82b0d5683bfb3e04b8e1
5
5
  SHA512:
6
- metadata.gz: b5b814ee625daaf11b9105476bc1f3c32f8079f22ee19298d787ad1fa41e090253d4a894227f64b10bbaee67775d4e0e755b925f2f3f9199c97d246650584d2a
7
- data.tar.gz: 395cd37b2a48b85ee8e2005e27a6038159c2655a920f9d1e466717dd177c9b8adc58a6a0b13063b94d0c70fdc510ecceadc058444be82692b15911d2d9e2159c
6
+ metadata.gz: 77aa107fcdc3ad04cfde45eb675fa34dec8a75a0b74a7255670f1f6120a5644c87250e98d200b61dac801b22763e716f63c7a9fef28906e6d0689e09af580796
7
+ data.tar.gz: f6bf66a90f691d3d1550d4e78417bfd778b6452542d9ae2c4b256656bee714018468c468c1c273b00356da3e44f7ac004e1aec2f7b32231b9923e969f3fff7c6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 1.2.1 / 2014-02-12
2
+
3
+ ### Bug fixes
4
+
5
+ * Issue [#357][], pull request [#358][]: Load needed (dynamic) dependencies for provisioners at creation time to prevent any native or dynamic code being loaded in a non-main thread (an issue on Mac with MRI Ruby 1.9/2.0). ([@fnichol][])
6
+
7
+ ### Improvements
8
+
9
+ * Pull request [#358][]: Output the loaded version of Berkshelf or Librarian-Chef when converging to better help troubleshooting issues. ([@fnichol][])
10
+
11
+
1
12
  ## 1.2.0 / 2014-02-11
2
13
 
3
14
  ### Upstream changes
@@ -459,6 +470,8 @@ The initial release.
459
470
  [#316]: https://github.com/opscode/test-kitchen/issues/316
460
471
  [#318]: https://github.com/opscode/test-kitchen/issues/318
461
472
  [#353]: https://github.com/opscode/test-kitchen/issues/353
473
+ [#357]: https://github.com/opscode/test-kitchen/issues/357
474
+ [#358]: https://github.com/opscode/test-kitchen/issues/358
462
475
  [@ChrisLundquist]: https://github.com/ChrisLundquist
463
476
  [@adamhjk]: https://github.com/adamhjk
464
477
  [@arangamani]: https://github.com/arangamani
@@ -31,20 +31,42 @@ module Kitchen
31
31
  class Diagnose < Kitchen::Command::Base
32
32
 
33
33
  def call
34
- loader = if options[:all] || options[:loader]
35
- @loader
36
- else
37
- nil
38
- end
34
+ instances = record_failure { load_instances }
35
+
36
+ loader = record_failure { load_loader }
37
+
38
+ puts Kitchen::Diagnostic.new(
39
+ :loader => loader, :instances => instances).read.to_yaml
40
+ end
41
+
42
+ private
39
43
 
40
- instances = if options[:all] || options[:instances]
44
+ def load_instances
45
+ if options[:all] || options[:instances]
41
46
  parse_subcommand(args.first)
42
47
  else
43
48
  []
44
49
  end
50
+ end
45
51
 
46
- puts Kitchen::Diagnostic.new(
47
- :loader => loader, :instances => instances).read.to_yaml
52
+ def load_loader
53
+ if options[:all] || options[:loader]
54
+ @loader
55
+ else
56
+ nil
57
+ end
58
+ end
59
+
60
+ def record_failure
61
+ yield
62
+ rescue => e
63
+ {
64
+ :error => {
65
+ :exception => e.inspect,
66
+ :message => e.message,
67
+ :backtrace => e.backtrace
68
+ }
69
+ }
48
70
  end
49
71
  end
50
72
  end
@@ -50,12 +50,24 @@ module Kitchen
50
50
  end
51
51
 
52
52
  def prepare_loader
53
- result[:loader] = loader.diagnose if loader
53
+ if error_hash?(loader)
54
+ result[:loader] = loader
55
+ else
56
+ result[:loader] = loader.diagnose if loader
57
+ end
54
58
  end
55
59
 
56
60
  def prepare_instances
57
61
  result[:instances] = Hash.new
58
- Array(instances).each { |i| result[:instances][i.name] = i.diagnose }
62
+ if error_hash?(instances)
63
+ result[:instances][:error] = instances[:error]
64
+ else
65
+ Array(instances).each { |i| result[:instances][i.name] = i.diagnose }
66
+ end
67
+ end
68
+
69
+ def error_hash?(obj)
70
+ obj.is_a?(Hash) && obj.has_key?(:error)
59
71
  end
60
72
  end
61
73
  end
@@ -122,7 +122,8 @@ module Kitchen
122
122
 
123
123
  def self.handle_error(e)
124
124
  stderr_log(Error.formatted_exception(e))
125
- stderr_log("Please see .kitchen/logs/kitchen.log for more details\n")
125
+ stderr_log("Please see .kitchen/logs/kitchen.log for more details")
126
+ stderr_log("Also try running `kitchen diagnose --all` for configuration\n")
126
127
  file_log(:error, Error.formatted_trace(e))
127
128
  end
128
129
  end
@@ -41,6 +41,7 @@ module Kitchen
41
41
  def instance=(instance)
42
42
  @instance = instance
43
43
  expand_paths!
44
+ load_needed_dependencies!
44
45
  end
45
46
 
46
47
  # Returns the name of this driver, suitable for display in a CLI.
@@ -128,6 +129,8 @@ module Kitchen
128
129
  end
129
130
  end
130
131
 
132
+ def load_needed_dependencies! ; end
133
+
131
134
  def logger
132
135
  instance ? instance.logger : Kitchen.logger
133
136
  end
@@ -39,12 +39,15 @@ module Kitchen
39
39
  @logger = logger
40
40
  end
41
41
 
42
+ def self.load!(logger = Kitchen.logger)
43
+ load_berkshelf!(logger)
44
+ end
45
+
42
46
  def resolve
43
- info("Resolving cookbook dependencies with Berkshelf...")
47
+ version = ::Berkshelf::VERSION
48
+ info("Resolving cookbook dependencies with Berkshelf #{version}...")
44
49
  debug("Using Berksfile from #{berksfile}")
45
50
 
46
- load_berkshelf!
47
-
48
51
  ::Berkshelf.ui.mute do
49
52
  if ::Berkshelf::Berksfile.method_defined?(:vendor)
50
53
  # Berkshelf 3.0 requires the directory to not exist
@@ -60,10 +63,17 @@ module Kitchen
60
63
 
61
64
  attr_reader :berksfile, :path, :logger
62
65
 
63
- def load_berkshelf!
64
- require 'berkshelf'
66
+ def self.load_berkshelf!(logger)
67
+ first_load = require 'berkshelf'
68
+
69
+ version = ::Berkshelf::VERSION
70
+ if first_load
71
+ logger.debug("Berkshelf #{version} library loaded")
72
+ else
73
+ logger.debug("Berkshelf #{version} previously loaded")
74
+ end
65
75
  rescue LoadError => e
66
- fatal("The `berkshelf' gem is missing and must be installed" +
76
+ logger.fatal("The `berkshelf' gem is missing and must be installed" +
67
77
  " or cannot be properly activated. Run" +
68
78
  " `gem install berkshelf` or add the following to your" +
69
79
  " Gemfile if you are using Bundler: `gem 'berkshelf'`.")
@@ -33,18 +33,22 @@ module Kitchen
33
33
 
34
34
  include Logging
35
35
 
36
+
36
37
  def initialize(cheffile, path, logger = Kitchen.logger)
37
38
  @cheffile = cheffile
38
39
  @path = path
39
40
  @logger = logger
40
41
  end
41
42
 
43
+ def self.load!(logger = Kitchen.logger)
44
+ load_librarian!(logger)
45
+ end
46
+
42
47
  def resolve
43
- info("Resolving cookbook dependencies with Librarian-Chef")
48
+ version = ::Librarian::Chef::VERSION
49
+ info("Resolving cookbook dependencies with Librarian-Chef #{version}...")
44
50
  debug("Using Cheffile from #{cheffile}")
45
51
 
46
- load_librarian!
47
-
48
52
  env = ::Librarian::Chef::Environment.new(
49
53
  :project_path => File.dirname(cheffile))
50
54
  env.config_db.local["path"] = path
@@ -54,12 +58,19 @@ module Kitchen
54
58
 
55
59
  attr_reader :cheffile, :path, :logger
56
60
 
57
- def load_librarian!
58
- require 'librarian/chef/environment'
61
+ def self.load_librarian!(logger)
62
+ first_load = require 'librarian/chef/environment'
59
63
  require 'librarian/action/resolve'
60
64
  require 'librarian/action/install'
65
+
66
+ version = ::Librarian::Chef::VERSION
67
+ if first_load
68
+ logger.debug("Librarian-Chef #{version} library loaded")
69
+ else
70
+ logger.debug("Librarian-Chef #{version} previously loaded")
71
+ end
61
72
  rescue LoadError => e
62
- fatal("The `librarian-chef' gem is missing and must be installed" +
73
+ logger.fatal("The `librarian-chef' gem is missing and must be installed" +
63
74
  " or cannot be properly activated. Run" +
64
75
  " `gem install librarian-chef` or add the following to your" +
65
76
  " Gemfile if you are using Bundler: `gem 'librarian-chef'`.")
@@ -129,6 +129,16 @@ module Kitchen
129
129
 
130
130
  protected
131
131
 
132
+ def load_needed_dependencies!
133
+ if File.exists?(berksfile)
134
+ debug("Berksfile found at #{berksfile}, loading Berkshelf")
135
+ Chef::Berkshelf.load!(logger)
136
+ elsif File.exists?(cheffile)
137
+ debug("Cheffile found at #{cheffile}, loading Librarian-Chef")
138
+ Chef::Librarian.load!(logger)
139
+ end
140
+ end
141
+
132
142
  def format_config_file(data)
133
143
  data.each.map { |attr, value|
134
144
  [attr, (value.is_a?(Array) ? value.to_s : %{"#{value}"})].join(" ")
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Kitchen
20
20
 
21
- VERSION = "1.2.0"
21
+ VERSION = "1.2.1"
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol