test-kitchen 1.3.1 → 1.4.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cane +2 -0
- data/.gitignore +4 -0
- data/CHANGELOG.md +45 -0
- data/Rakefile +15 -0
- data/features/kitchen_action_commands.feature +12 -9
- data/features/kitchen_defaults.feature +38 -0
- data/features/kitchen_init_command.feature +0 -1
- data/features/kitchen_list_command.feature +2 -2
- data/features/kitchen_login_command.feature +7 -1
- data/features/kitchen_test_command.feature +4 -4
- data/lib/kitchen.rb +40 -11
- data/lib/kitchen/cli.rb +38 -22
- data/lib/kitchen/command/list.rb +5 -2
- data/lib/kitchen/config.rb +45 -18
- data/lib/kitchen/configurable.rb +137 -1
- data/lib/kitchen/data_munger.rb +248 -17
- data/lib/kitchen/driver.rb +1 -1
- data/lib/kitchen/driver/base.rb +1 -83
- data/lib/kitchen/driver/dummy.rb +0 -5
- data/lib/kitchen/driver/ssh_base.rb +177 -22
- data/lib/kitchen/instance.rb +140 -20
- data/lib/kitchen/logger.rb +43 -8
- data/lib/kitchen/login_command.rb +14 -5
- data/lib/kitchen/platform.rb +19 -0
- data/lib/kitchen/provisioner.rb +5 -3
- data/lib/kitchen/provisioner/base.rb +46 -48
- data/lib/kitchen/provisioner/chef/common_sandbox.rb +322 -0
- data/lib/kitchen/provisioner/chef_base.rb +179 -286
- data/lib/kitchen/provisioner/chef_solo.rb +11 -5
- data/lib/kitchen/provisioner/chef_zero.rb +108 -94
- data/lib/kitchen/provisioner/dummy.rb +47 -0
- data/lib/kitchen/provisioner/shell.rb +45 -12
- data/lib/kitchen/rake_tasks.rb +1 -1
- data/lib/kitchen/ssh.rb +1 -1
- data/lib/kitchen/thor_tasks.rb +1 -1
- data/lib/kitchen/transport.rb +54 -0
- data/lib/kitchen/transport/base.rb +146 -0
- data/lib/kitchen/transport/dummy.rb +75 -0
- data/lib/kitchen/transport/ssh.rb +325 -0
- data/lib/kitchen/transport/winrm.rb +508 -0
- data/lib/kitchen/transport/winrm/command_executor.rb +188 -0
- data/lib/kitchen/transport/winrm/file_transporter.rb +454 -0
- data/lib/kitchen/transport/winrm/logging.rb +50 -0
- data/lib/kitchen/transport/winrm/template.rb +74 -0
- data/lib/kitchen/transport/winrm/tmp_zip.rb +187 -0
- data/lib/kitchen/verifier.rb +55 -0
- data/lib/kitchen/verifier/base.rb +191 -0
- data/lib/kitchen/verifier/busser.rb +266 -0
- data/lib/kitchen/verifier/dummy.rb +75 -0
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/cli_spec.rb +56 -0
- data/spec/kitchen/config_spec.rb +61 -20
- data/spec/kitchen/configurable_spec.rb +327 -1
- data/spec/kitchen/data_munger_spec.rb +777 -14
- data/spec/kitchen/driver/base_spec.rb +7 -38
- data/spec/kitchen/driver/dummy_spec.rb +0 -29
- data/spec/kitchen/driver/ssh_base_spec.rb +580 -236
- data/spec/kitchen/driver_spec.rb +1 -0
- data/spec/kitchen/instance_spec.rb +383 -83
- data/spec/kitchen/login_command_spec.rb +29 -10
- data/spec/kitchen/platform_spec.rb +58 -2
- data/spec/kitchen/provisioner/base_spec.rb +170 -18
- data/spec/kitchen/provisioner/chef_base_spec.rb +454 -104
- data/spec/kitchen/provisioner/chef_solo_spec.rb +307 -104
- data/spec/kitchen/provisioner/chef_zero_spec.rb +561 -230
- data/spec/kitchen/provisioner/dummy_spec.rb +91 -0
- data/spec/kitchen/provisioner/shell_spec.rb +158 -56
- data/spec/kitchen/provisioner_spec.rb +37 -0
- data/spec/kitchen/ssh_spec.rb +19 -19
- data/spec/kitchen/transport/base_spec.rb +89 -0
- data/spec/kitchen/transport/ssh_spec.rb +1147 -0
- data/spec/kitchen/transport/winrm/command_executor_spec.rb +400 -0
- data/spec/kitchen/transport/winrm/file_transporter_spec.rb +876 -0
- data/spec/kitchen/transport/winrm/logging_spec.rb +92 -0
- data/spec/kitchen/transport/winrm/template_spec.rb +51 -0
- data/spec/kitchen/transport/winrm/tmp_zip_spec.rb +132 -0
- data/spec/kitchen/transport/winrm_spec.rb +1069 -0
- data/spec/kitchen/transport_spec.rb +112 -0
- data/spec/kitchen/verifier/base_spec.rb +310 -0
- data/spec/kitchen/verifier/busser_spec.rb +540 -0
- data/spec/kitchen/verifier/dummy_spec.rb +91 -0
- data/spec/kitchen/verifier_spec.rb +120 -0
- data/spec/kitchen_spec.rb +7 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/powershell_max_size_spec.rb +40 -0
- data/support/busser_install_command.ps1 +14 -0
- data/support/busser_install_command.sh +15 -0
- data/support/check_files.ps1.erb +48 -0
- data/support/chef_base_init_command.ps1 +18 -0
- data/support/chef_base_init_command.sh +2 -0
- data/support/chef_base_install_command.ps1 +76 -0
- data/support/chef_base_install_command.sh +137 -0
- data/support/chef_zero_prepare_command_legacy.ps1 +9 -0
- data/support/chef_zero_prepare_command_legacy.sh +10 -0
- data/support/decode_files.ps1.erb +61 -0
- data/test-kitchen.gemspec +2 -0
- metadata +97 -8
- data/lib/kitchen/busser.rb +0 -316
- data/spec/kitchen/busser_spec.rb +0 -490
- data/support/chef_helpers.sh +0 -16
data/spec/kitchen/driver_spec.rb
CHANGED
@@ -27,6 +27,8 @@ require "kitchen/platform"
|
|
27
27
|
require "kitchen/provisioner"
|
28
28
|
require "kitchen/provisioner/dummy"
|
29
29
|
require "kitchen/suite"
|
30
|
+
require "kitchen/transport/dummy"
|
31
|
+
require "kitchen/verifier/dummy"
|
30
32
|
|
31
33
|
class DummyStateFile
|
32
34
|
|
@@ -52,7 +54,7 @@ end
|
|
52
54
|
|
53
55
|
class SerialDummyDriver < Kitchen::Driver::Dummy
|
54
56
|
|
55
|
-
no_parallel_for :create, :
|
57
|
+
no_parallel_for :create, :destroy
|
56
58
|
|
57
59
|
attr_reader :action_in_mutex
|
58
60
|
|
@@ -66,24 +68,26 @@ class SerialDummyDriver < Kitchen::Driver::Dummy
|
|
66
68
|
super
|
67
69
|
end
|
68
70
|
|
69
|
-
def
|
70
|
-
track_locked(:
|
71
|
+
def destroy(state)
|
72
|
+
track_locked(:destroy)
|
71
73
|
super
|
72
74
|
end
|
75
|
+
end
|
73
76
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
+
class LegacyDriver < Kitchen::Driver::SSHBase
|
78
|
+
|
79
|
+
attr_reader :called_converge, :called_setup, :called_verify
|
80
|
+
|
81
|
+
def converge(_)
|
82
|
+
@called_converge
|
77
83
|
end
|
78
84
|
|
79
|
-
def
|
80
|
-
|
81
|
-
super
|
85
|
+
def setup(_)
|
86
|
+
@called_setup
|
82
87
|
end
|
83
88
|
|
84
|
-
def
|
85
|
-
|
86
|
-
super
|
89
|
+
def verify(_)
|
90
|
+
@called_verify
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
@@ -95,12 +99,13 @@ describe Kitchen::Instance do
|
|
95
99
|
let(:instance) { Kitchen::Instance.new(opts) }
|
96
100
|
let(:provisioner) { Kitchen::Provisioner::Dummy.new({}) }
|
97
101
|
let(:state_file) { DummyStateFile.new }
|
98
|
-
let(:
|
102
|
+
let(:transport) { Kitchen::Transport::Dummy.new({}) }
|
103
|
+
let(:verifier) { Kitchen::Verifier::Dummy.new({}) }
|
99
104
|
|
100
105
|
let(:opts) do
|
101
106
|
{ :suite => suite, :platform => platform, :driver => driver,
|
102
|
-
:provisioner => provisioner, :
|
103
|
-
:logger => logger, :state_file => state_file }
|
107
|
+
:provisioner => provisioner, :verifier => verifier,
|
108
|
+
:logger => logger, :state_file => state_file, :transport => transport }
|
104
109
|
end
|
105
110
|
|
106
111
|
def suite(name = "suite")
|
@@ -234,16 +239,38 @@ describe Kitchen::Instance do
|
|
234
239
|
end
|
235
240
|
end
|
236
241
|
|
237
|
-
describe "#
|
242
|
+
describe "#transport" do
|
243
|
+
|
244
|
+
it "returns its transport" do
|
245
|
+
instance.transport.must_equal transport
|
246
|
+
end
|
247
|
+
|
248
|
+
it "raises an ArgumentError if missing" do
|
249
|
+
opts.delete(:transport)
|
250
|
+
proc { Kitchen::Instance.new(opts) }.must_raise Kitchen::ClientError
|
251
|
+
end
|
252
|
+
|
253
|
+
it "sets Transport#instance to itself" do
|
254
|
+
# it's mind-bottling
|
255
|
+
instance.transport.instance.must_equal instance
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
describe "#verifier" do
|
238
260
|
|
239
|
-
it "returns its
|
240
|
-
instance.
|
261
|
+
it "returns its verifier" do
|
262
|
+
instance.verifier.must_equal verifier
|
241
263
|
end
|
242
264
|
|
243
265
|
it "raises and ArgumentError if missing" do
|
244
|
-
opts.delete(:
|
266
|
+
opts.delete(:verifier)
|
245
267
|
proc { Kitchen::Instance.new(opts) }.must_raise Kitchen::ClientError
|
246
268
|
end
|
269
|
+
|
270
|
+
it "sets Verifier#instance to itself" do
|
271
|
+
# it's mind-bottling
|
272
|
+
instance.verifier.instance.must_equal instance
|
273
|
+
end
|
247
274
|
end
|
248
275
|
|
249
276
|
describe "#state_file" do
|
@@ -262,10 +289,13 @@ describe Kitchen::Instance do
|
|
262
289
|
instance.to_str.must_equal "<suite-platform>"
|
263
290
|
end
|
264
291
|
|
265
|
-
it "#login executes the
|
292
|
+
it "#login executes the transport's login_command" do
|
293
|
+
conn = stub("connection")
|
266
294
|
state_file.write(:last_action => "create")
|
267
|
-
|
268
|
-
returns(
|
295
|
+
transport.stubs(:connection).with(:last_action => "create").
|
296
|
+
returns(conn)
|
297
|
+
conn.stubs(:login_command).
|
298
|
+
returns(Kitchen::LoginCommand.new("echo", ["hello"], :purple => true))
|
269
299
|
Kernel.expects(:exec).with("echo", "hello", :purple => true)
|
270
300
|
|
271
301
|
instance.login
|
@@ -283,6 +313,20 @@ describe Kitchen::Instance do
|
|
283
313
|
instance.diagnose.must_be_instance_of Hash
|
284
314
|
end
|
285
315
|
|
316
|
+
it "sets :platform key to platform's diagnose info" do
|
317
|
+
platform.stubs(:diagnose).returns(:a => "b")
|
318
|
+
|
319
|
+
instance.diagnose[:platform].must_equal(:a => "b")
|
320
|
+
end
|
321
|
+
|
322
|
+
it "sets :platform key to :unknown if obj can't respond to #diagnose" do
|
323
|
+
opts[:platform] = Class.new(platform.class) {
|
324
|
+
undef_method :diagnose
|
325
|
+
}.new(:name => "whoop")
|
326
|
+
|
327
|
+
instance.diagnose[:platform].must_equal :unknown
|
328
|
+
end
|
329
|
+
|
286
330
|
it "sets :state_file key to state_file's diganose info" do
|
287
331
|
state_file.stubs(:diagnose).returns(:a => "b")
|
288
332
|
|
@@ -311,18 +355,32 @@ describe Kitchen::Instance do
|
|
311
355
|
instance.diagnose[:provisioner].must_equal :unknown
|
312
356
|
end
|
313
357
|
|
314
|
-
it "sets :
|
315
|
-
|
358
|
+
it "sets :verifier key to verifier's diganose info" do
|
359
|
+
verifier.stubs(:diagnose).returns(:a => "b")
|
360
|
+
|
361
|
+
instance.diagnose[:verifier].must_equal(:a => "b")
|
362
|
+
end
|
363
|
+
|
364
|
+
it "sets :verifier key to :unknown if obj can't respond to #diagnose" do
|
365
|
+
opts[:verifier] = Class.new(verifier.class) {
|
366
|
+
undef_method :diagnose
|
367
|
+
}.new({})
|
368
|
+
|
369
|
+
instance.diagnose[:verifier].must_equal :unknown
|
370
|
+
end
|
371
|
+
|
372
|
+
it "sets :transport key to transport's diganose info" do
|
373
|
+
transport.stubs(:diagnose).returns(:a => "b")
|
316
374
|
|
317
|
-
instance.diagnose[:
|
375
|
+
instance.diagnose[:transport].must_equal(:a => "b")
|
318
376
|
end
|
319
377
|
|
320
|
-
it "sets :
|
321
|
-
opts[:
|
378
|
+
it "sets :transport key to :unknown if obj can't respond to #diagnose" do
|
379
|
+
opts[:transport] = Class.new(transport.class) {
|
322
380
|
undef_method :diagnose
|
323
|
-
}.new
|
381
|
+
}.new
|
324
382
|
|
325
|
-
instance.diagnose[:
|
383
|
+
instance.diagnose[:transport].must_equal :unknown
|
326
384
|
end
|
327
385
|
end
|
328
386
|
|
@@ -382,9 +440,9 @@ describe Kitchen::Instance do
|
|
382
440
|
|
383
441
|
describe "with no state" do
|
384
442
|
|
385
|
-
it "calls Driver#create and
|
443
|
+
it "calls Driver#create and Provisioner#call with empty state hash" do
|
386
444
|
driver.expects(:create).with(Hash.new)
|
387
|
-
|
445
|
+
provisioner.expects(:call).
|
388
446
|
with { |state| state[:last_action] == "create" }
|
389
447
|
|
390
448
|
instance.converge
|
@@ -414,8 +472,8 @@ describe Kitchen::Instance do
|
|
414
472
|
|
415
473
|
before { state_file.write(:last_action => "create") }
|
416
474
|
|
417
|
-
it "calls
|
418
|
-
|
475
|
+
it "calls Provisioner#call with state hash" do
|
476
|
+
provisioner.expects(:call).
|
419
477
|
with { |state| state[:last_action] == "create" }
|
420
478
|
|
421
479
|
instance.converge
|
@@ -432,8 +490,8 @@ describe Kitchen::Instance do
|
|
432
490
|
|
433
491
|
before { state_file.write(:last_action => "converge") }
|
434
492
|
|
435
|
-
it "calls
|
436
|
-
|
493
|
+
it "calls Provisioner#call with state hash" do
|
494
|
+
provisioner.expects(:call).
|
437
495
|
with { |state| state[:last_action] == "converge" }
|
438
496
|
|
439
497
|
instance.converge
|
@@ -451,12 +509,13 @@ describe Kitchen::Instance do
|
|
451
509
|
|
452
510
|
describe "with no state" do
|
453
511
|
|
454
|
-
it "calls
|
512
|
+
it "calls create and converge with empty state hash" do
|
455
513
|
driver.expects(:create).with(Hash.new)
|
456
|
-
|
514
|
+
provisioner.expects(:call).
|
457
515
|
with { |state| state[:last_action] == "create" }
|
458
516
|
driver.expects(:setup).
|
459
|
-
with { |state| state[:last_action] == "converge" }
|
517
|
+
with { |state| state[:last_action] == "converge" }.
|
518
|
+
never
|
460
519
|
|
461
520
|
instance.setup
|
462
521
|
end
|
@@ -485,11 +544,12 @@ describe Kitchen::Instance do
|
|
485
544
|
|
486
545
|
before { state_file.write(:last_action => "create") }
|
487
546
|
|
488
|
-
it "calls
|
489
|
-
|
547
|
+
it "calls Provisioner#call with state hash" do
|
548
|
+
provisioner.expects(:call).
|
490
549
|
with { |state| state[:last_action] == "create" }
|
491
550
|
driver.expects(:setup).
|
492
|
-
with { |state| state[:last_action] == "converge" }
|
551
|
+
with { |state| state[:last_action] == "converge" }.
|
552
|
+
never
|
493
553
|
|
494
554
|
instance.setup
|
495
555
|
end
|
@@ -505,9 +565,10 @@ describe Kitchen::Instance do
|
|
505
565
|
|
506
566
|
before { state_file.write(:last_action => "converge") }
|
507
567
|
|
508
|
-
it "calls
|
568
|
+
it "calls nothing with state hash" do
|
509
569
|
driver.expects(:setup).
|
510
|
-
with { |state| state[:last_action] == "converge" }
|
570
|
+
with { |state| state[:last_action] == "converge" }.
|
571
|
+
never
|
511
572
|
|
512
573
|
instance.setup
|
513
574
|
end
|
@@ -523,9 +584,10 @@ describe Kitchen::Instance do
|
|
523
584
|
|
524
585
|
before { state_file.write(:last_action => "setup") }
|
525
586
|
|
526
|
-
it "calls
|
587
|
+
it "calls nothing with state hash" do
|
527
588
|
driver.expects(:setup).
|
528
|
-
with { |state| state[:last_action] == "setup" }
|
589
|
+
with { |state| state[:last_action] == "setup" }.
|
590
|
+
never
|
529
591
|
|
530
592
|
instance.setup
|
531
593
|
end
|
@@ -542,13 +604,14 @@ describe Kitchen::Instance do
|
|
542
604
|
|
543
605
|
describe "with no state" do
|
544
606
|
|
545
|
-
it "calls
|
607
|
+
it "calls create, converge, and verify with empty state hash" do
|
546
608
|
driver.expects(:create).with(Hash.new)
|
547
|
-
|
609
|
+
provisioner.expects(:call).
|
548
610
|
with { |state| state[:last_action] == "create" }
|
549
611
|
driver.expects(:setup).
|
550
|
-
with { |state| state[:last_action] == "converge" }
|
551
|
-
|
612
|
+
with { |state| state[:last_action] == "converge" }.
|
613
|
+
never
|
614
|
+
verifier.expects(:call).
|
552
615
|
with { |state| state[:last_action] == "setup" }
|
553
616
|
|
554
617
|
instance.verify
|
@@ -578,12 +641,13 @@ describe Kitchen::Instance do
|
|
578
641
|
|
579
642
|
before { state_file.write(:last_action => "create") }
|
580
643
|
|
581
|
-
it "calls
|
582
|
-
|
644
|
+
it "calls converge, and verify with state hash" do
|
645
|
+
provisioner.expects(:call).
|
583
646
|
with { |state| state[:last_action] == "create" }
|
584
647
|
driver.expects(:setup).
|
585
|
-
with { |state| state[:last_action] == "converge" }
|
586
|
-
|
648
|
+
with { |state| state[:last_action] == "converge" }.
|
649
|
+
never
|
650
|
+
verifier.expects(:call).
|
587
651
|
with { |state| state[:last_action] == "setup" }
|
588
652
|
|
589
653
|
instance.verify
|
@@ -600,10 +664,11 @@ describe Kitchen::Instance do
|
|
600
664
|
|
601
665
|
before { state_file.write(:last_action => "converge") }
|
602
666
|
|
603
|
-
it "calls
|
667
|
+
it "calls Verifier#call with state hash" do
|
604
668
|
driver.expects(:setup).
|
605
|
-
with { |state| state[:last_action] == "converge" }
|
606
|
-
|
669
|
+
with { |state| state[:last_action] == "converge" }.
|
670
|
+
never
|
671
|
+
verifier.expects(:call).
|
607
672
|
with { |state| state[:last_action] == "setup" }
|
608
673
|
|
609
674
|
instance.verify
|
@@ -620,8 +685,8 @@ describe Kitchen::Instance do
|
|
620
685
|
|
621
686
|
before { state_file.write(:last_action => "setup") }
|
622
687
|
|
623
|
-
it "calls
|
624
|
-
|
688
|
+
it "calls Verifier#call with state hash" do
|
689
|
+
verifier.expects(:call).
|
625
690
|
with { |state| state[:last_action] == "setup" }
|
626
691
|
|
627
692
|
instance.verify
|
@@ -638,8 +703,8 @@ describe Kitchen::Instance do
|
|
638
703
|
|
639
704
|
before { state_file.write(:last_action => "verify") }
|
640
705
|
|
641
|
-
it "calls
|
642
|
-
|
706
|
+
it "calls Verifier#call with state hash" do
|
707
|
+
verifier.expects(:call).
|
643
708
|
with { |state| state[:last_action] == "verify" }
|
644
709
|
|
645
710
|
instance.verify
|
@@ -710,12 +775,11 @@ describe Kitchen::Instance do
|
|
710
775
|
|
711
776
|
describe "with no state" do
|
712
777
|
|
713
|
-
it "calls
|
778
|
+
it "calls destroy, create, converge, setup, verify, destroy" do
|
714
779
|
driver.expects(:destroy)
|
715
780
|
driver.expects(:create)
|
716
|
-
|
717
|
-
|
718
|
-
driver.expects(:verify)
|
781
|
+
provisioner.expects(:call)
|
782
|
+
verifier.expects(:call)
|
719
783
|
driver.expects(:destroy)
|
720
784
|
|
721
785
|
instance.test
|
@@ -741,12 +805,11 @@ describe Kitchen::Instance do
|
|
741
805
|
|
742
806
|
before { state_file.write(:last_action => action) }
|
743
807
|
|
744
|
-
it "calls
|
808
|
+
it "calls destroy, create, converge, setup, verify, destroy" do
|
745
809
|
driver.expects(:destroy)
|
746
810
|
driver.expects(:create)
|
747
|
-
|
748
|
-
|
749
|
-
driver.expects(:verify)
|
811
|
+
provisioner.expects(:call)
|
812
|
+
verifier.expects(:call)
|
750
813
|
driver.expects(:destroy)
|
751
814
|
|
752
815
|
instance.test
|
@@ -756,12 +819,11 @@ describe Kitchen::Instance do
|
|
756
819
|
|
757
820
|
describe "with destroy mode of never" do
|
758
821
|
|
759
|
-
it "calls
|
822
|
+
it "calls destroy, create, converge, setup, verify" do
|
760
823
|
driver.expects(:destroy).once
|
761
824
|
driver.expects(:create)
|
762
|
-
|
763
|
-
|
764
|
-
driver.expects(:verify)
|
825
|
+
provisioner.expects(:call)
|
826
|
+
verifier.expects(:call)
|
765
827
|
|
766
828
|
instance.test(:never)
|
767
829
|
end
|
@@ -769,10 +831,10 @@ describe Kitchen::Instance do
|
|
769
831
|
|
770
832
|
describe "with destroy mode of always" do
|
771
833
|
|
772
|
-
it "calls
|
834
|
+
it "calls destroy at even when action fails" do
|
773
835
|
driver.expects(:destroy)
|
774
836
|
driver.expects(:create)
|
775
|
-
|
837
|
+
provisioner.expects(:call).raises(Kitchen::ActionFailed)
|
776
838
|
driver.expects(:destroy)
|
777
839
|
|
778
840
|
begin
|
@@ -801,11 +863,10 @@ describe Kitchen::Instance do
|
|
801
863
|
|
802
864
|
before { state_file.write(:last_action => "create") }
|
803
865
|
|
804
|
-
it "calls
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
end
|
866
|
+
it "calls Transport#execute with command" do
|
867
|
+
connection = mock("connection")
|
868
|
+
connection.expects(:execute).with("uptime")
|
869
|
+
transport.stubs(:connection).yields(connection)
|
809
870
|
|
810
871
|
instance.remote_exec("uptime")
|
811
872
|
end
|
@@ -901,7 +962,7 @@ describe Kitchen::Instance do
|
|
901
962
|
describe "crashes preserve last action for desired verify action" do
|
902
963
|
|
903
964
|
before do
|
904
|
-
|
965
|
+
verifier.stubs(:call).raises(Kitchen::ActionFailed, "death")
|
905
966
|
end
|
906
967
|
|
907
968
|
[:create, :converge, :setup].each do |action|
|
@@ -938,12 +999,251 @@ describe Kitchen::Instance do
|
|
938
999
|
instance.test
|
939
1000
|
|
940
1001
|
driver.action_in_mutex[:create].must_equal true
|
941
|
-
driver.action_in_mutex[:converge].must_equal false
|
942
|
-
driver.action_in_mutex[:setup].must_equal false
|
943
|
-
driver.action_in_mutex[:verify].must_equal true
|
944
1002
|
driver.action_in_mutex[:destroy].must_equal true
|
945
1003
|
end
|
946
1004
|
end
|
1005
|
+
|
1006
|
+
describe "with legacy Driver::SSHBase subclasses" do
|
1007
|
+
|
1008
|
+
let(:driver) { LegacyDriver.new({}) }
|
1009
|
+
|
1010
|
+
describe "#converge" do
|
1011
|
+
|
1012
|
+
describe "with no state" do
|
1013
|
+
|
1014
|
+
it "calls Driver#create and Driver#converge with empty state hash" do
|
1015
|
+
driver.expects(:create).with(Hash.new)
|
1016
|
+
driver.expects(:converge).
|
1017
|
+
with { |state| state[:last_action] == "create" }
|
1018
|
+
|
1019
|
+
instance.converge
|
1020
|
+
end
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
describe "with last action of create" do
|
1024
|
+
|
1025
|
+
before { state_file.write(:last_action => "create") }
|
1026
|
+
|
1027
|
+
it "calls Driver#converge with state hash" do
|
1028
|
+
driver.expects(:converge).
|
1029
|
+
with { |state| state[:last_action] == "create" }
|
1030
|
+
|
1031
|
+
instance.converge
|
1032
|
+
end
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
describe "with last action of converge" do
|
1036
|
+
|
1037
|
+
before { state_file.write(:last_action => "converge") }
|
1038
|
+
|
1039
|
+
it "calls Driver#converge with state hash" do
|
1040
|
+
driver.expects(:converge).
|
1041
|
+
with { |state| state[:last_action] == "converge" }
|
1042
|
+
|
1043
|
+
instance.converge
|
1044
|
+
end
|
1045
|
+
end
|
1046
|
+
end
|
1047
|
+
|
1048
|
+
describe "#setup" do
|
1049
|
+
|
1050
|
+
describe "with no state" do
|
1051
|
+
|
1052
|
+
it "calls create, converge, and setup with empty state hash" do
|
1053
|
+
driver.expects(:create).with(Hash.new)
|
1054
|
+
driver.expects(:converge).
|
1055
|
+
with { |state| state[:last_action] == "create" }
|
1056
|
+
driver.expects(:setup).
|
1057
|
+
with { |state| state[:last_action] == "converge" }
|
1058
|
+
|
1059
|
+
instance.setup
|
1060
|
+
end
|
1061
|
+
end
|
1062
|
+
|
1063
|
+
describe "with last action of create" do
|
1064
|
+
|
1065
|
+
before { state_file.write(:last_action => "create") }
|
1066
|
+
|
1067
|
+
it "calls Provisioner#call and setup with state hash" do
|
1068
|
+
driver.expects(:converge).
|
1069
|
+
with { |state| state[:last_action] == "create" }
|
1070
|
+
driver.expects(:setup).
|
1071
|
+
with { |state| state[:last_action] == "converge" }
|
1072
|
+
|
1073
|
+
instance.setup
|
1074
|
+
end
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
describe "with last action of converge" do
|
1078
|
+
|
1079
|
+
before { state_file.write(:last_action => "converge") }
|
1080
|
+
|
1081
|
+
it "calls Driver#setup with state hash" do
|
1082
|
+
driver.expects(:setup).
|
1083
|
+
with { |state| state[:last_action] == "converge" }
|
1084
|
+
|
1085
|
+
instance.setup
|
1086
|
+
end
|
1087
|
+
end
|
1088
|
+
|
1089
|
+
describe "with last action of setup" do
|
1090
|
+
|
1091
|
+
before { state_file.write(:last_action => "setup") }
|
1092
|
+
|
1093
|
+
it "calls Driver#setup with state hash" do
|
1094
|
+
driver.expects(:setup).
|
1095
|
+
with { |state| state[:last_action] == "setup" }
|
1096
|
+
|
1097
|
+
instance.setup
|
1098
|
+
end
|
1099
|
+
end
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
describe "#verify" do
|
1103
|
+
|
1104
|
+
describe "with no state" do
|
1105
|
+
|
1106
|
+
it "calls create, converge, setup, and verify with empty state hash" do
|
1107
|
+
driver.expects(:create).with(Hash.new)
|
1108
|
+
driver.expects(:converge).
|
1109
|
+
with { |state| state[:last_action] == "create" }
|
1110
|
+
driver.expects(:setup).
|
1111
|
+
with { |state| state[:last_action] == "converge" }
|
1112
|
+
driver.expects(:verify).
|
1113
|
+
with { |state| state[:last_action] == "setup" }
|
1114
|
+
|
1115
|
+
instance.verify
|
1116
|
+
end
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
describe "with last of create" do
|
1120
|
+
|
1121
|
+
before { state_file.write(:last_action => "create") }
|
1122
|
+
|
1123
|
+
it "calls converge, setup, and verify with state hash" do
|
1124
|
+
driver.expects(:converge).
|
1125
|
+
with { |state| state[:last_action] == "create" }
|
1126
|
+
driver.expects(:setup).
|
1127
|
+
with { |state| state[:last_action] == "converge" }
|
1128
|
+
driver.expects(:verify).
|
1129
|
+
with { |state| state[:last_action] == "setup" }
|
1130
|
+
|
1131
|
+
instance.verify
|
1132
|
+
end
|
1133
|
+
end
|
1134
|
+
|
1135
|
+
describe "with last of converge" do
|
1136
|
+
|
1137
|
+
before { state_file.write(:last_action => "converge") }
|
1138
|
+
|
1139
|
+
it "calls Driver#setup, and verify with state hash" do
|
1140
|
+
driver.expects(:setup).
|
1141
|
+
with { |state| state[:last_action] == "converge" }
|
1142
|
+
driver.expects(:verify).
|
1143
|
+
with { |state| state[:last_action] == "setup" }
|
1144
|
+
|
1145
|
+
instance.verify
|
1146
|
+
end
|
1147
|
+
end
|
1148
|
+
|
1149
|
+
describe "with last of setup" do
|
1150
|
+
|
1151
|
+
before { state_file.write(:last_action => "setup") }
|
1152
|
+
|
1153
|
+
it "calls Driver#verify with state hash" do
|
1154
|
+
driver.expects(:verify).
|
1155
|
+
with { |state| state[:last_action] == "setup" }
|
1156
|
+
|
1157
|
+
instance.verify
|
1158
|
+
end
|
1159
|
+
end
|
1160
|
+
|
1161
|
+
describe "with last of verify" do
|
1162
|
+
|
1163
|
+
before { state_file.write(:last_action => "verify") }
|
1164
|
+
|
1165
|
+
it "calls Driver#verify with state hash" do
|
1166
|
+
driver.expects(:verify).
|
1167
|
+
with { |state| state[:last_action] == "verify" }
|
1168
|
+
|
1169
|
+
instance.verify
|
1170
|
+
end
|
1171
|
+
end
|
1172
|
+
end
|
1173
|
+
|
1174
|
+
describe "#test" do
|
1175
|
+
|
1176
|
+
describe "with no state" do
|
1177
|
+
|
1178
|
+
it "calls destroy, create, converge, setup, verify, destroy" do
|
1179
|
+
driver.expects(:destroy)
|
1180
|
+
driver.expects(:create)
|
1181
|
+
driver.expects(:converge)
|
1182
|
+
driver.expects(:setup)
|
1183
|
+
driver.expects(:verify)
|
1184
|
+
driver.expects(:destroy)
|
1185
|
+
|
1186
|
+
instance.test
|
1187
|
+
end
|
1188
|
+
end
|
1189
|
+
|
1190
|
+
[:create, :converge, :setup, :verify].each do |action|
|
1191
|
+
|
1192
|
+
describe "with last action of #{action}" do
|
1193
|
+
|
1194
|
+
before { state_file.write(:last_action => action) }
|
1195
|
+
|
1196
|
+
it "calls destroy, create, converge, setup, verify, destroy" do
|
1197
|
+
driver.expects(:destroy)
|
1198
|
+
driver.expects(:create)
|
1199
|
+
driver.expects(:converge)
|
1200
|
+
driver.expects(:setup)
|
1201
|
+
driver.expects(:verify)
|
1202
|
+
driver.expects(:destroy)
|
1203
|
+
|
1204
|
+
instance.test
|
1205
|
+
end
|
1206
|
+
end
|
1207
|
+
end
|
1208
|
+
|
1209
|
+
describe "with destroy mode of never" do
|
1210
|
+
|
1211
|
+
it "calls destroy, create, converge, setup, verify" do
|
1212
|
+
driver.expects(:destroy).once
|
1213
|
+
driver.expects(:create)
|
1214
|
+
driver.expects(:converge)
|
1215
|
+
driver.expects(:setup)
|
1216
|
+
driver.expects(:verify)
|
1217
|
+
|
1218
|
+
instance.test(:never)
|
1219
|
+
end
|
1220
|
+
end
|
1221
|
+
|
1222
|
+
describe "with destroy mode of always" do
|
1223
|
+
|
1224
|
+
it "calls destroy at even when action fails" do
|
1225
|
+
driver.expects(:destroy)
|
1226
|
+
driver.expects(:create)
|
1227
|
+
driver.expects(:converge).raises(Kitchen::ActionFailed)
|
1228
|
+
driver.expects(:destroy)
|
1229
|
+
|
1230
|
+
begin
|
1231
|
+
instance.test(:always)
|
1232
|
+
rescue # rubocop:disable Lint/HandleExceptions
|
1233
|
+
end
|
1234
|
+
end
|
1235
|
+
end
|
1236
|
+
end
|
1237
|
+
|
1238
|
+
it "#login executes the driver's login_command" do
|
1239
|
+
state_file.write(:last_action => "create")
|
1240
|
+
driver.stubs(:login_command).with(:last_action => "create").
|
1241
|
+
returns(Kitchen::LoginCommand.new("echo", ["hello"], :purple => true))
|
1242
|
+
Kernel.expects(:exec).with("echo", "hello", :purple => true)
|
1243
|
+
|
1244
|
+
instance.login
|
1245
|
+
end
|
1246
|
+
end
|
947
1247
|
end
|
948
1248
|
|
949
1249
|
describe Kitchen::Instance::FSM do
|