test-kitchen 1.4.0.beta.2 → 1.4.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -0
- data/features/kitchen_diagnose_command.feature +32 -0
- data/lib/kitchen/cli.rb +3 -0
- data/lib/kitchen/command/diagnose.rb +6 -1
- data/lib/kitchen/configurable.rb +48 -1
- data/lib/kitchen/diagnostic.rb +29 -0
- data/lib/kitchen/driver/base.rb +25 -0
- data/lib/kitchen/driver/dummy.rb +4 -0
- data/lib/kitchen/driver/proxy.rb +3 -0
- data/lib/kitchen/instance.rb +17 -0
- data/lib/kitchen/provisioner/base.rb +30 -1
- data/lib/kitchen/provisioner/chef_base.rb +7 -3
- data/lib/kitchen/provisioner/chef_solo.rb +4 -0
- data/lib/kitchen/provisioner/chef_zero.rb +5 -1
- data/lib/kitchen/provisioner/dummy.rb +4 -0
- data/lib/kitchen/provisioner/shell.rb +5 -0
- data/lib/kitchen/shell_out.rb +6 -2
- data/lib/kitchen/transport/base.rb +25 -0
- data/lib/kitchen/transport/dummy.rb +4 -0
- data/lib/kitchen/transport/ssh.rb +22 -1
- data/lib/kitchen/transport/winrm.rb +61 -90
- data/lib/kitchen/verifier/base.rb +30 -1
- data/lib/kitchen/verifier/busser.rb +4 -0
- data/lib/kitchen/verifier/dummy.rb +4 -0
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/configurable_spec.rb +35 -0
- data/spec/kitchen/diagnostic_spec.rb +53 -3
- data/spec/kitchen/driver/dummy_spec.rb +8 -0
- data/spec/kitchen/driver/proxy_spec.rb +4 -0
- data/spec/kitchen/driver/ssh_base_spec.rb +4 -0
- data/spec/kitchen/instance_spec.rb +75 -0
- data/spec/kitchen/provisioner/base_spec.rb +32 -6
- data/spec/kitchen/provisioner/chef_base_spec.rb +3 -2
- data/spec/kitchen/provisioner/chef_solo_spec.rb +10 -2
- data/spec/kitchen/provisioner/chef_zero_spec.rb +24 -2
- data/spec/kitchen/provisioner/dummy_spec.rb +8 -0
- data/spec/kitchen/provisioner/shell_spec.rb +10 -0
- data/spec/kitchen/shell_out_spec.rb +7 -0
- data/spec/kitchen/transport/ssh_spec.rb +90 -1
- data/spec/kitchen/transport/winrm_spec.rb +91 -11
- data/spec/kitchen/verifier/base_spec.rb +32 -6
- data/spec/kitchen/verifier/busser_spec.rb +8 -0
- data/spec/kitchen/verifier/dummy_spec.rb +8 -0
- data/support/chef_base_install_command.sh +183 -100
- data/test-kitchen.gemspec +1 -2
- metadata +11 -48
- data/lib/kitchen/transport/winrm/command_executor.rb +0 -188
- data/lib/kitchen/transport/winrm/file_transporter.rb +0 -454
- data/lib/kitchen/transport/winrm/logging.rb +0 -50
- data/lib/kitchen/transport/winrm/template.rb +0 -74
- data/lib/kitchen/transport/winrm/tmp_zip.rb +0 -187
- data/spec/kitchen/transport/winrm/command_executor_spec.rb +0 -400
- data/spec/kitchen/transport/winrm/file_transporter_spec.rb +0 -876
- data/spec/kitchen/transport/winrm/logging_spec.rb +0 -92
- data/spec/kitchen/transport/winrm/template_spec.rb +0 -51
- data/spec/kitchen/transport/winrm/tmp_zip_spec.rb +0 -132
- data/support/check_files.ps1.erb +0 -48
- data/support/decode_files.ps1.erb +0 -62
@@ -32,6 +32,10 @@ module Kitchen
|
|
32
32
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
33
33
|
class Busser < Kitchen::Verifier::Base
|
34
34
|
|
35
|
+
kitchen_verifier_api_version 1
|
36
|
+
|
37
|
+
plugin_version Kitchen::VERSION
|
38
|
+
|
35
39
|
default_config :busser_bin do |verifier|
|
36
40
|
verifier.
|
37
41
|
remote_path_join(%W[#{verifier[:root_path]} bin busser]).
|
data/lib/kitchen/version.rb
CHANGED
@@ -39,6 +39,11 @@ module Kitchen
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
class Versioned < Tiny
|
43
|
+
|
44
|
+
plugin_version "1.8.17"
|
45
|
+
end
|
46
|
+
|
42
47
|
class StaticDefaults
|
43
48
|
|
44
49
|
include Kitchen::Configurable
|
@@ -339,6 +344,18 @@ describe Kitchen::Configurable do
|
|
339
344
|
|
340
345
|
subject[:complex_path].must_equal "/tmp/yo/self/complex"
|
341
346
|
end
|
347
|
+
|
348
|
+
it "leaves a nil config value as nil" do
|
349
|
+
config[:success_path] = nil
|
350
|
+
|
351
|
+
subject[:success_path].must_equal nil
|
352
|
+
end
|
353
|
+
|
354
|
+
it "leaves a false config value as false" do
|
355
|
+
config[:success_path] = false
|
356
|
+
|
357
|
+
subject[:success_path].must_equal false
|
358
|
+
end
|
342
359
|
end
|
343
360
|
|
344
361
|
describe "using inherited static expand_path_for statements" do
|
@@ -392,6 +409,24 @@ describe Kitchen::Configurable do
|
|
392
409
|
end
|
393
410
|
end
|
394
411
|
|
412
|
+
describe "#diagnose_plugin" do
|
413
|
+
|
414
|
+
it "returns a plugin hash for a plugin without version" do
|
415
|
+
subject.diagnose_plugin.must_equal(
|
416
|
+
:name => "Tiny", :class => "Kitchen::Thing::Tiny",
|
417
|
+
:version => nil, :api_version => nil
|
418
|
+
)
|
419
|
+
end
|
420
|
+
|
421
|
+
it "returns a plugin hash for a plugin with version" do
|
422
|
+
subject = Kitchen::Thing::Versioned.new(config).finalize_config!(instance)
|
423
|
+
subject.diagnose_plugin.must_equal(
|
424
|
+
:name => "Versioned", :class => "Kitchen::Thing::Versioned",
|
425
|
+
:version => "1.8.17", :api_version => nil
|
426
|
+
)
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
395
430
|
describe "#calculate_path" do
|
396
431
|
|
397
432
|
let(:config) do
|
@@ -28,8 +28,26 @@ describe Kitchen::Diagnostic do
|
|
28
28
|
|
29
29
|
let(:instances) do
|
30
30
|
[
|
31
|
-
stub(
|
32
|
-
|
31
|
+
stub(
|
32
|
+
:name => "i1",
|
33
|
+
:diagnose => { :stuff => "sup" },
|
34
|
+
:diagnose_plugins => {
|
35
|
+
:driver => { :name => "driva", :a => "b" },
|
36
|
+
:provisioner => { :name => "prov", :c => "d" },
|
37
|
+
:transport => { :name => "transa", :e => "f" },
|
38
|
+
:verifier => { :name => "verve", :g => "h" }
|
39
|
+
}
|
40
|
+
),
|
41
|
+
stub(
|
42
|
+
:name => "i2",
|
43
|
+
:diagnose => { :stuff => "yo" },
|
44
|
+
:diagnose_plugins => {
|
45
|
+
:driver => { :name => "driva", :a => "b" },
|
46
|
+
:provisioner => { :name => "presto", :i => "j" },
|
47
|
+
:transport => { :name => "tressa", :k => "l" },
|
48
|
+
:verifier => { :name => "verve", :g => "h" }
|
49
|
+
}
|
50
|
+
)
|
33
51
|
]
|
34
52
|
end
|
35
53
|
|
@@ -62,10 +80,42 @@ describe Kitchen::Diagnostic do
|
|
62
80
|
read["loader"].must_equal("error" => "damn")
|
63
81
|
end
|
64
82
|
|
65
|
-
it "#read returns
|
83
|
+
it "#read returns the unique set of plugins' diagnose hash if :plugins is set" do
|
84
|
+
Kitchen::Diagnostic.new(:instances => instances, :plugins => true).
|
85
|
+
read["plugins"].
|
86
|
+
must_equal(
|
87
|
+
"driver" => {
|
88
|
+
"driva" => { "a" => "b" }
|
89
|
+
},
|
90
|
+
"provisioner" => {
|
91
|
+
"prov" => { "c" => "d" },
|
92
|
+
"presto" => { "i" => "j" }
|
93
|
+
},
|
94
|
+
"transport" => {
|
95
|
+
"transa" => { "e" => "f" },
|
96
|
+
"tressa" => { "k" => "l" }
|
97
|
+
},
|
98
|
+
"verifier" => {
|
99
|
+
"verve" => { "g" => "h" }
|
100
|
+
}
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "#read returns an empty plugins hash if no instances were given" do
|
105
|
+
Kitchen::Diagnostic.new(:plugins => true).
|
106
|
+
read["plugins"].must_equal Hash.new
|
107
|
+
end
|
108
|
+
|
109
|
+
it "#read returns an empty instances hash if no instances were given" do
|
66
110
|
Kitchen::Diagnostic.new.read["instances"].must_equal Hash.new
|
67
111
|
end
|
68
112
|
|
113
|
+
it "#read returns an error hash for plugins if error hash is passed in" do
|
114
|
+
Kitchen::Diagnostic.new(
|
115
|
+
:instances => { :error => "shoot" }, :plugins => true
|
116
|
+
).read["plugins"].must_equal("error" => "shoot")
|
117
|
+
end
|
118
|
+
|
69
119
|
it "#read returns the instances' diganose hashes if instances are present" do
|
70
120
|
Kitchen::Diagnostic.new(:instances => instances).
|
71
121
|
read["instances"].
|
@@ -37,6 +37,14 @@ describe Kitchen::Driver::Dummy do
|
|
37
37
|
Kitchen::Driver::Dummy.new(config).finalize_config!(instance)
|
38
38
|
end
|
39
39
|
|
40
|
+
it "driver api_version is 2" do
|
41
|
+
driver.diagnose_plugin[:api_version].must_equal 2
|
42
|
+
end
|
43
|
+
|
44
|
+
it "plugin_version is set to Kitchen::VERSION" do
|
45
|
+
driver.diagnose_plugin[:version].must_equal Kitchen::VERSION
|
46
|
+
end
|
47
|
+
|
40
48
|
describe "default_config" do
|
41
49
|
|
42
50
|
it "sets :sleep to 0 by default" do
|
@@ -38,6 +38,10 @@ describe Kitchen::Driver::Proxy do
|
|
38
38
|
Kitchen::Driver::Proxy.new(config).finalize_config!(instance)
|
39
39
|
end
|
40
40
|
|
41
|
+
it "plugin_version is set to Kitchen::VERSION" do
|
42
|
+
driver.diagnose_plugin[:version].must_equal Kitchen::VERSION
|
43
|
+
end
|
44
|
+
|
41
45
|
describe "non-parallel action" do
|
42
46
|
|
43
47
|
it "create must be serially executed" do
|
@@ -109,6 +109,10 @@ describe Kitchen::Driver::SSHBase do
|
|
109
109
|
Kitchen::Driver::SSHBase.new(config).finalize_config!(instance)
|
110
110
|
end
|
111
111
|
|
112
|
+
it "plugin_version is not set" do
|
113
|
+
driver.diagnose_plugin[:version].must_equal nil
|
114
|
+
end
|
115
|
+
|
112
116
|
describe "configuration" do
|
113
117
|
|
114
118
|
it ":sudo defaults to true" do
|
@@ -384,6 +384,81 @@ describe Kitchen::Instance do
|
|
384
384
|
end
|
385
385
|
end
|
386
386
|
|
387
|
+
describe "#diagnose_plugins" do
|
388
|
+
|
389
|
+
it "returns a hash" do
|
390
|
+
instance.diagnose_plugins.must_be_instance_of Hash
|
391
|
+
end
|
392
|
+
|
393
|
+
it "sets :driver key to driver's plugin_diagnose info" do
|
394
|
+
driver.class.stubs(:diagnose).returns(:a => "b")
|
395
|
+
|
396
|
+
instance.diagnose_plugins[:driver].must_equal(
|
397
|
+
:name => "Dummy",
|
398
|
+
:a => "b"
|
399
|
+
)
|
400
|
+
end
|
401
|
+
|
402
|
+
it "sets :driver key to :unknown if class doesn't have #diagnose" do
|
403
|
+
opts[:driver] = Class.new(driver.class) {
|
404
|
+
undef_method :diagnose_plugin
|
405
|
+
}.new({})
|
406
|
+
|
407
|
+
instance.diagnose_plugins[:driver].must_equal(:unknown)
|
408
|
+
end
|
409
|
+
|
410
|
+
it "sets :provisioner key to provisioner's plugin_diagnose info" do
|
411
|
+
provisioner.class.stubs(:diagnose).returns(:a => "b")
|
412
|
+
|
413
|
+
instance.diagnose_plugins[:provisioner].must_equal(
|
414
|
+
:name => "Dummy",
|
415
|
+
:a => "b"
|
416
|
+
)
|
417
|
+
end
|
418
|
+
|
419
|
+
it "sets :provisioner key to :unknown if class doesn't have #diagnose" do
|
420
|
+
opts[:provisioner] = Class.new(driver.class) {
|
421
|
+
undef_method :diagnose_plugin
|
422
|
+
}.new({})
|
423
|
+
|
424
|
+
instance.diagnose_plugins[:provisioner].must_equal(:unknown)
|
425
|
+
end
|
426
|
+
|
427
|
+
it "sets :verifier key to verifier's plugin_diagnose info" do
|
428
|
+
verifier.class.stubs(:diagnose).returns(:a => "b")
|
429
|
+
|
430
|
+
instance.diagnose_plugins[:verifier].must_equal(
|
431
|
+
:name => "Dummy",
|
432
|
+
:a => "b"
|
433
|
+
)
|
434
|
+
end
|
435
|
+
|
436
|
+
it "sets :verifier key to :unknown if class doesn't have #diagnose" do
|
437
|
+
opts[:verifier] = Class.new(verifier.class) {
|
438
|
+
undef_method :diagnose_plugin
|
439
|
+
}.new({})
|
440
|
+
|
441
|
+
instance.diagnose_plugins[:verifier].must_equal(:unknown)
|
442
|
+
end
|
443
|
+
|
444
|
+
it "sets :transport key to transport's plugin_diagnose info" do
|
445
|
+
transport.class.stubs(:diagnose).returns(:a => "b")
|
446
|
+
|
447
|
+
instance.diagnose_plugins[:transport].must_equal(
|
448
|
+
:name => "Dummy",
|
449
|
+
:a => "b"
|
450
|
+
)
|
451
|
+
end
|
452
|
+
|
453
|
+
it "sets :transport key to :unknown if class doesn't have #diagnose" do
|
454
|
+
opts[:transport] = Class.new(transport.class) {
|
455
|
+
undef_method :diagnose_plugin
|
456
|
+
}.new({})
|
457
|
+
|
458
|
+
instance.diagnose_plugins[:transport].must_equal(:unknown)
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
387
462
|
describe "performing actions" do
|
388
463
|
|
389
464
|
describe "#create" do
|
@@ -101,6 +101,10 @@ describe Kitchen::Provisioner::Base do
|
|
101
101
|
it ":sudo defaults to true" do
|
102
102
|
provisioner[:sudo].must_equal true
|
103
103
|
end
|
104
|
+
|
105
|
+
it ":sudo_command defaults to sudo -E" do
|
106
|
+
provisioner[:sudo_command].must_equal "sudo -E"
|
107
|
+
end
|
104
108
|
end
|
105
109
|
|
106
110
|
describe "for windows operating systems" do
|
@@ -114,6 +118,10 @@ describe Kitchen::Provisioner::Base do
|
|
114
118
|
it ":sudo defaults to nil" do
|
115
119
|
provisioner[:sudo].must_equal nil
|
116
120
|
end
|
121
|
+
|
122
|
+
it ":sudo_command defaults to nil" do
|
123
|
+
provisioner[:sudo_command].must_equal nil
|
124
|
+
end
|
117
125
|
end
|
118
126
|
|
119
127
|
it ":http_proxy defaults to nil" do
|
@@ -287,16 +295,34 @@ describe Kitchen::Provisioner::Base do
|
|
287
295
|
|
288
296
|
describe "#sudo" do
|
289
297
|
|
290
|
-
|
291
|
-
|
298
|
+
describe "with :sudo set" do
|
299
|
+
|
300
|
+
before { config[:sudo] = true }
|
301
|
+
|
302
|
+
it "prepends sudo command" do
|
303
|
+
provisioner.send(:sudo, "wakka").must_equal("sudo -E wakka")
|
304
|
+
end
|
305
|
+
|
306
|
+
it "customizes sudo when :sudo_command is set" do
|
307
|
+
config[:sudo_command] = "blueto -Ohai"
|
292
308
|
|
293
|
-
|
309
|
+
provisioner.send(:sudo, "wakka").must_equal("blueto -Ohai wakka")
|
310
|
+
end
|
294
311
|
end
|
295
312
|
|
296
|
-
|
297
|
-
config[:sudo] = false
|
313
|
+
describe "with :sudo falsey" do
|
298
314
|
|
299
|
-
|
315
|
+
before { config[:sudo] = false }
|
316
|
+
|
317
|
+
it "does not include sudo command" do
|
318
|
+
provisioner.send(:sudo, "wakka").must_equal("wakka")
|
319
|
+
end
|
320
|
+
|
321
|
+
it "does not include sudo command, even when :sudo_command is set" do
|
322
|
+
config[:sudo_command] = "blueto -Ohai"
|
323
|
+
|
324
|
+
provisioner.send(:sudo, "wakka").must_equal("wakka")
|
325
|
+
end
|
300
326
|
end
|
301
327
|
end
|
302
328
|
end
|
@@ -529,7 +529,7 @@ describe Kitchen::Provisioner::ChefBase do
|
|
529
529
|
config[:root_path] = "/route"
|
530
530
|
dirs = %W[
|
531
531
|
/route/clients /route/cookbooks /route/data /route/data_bags
|
532
|
-
/route/environments /route/roles
|
532
|
+
/route/encrypted_data_bag_secret /route/environments /route/roles
|
533
533
|
].join(" ")
|
534
534
|
|
535
535
|
cmd.must_match regexify(%{dirs="#{dirs}"})
|
@@ -583,7 +583,8 @@ describe Kitchen::Provisioner::ChefBase do
|
|
583
583
|
config[:root_path] = "\\route"
|
584
584
|
dirs = %W[
|
585
585
|
"\\route\\clients" "\\route\\cookbooks" "\\route\\data"
|
586
|
-
"\\route\\data_bags" "\\route\\
|
586
|
+
"\\route\\data_bags" "\\route\\encrypted_data_bag_secret"
|
587
|
+
"\\route\\environments" "\\route\\roles"
|
587
588
|
].join(", ")
|
588
589
|
|
589
590
|
cmd.must_match regexify(%{$dirs = @(#{dirs})})
|
@@ -45,6 +45,14 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
45
45
|
Kitchen::Provisioner::ChefSolo.new(config).finalize_config!(instance)
|
46
46
|
end
|
47
47
|
|
48
|
+
it "provisioner api_version is 2" do
|
49
|
+
provisioner.diagnose_plugin[:api_version].must_equal 2
|
50
|
+
end
|
51
|
+
|
52
|
+
it "plugin_version is set to Kitchen::VERSION" do
|
53
|
+
provisioner.diagnose_plugin[:version].must_equal Kitchen::VERSION
|
54
|
+
end
|
55
|
+
|
48
56
|
describe "default config" do
|
49
57
|
|
50
58
|
describe "for unix operating systems" do
|
@@ -258,9 +266,9 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
258
266
|
file.must_include %{foo 7}
|
259
267
|
end
|
260
268
|
|
261
|
-
it "formats symbol values correctly" do
|
269
|
+
it "formats symbol-looking string values correctly" do
|
262
270
|
config[:solo_rb] = {
|
263
|
-
:foo => :bar
|
271
|
+
:foo => ":bar"
|
264
272
|
}
|
265
273
|
provisioner.create_sandbox
|
266
274
|
|
@@ -45,6 +45,14 @@ describe Kitchen::Provisioner::ChefZero do
|
|
45
45
|
Kitchen::Provisioner::ChefZero.new(config).finalize_config!(instance)
|
46
46
|
end
|
47
47
|
|
48
|
+
it "provisioner api_version is 2" do
|
49
|
+
provisioner.diagnose_plugin[:api_version].must_equal 2
|
50
|
+
end
|
51
|
+
|
52
|
+
it "plugin_version is set to Kitchen::VERSION" do
|
53
|
+
provisioner.diagnose_plugin[:version].must_equal Kitchen::VERSION
|
54
|
+
end
|
55
|
+
|
48
56
|
describe "default config" do
|
49
57
|
|
50
58
|
describe "for unix operating systems" do
|
@@ -283,9 +291,9 @@ describe Kitchen::Provisioner::ChefZero do
|
|
283
291
|
file.must_include %{foo 7}
|
284
292
|
end
|
285
293
|
|
286
|
-
it "formats symbol values correctly" do
|
294
|
+
it "formats symbol-looking string values correctly" do
|
287
295
|
config[:client_rb] = {
|
288
|
-
:foo => :bar
|
296
|
+
:foo => ":bar"
|
289
297
|
}
|
290
298
|
provisioner.create_sandbox
|
291
299
|
|
@@ -337,6 +345,20 @@ describe Kitchen::Provisioner::ChefZero do
|
|
337
345
|
|
338
346
|
sandbox_path("chef-client-zero.rb").file?.must_equal false
|
339
347
|
end
|
348
|
+
|
349
|
+
it "a version of '11' is still considered modern" do
|
350
|
+
config[:require_chef_omnibus] = "11"
|
351
|
+
provisioner.create_sandbox
|
352
|
+
|
353
|
+
sandbox_path("chef-client-zero.rb").file?.must_equal false
|
354
|
+
end
|
355
|
+
|
356
|
+
it "a version of 11 is still considered modern" do
|
357
|
+
config[:require_chef_omnibus] = 11
|
358
|
+
provisioner.create_sandbox
|
359
|
+
|
360
|
+
sandbox_path("chef-client-zero.rb").file?.must_equal false
|
361
|
+
end
|
340
362
|
end
|
341
363
|
|
342
364
|
describe "for old Chef versions" do
|
@@ -49,6 +49,14 @@ describe Kitchen::Provisioner::Dummy do
|
|
49
49
|
Kitchen::Provisioner::Dummy.new(config).finalize_config!(instance)
|
50
50
|
end
|
51
51
|
|
52
|
+
it "provisioner api_version is 2" do
|
53
|
+
provisioner.diagnose_plugin[:api_version].must_equal 2
|
54
|
+
end
|
55
|
+
|
56
|
+
it "plugin_version is set to Kitchen::VERSION" do
|
57
|
+
provisioner.diagnose_plugin[:version].must_equal Kitchen::VERSION
|
58
|
+
end
|
59
|
+
|
52
60
|
describe "configuration" do
|
53
61
|
|
54
62
|
it "sets :sleep to 0 by default" do
|