test-kitchen 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: d22285218684802317ed183046f76c3cc2344292
4
- data.tar.gz: ddebfec0f35d3e73146860e4f0c1965b5dcfa606
3
+ metadata.gz: 64d47d36ddf40c8ecc6d85d959e3a57156532e47
4
+ data.tar.gz: 2c60df4e026b0f2cad64dc5b4c3c3ba1341ac2a6
5
5
  SHA512:
6
- metadata.gz: dcc1ca63e1da958c70604f2df12fd141004f41339be28d815c593f5e1fa02b97005613dcd720dccc78fc2994ca82ce345b6a9e936efd50264e3883e4a36f87d5
7
- data.tar.gz: 530e3634dc4113aa662f95aec7f8e5f49028fdaef173db54b172ff4253c9c8d79973b8b499823d6012d5c8f6307266eb7f7b5582e4180d5b79937fce1953d221
6
+ metadata.gz: a3de01b4c239c767b824c4d29b8645950ab2704f20c821dd42877d9034ec7024f9b669d4b1c41141ebb213f02f1fe33832adbd2eef804b089abdff78e1aa3d2f
7
+ data.tar.gz: 3b6ad9625a57724367af1de37712d39b9e2bd6c2115a3f5a66bda655b180797f319888d5ac916a4425b013bf390178d21398aba2198c125779c487f92658f1ad
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 1.1.1 / 2013-12-08
2
+
3
+ ### Bug fixes
4
+
5
+ * Normalize driver, provisioner, & busser blocks when merging raw YAML. ([@fnichol][])
6
+ * Issue [#276][], issue [#278][]: Ensure `Busser#local_suite_files` only rejects chef data dirs. ([@fnichol][])
7
+ * Pull request [#275][]: Fix SSH 'Too many authentication failures' error. ([@zts][])
8
+ * When copying `./cookbooks`, conditionally check for `./site-cookbooks`. ([@fnichol][])
9
+
10
+ ### Improvements
11
+
12
+ * Improve `kitchen diagnose` when loader data merging fails. ([@fnichol][])
13
+
14
+
1
15
  ## 1.1.0 / 2013-12-04
2
16
 
3
17
  ### Default updates
@@ -383,6 +397,9 @@ The initial release.
383
397
  [#265]: https://github.com/opscode/test-kitchen/issues/265
384
398
  [#266]: https://github.com/opscode/test-kitchen/issues/266
385
399
  [#272]: https://github.com/opscode/test-kitchen/issues/272
400
+ [#275]: https://github.com/opscode/test-kitchen/issues/275
401
+ [#276]: https://github.com/opscode/test-kitchen/issues/276
402
+ [#278]: https://github.com/opscode/test-kitchen/issues/278
386
403
  [@ChrisLundquist]: https://github.com/ChrisLundquist
387
404
  [@adamhjk]: https://github.com/adamhjk
388
405
  [@arangamani]: https://github.com/arangamani
@@ -419,4 +436,5 @@ The initial release.
419
436
  [@sethvargo]: https://github.com/sethvargo
420
437
  [@smith]: https://github.com/smith
421
438
  [@stevendanna]: https://github.com/stevendanna
422
- [@thommay]: https://github.com/thommay
439
+ [@thommay]: https://github.com/thommay
440
+ [@zts]: https://github.com/zts
@@ -181,12 +181,17 @@ module Kitchen
181
181
  end
182
182
 
183
183
  def local_suite_files
184
- glob = File.join(config[:test_base_path], config[:suite_name], "*/**/*")
184
+ base = File.join(config[:test_base_path], config[:suite_name])
185
+ glob = File.join(base, "*/**/*")
185
186
  Dir.glob(glob).reject do |f|
186
- f[/(data|data_bags|environments|nodes|roles)/] || File.directory?(f)
187
+ is_chef_data_dir?(base, f) || File.directory?(f)
187
188
  end
188
189
  end
189
190
 
191
+ def is_chef_data_dir?(base, file)
192
+ file =~ %r[^#{base}/(data|data_bags|environments|nodes|roles)/]
193
+ end
194
+
190
195
  def helper_files
191
196
  Dir.glob(File.join(config[:test_base_path], "helpers", "*/**/*"))
192
197
  end
@@ -85,6 +85,7 @@ module Kitchen
85
85
  opts = Hash.new
86
86
  opts[:user_known_hosts_file] = "/dev/null"
87
87
  opts[:paranoid] = false
88
+ opts[:keys_only] = true if combined[:ssh_key]
88
89
  opts[:password] = combined[:password] if combined[:password]
89
90
  opts[:forward_agent] = combined[:forward_agent] if combined.key? :forward_agent
90
91
  opts[:port] = combined[:port] if combined[:port]
@@ -80,7 +80,8 @@ module Kitchen
80
80
  result[:local_config] =
81
81
  { :filename => local_config_file, :raw_data => local_yaml }
82
82
  end
83
- result[:combined_config] = { :raw_data => combined_hash }
83
+ combined = begin ; combined_hash ; rescue => e ; failure_hash(e) ; end
84
+ result[:combined_config] = { :raw_data => combined }
84
85
  result
85
86
  end
86
87
 
@@ -91,8 +92,12 @@ module Kitchen
91
92
  end
92
93
 
93
94
  def combined_hash
94
- y = @process_local ? yaml.rmerge(local_yaml) : yaml
95
- @process_global ? y.rmerge(global_yaml) : y
95
+ y = if @process_local
96
+ normalize(yaml).rmerge(normalize(local_yaml))
97
+ else
98
+ normalize(yaml)
99
+ end
100
+ @process_global ? y.rmerge(normalize(global_yaml)) : y
96
101
  rescue NoMethodError
97
102
  raise UserError, "Error merging #{File.basename(config_file)} and" +
98
103
  "#{File.basename(local_config_file)}"
@@ -128,6 +133,40 @@ module Kitchen
128
133
  File.join(File.expand_path(ENV["HOME"]), ".kitchen", "config.yml")
129
134
  end
130
135
 
136
+ def failure_hash(e)
137
+ {
138
+ :error => {
139
+ :exception => e.inspect,
140
+ :message => e.message,
141
+ :backtrace => e.backtrace
142
+ }
143
+ }
144
+ end
145
+
146
+ def normalize(obj)
147
+ if obj.is_a?(Hash)
148
+ obj.inject(Hash.new) { |h, (k, v)| normalize_hash(h, k, v) ; h }
149
+ else
150
+ obj
151
+ end
152
+ end
153
+
154
+ def normalize_hash(hash, key, value)
155
+ case key
156
+ when "driver", "provisioner", "busser"
157
+ hash[key] = if value.nil?
158
+ Hash.new
159
+ elsif value.is_a?(String)
160
+ default_key = key == "busser" ? "version" : "name"
161
+ { default_key => value }
162
+ else
163
+ normalize(value)
164
+ end
165
+ else
166
+ hash[key] = normalize(value)
167
+ end
168
+ end
169
+
131
170
  def parse_yaml_string(string, file_name)
132
171
  return Hash.new if string.nil? || string.empty?
133
172
 
@@ -355,13 +355,16 @@ module Kitchen
355
355
  FileUtils.mkdir_p(tmpbooks_dir)
356
356
  FileUtils.cp_r(File.join(cookbooks_dir, "."), tmpbooks_dir)
357
357
 
358
+ cp_site_cookbooks if File.directory?(site_cookbooks_dir)
359
+ cp_this_cookbook if File.exists?(metadata_rb)
360
+ end
361
+
362
+ def cp_site_cookbooks
358
363
  info("Preparing site-cookbooks from project directory")
359
364
  debug("Using cookbooks from #{site_cookbooks_dir}")
360
365
 
361
366
  FileUtils.mkdir_p(tmpsitebooks_dir)
362
367
  FileUtils.cp_r(File.join(site_cookbooks_dir, "."), tmpsitebooks_dir)
363
-
364
- cp_this_cookbook if File.exists?(metadata_rb)
365
368
  end
366
369
 
367
370
  def cp_this_cookbook
data/lib/kitchen/ssh.rb CHANGED
@@ -92,6 +92,7 @@ module Kitchen
92
92
  def login_command
93
93
  args = %W{ -o UserKnownHostsFile=/dev/null }
94
94
  args += %W{ -o StrictHostKeyChecking=no }
95
+ args += %W{ -o IdentitiesOnly=yes } if options[:keys]
95
96
  args += %W{ -o LogLevel=#{logger.debug? ? "VERBOSE" : "ERROR"} }
96
97
  args += %W{ -o ForwardAgent=#{options[:forward_agent] ? "yes" : "no"} } if options.key? :forward_agent
97
98
  Array(options[:keys]).each { |ssh_key| args += %W{ -i #{ssh_key}} }
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Kitchen
20
20
 
21
- VERSION = "1.1.0"
21
+ VERSION = "1.1.1"
22
22
  end
@@ -130,6 +130,138 @@ describe Kitchen::Loader::YAML do
130
130
  loader.read.must_equal({ :common => { :thekey => 'kinda' } })
131
131
  end
132
132
 
133
+ NORMALIZED_KEYS = {
134
+ "driver" => "name",
135
+ "provisioner" => "name",
136
+ "busser" => "version"
137
+ }
138
+
139
+ NORMALIZED_KEYS.each do |key, default_key|
140
+
141
+ describe "normalizing #{key} config hashes" do
142
+
143
+ it "merges local with #{key} string value over yaml with hash value" do
144
+ stub_yaml!(".kitchen.yml", {
145
+ key => { 'dakey' => 'ya' }
146
+ })
147
+ stub_yaml!(".kitchen.local.yml", {
148
+ key => 'namey'
149
+ })
150
+
151
+ loader.read.must_equal({
152
+ key.to_sym => { default_key.to_sym => "namey", :dakey => 'ya' }
153
+ })
154
+ end
155
+
156
+ it "merges local with #{key} hash value over yaml with string value" do
157
+ stub_yaml!(".kitchen.yml", {
158
+ key => 'namey'
159
+ })
160
+ stub_yaml!(".kitchen.local.yml", {
161
+ key => { 'dakey' => 'ya' }
162
+ })
163
+
164
+ loader.read.must_equal({
165
+ key.to_sym => { default_key.to_sym => "namey", :dakey => 'ya' }
166
+ })
167
+ end
168
+
169
+ it "merges local with #{key} nil value over yaml with hash value" do
170
+ stub_yaml!(".kitchen.yml", {
171
+ key => { 'dakey' => 'ya' }
172
+ })
173
+ stub_yaml!(".kitchen.local.yml", {
174
+ key => nil
175
+ })
176
+
177
+ loader.read.must_equal({
178
+ key.to_sym => { :dakey => 'ya' }
179
+ })
180
+ end
181
+
182
+ it "merges local with #{key} hash value over yaml with nil value" do
183
+ stub_yaml!(".kitchen.yml", {
184
+ key => 'namey'
185
+ })
186
+ stub_yaml!(".kitchen.local.yml", {
187
+ key => nil
188
+ })
189
+
190
+ loader.read.must_equal({
191
+ key.to_sym => { default_key.to_sym => "namey" }
192
+ })
193
+ end
194
+
195
+ it "merges global with #{key} string value over yaml with hash value" do
196
+ stub_yaml!(".kitchen.yml", {
197
+ key => { 'dakey' => 'ya' }
198
+ })
199
+ stub_global!({
200
+ key => 'namey'
201
+ })
202
+
203
+ loader.read.must_equal({
204
+ key.to_sym => { default_key.to_sym => "namey", :dakey => 'ya' }
205
+ })
206
+ end
207
+
208
+ it "merges global with #{key} hash value over yaml with string value" do
209
+ stub_yaml!(".kitchen.yml", {
210
+ key => 'namey'
211
+ })
212
+ stub_global!({
213
+ key => { 'dakey' => 'ya' }
214
+ })
215
+
216
+ loader.read.must_equal({
217
+ key.to_sym => { default_key.to_sym => "namey", :dakey => 'ya' }
218
+ })
219
+ end
220
+
221
+ it "merges global with #{key} nil value over yaml with hash value" do
222
+ stub_yaml!(".kitchen.yml", {
223
+ key => { 'dakey' => 'ya' }
224
+ })
225
+ stub_global!({
226
+ key => nil
227
+ })
228
+
229
+ loader.read.must_equal({
230
+ key.to_sym => { :dakey => 'ya' }
231
+ })
232
+ end
233
+
234
+ it "merges global with #{key} hash value over yaml with nil value" do
235
+ stub_yaml!(".kitchen.yml", {
236
+ key => nil
237
+ })
238
+ stub_global!({
239
+ key => { 'dakey' => 'ya' }
240
+ })
241
+
242
+ loader.read.must_equal({
243
+ key.to_sym => { :dakey => 'ya' }
244
+ })
245
+ end
246
+
247
+ it "merges global, local, over yaml with mixed hash, string, nil values" do
248
+ stub_yaml!(".kitchen.yml", {
249
+ key => nil
250
+ })
251
+ stub_yaml!(".kitchen.local.yml", {
252
+ key => "namey"
253
+ })
254
+ stub_global!({
255
+ key => { 'dakey' => 'ya' }
256
+ })
257
+
258
+ loader.read.must_equal({
259
+ key.to_sym => { default_key.to_sym => "namey", :dakey => 'ya' }
260
+ })
261
+ end
262
+ end
263
+ end
264
+
133
265
  it "handles a kitchen.local.yml with no yaml elements" do
134
266
  stub_yaml!(".kitchen.yml", {
135
267
  'a' => 'b'
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: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-05 00:00:00.000000000 Z
11
+ date: 2013-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout