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 +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/kitchen/command/diagnose.rb +30 -8
- data/lib/kitchen/diagnostic.rb +14 -2
- data/lib/kitchen/errors.rb +2 -1
- data/lib/kitchen/provisioner/base.rb +3 -0
- data/lib/kitchen/provisioner/chef/berkshelf.rb +16 -6
- data/lib/kitchen/provisioner/chef/librarian.rb +17 -6
- data/lib/kitchen/provisioner/chef_base.rb +10 -0
- data/lib/kitchen/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ded765291266ac1c8c46c55e66b5f939b840a5d2
|
4
|
+
data.tar.gz: 725bb4f06f42cb37defa82b0d5683bfb3e04b8e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
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
|
-
|
47
|
-
|
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
|
data/lib/kitchen/diagnostic.rb
CHANGED
@@ -50,12 +50,24 @@ module Kitchen
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def prepare_loader
|
53
|
-
|
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
|
-
|
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
|
data/lib/kitchen/errors.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
-
|
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(" ")
|
data/lib/kitchen/version.rb
CHANGED