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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 882640379092b0732cc6d313bad0789817f6ad6a
|
4
|
+
data.tar.gz: 3bc38f11004420059c9674972e6f4205508b55bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 898fe17d662c7b9af006bd9b711a3e0305b2bebe8e1aaa5b2ea91ae8c9b73dc7f7ed7bcaa7721888e20a6cae1b90f79431033d4cefb079f88c1b7772dcd036cd
|
7
|
+
data.tar.gz: 7f8eff2f17d9796033dca9f6bc8e9f71fdddc7d3386d2c788573920cb4c0e297abc23e18958bfbd6de6d7f4b103bf64984f7a41ec485255a04e195b60417c65b
|
data/.cane
CHANGED
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
## 1.4.0.beta.1 / 2015-03-24
|
2
|
+
|
3
|
+
### Potentially breaking changes
|
4
|
+
|
5
|
+
**Note::** while a huge amount of effort has gone into preserving backwards compatibility, there could be issues when running this release using certain Drivers and Provisioners, especially ones that are deeply customized. Drivers that inherit directly from `Kitchen::Driver::Base` may need to be updated, while Driver that inherit directly from `Kitchen::Driver::SSHBase` should continue to operate as before. Other libraries/addons/plugins which patch internals of Test Kitchen's code may break or work differently and would be extremely hard to preserve while adding new functionality. Sadly, this is a tradeoff.
|
6
|
+
|
7
|
+
* Drivers are no longer responsible for `converge`, `setup`, `verify`, and `login` actions. The updated Driver API contract ([Driver::Base](https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/driver/base.rb)) only requires implementing the `#create` and `#destroy` methods, same as before. However, for Drivers that directly inherit from `Kitchen::Driver::Base`, any custom `#converge`, `#setup`, `#verify`, or `#login_command` methods will no longer be called. ([@fnichol][])
|
8
|
+
* Drivers which inherit directly from `Kitchen::Driver::SSHBase` are now considered "Legacy Drivers" as further improvements for these Drivers may not be available in future releases. The previous behavior is preserved, i.e. the Driver's `#converge`, `#setup`, and `#verify` methods are called and all methods signatures (and relative behavior) is preserved. ([Driver::SSHBase](https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/driver/ssh_base.rb), [Commit notes](https://github.com/test-kitchen/test-kitchen/commit/d816d6fd1bd21548b485ca91e0ff9303e99a6fbc)) ([@fnichol][])
|
9
|
+
* Provisioners are now self-aware, completely owning the `converge` action. The original public methods of the Base Provisioner are maintained but are now invoked with a `#call(state)` method on the Provisioner object. Provisioner authors may elect to implement the command and sandbox methods, or re-implement the `#call` method which may not call any of the previously mentioned methods. ([Provisioner::Base](https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/provisioner/base.rb), [Commit notes](https://github.com/test-kitchen/test-kitchen/commit/3196675e519a2fb97af4bcac80ef11f5e37f2537)) ([@fnichol][])
|
10
|
+
* Transport are not responsible for the `login` command. ([Commit notes](https://github.com/test-kitchen/test-kitchen/commit/ae360a11d8c18ff5d1086ee19b099db1d0422024)) ([@fnichol][])
|
11
|
+
* Busser is now a plugin of type Verifier (see below for details on Verifiers). Any external code that directly creates a `Kitchen::Busser` object will fail as the class has moved to `Kitchen::Verifier::Busser`. Any external code that directly invokes Busser's `#sync_cmd` will log a warning and will **not** transfer test files (authors of plugins may now call `instance.transport(state).upload(locals, remote)` in its place). ([@fnichol][])
|
12
|
+
* Verifiers are responsible for the `verify` action. ([Commit notes](https://github.com/test-kitchen/test-kitchen/commit/d62f577003c1920259eb627cc4479c0b21e0c374)) ([@fnichol][])
|
13
|
+
|
14
|
+
|
15
|
+
### New features
|
16
|
+
|
17
|
+
* ChefZero Provisioner supports Windows paths and PowerShell commands and works with the WinRM Transport (default behavior for Platform names starting with `/^win/`). ([Provisioner::ChefZero](https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/provisioner/chef_zero.rb)) ([@fnichol][])
|
18
|
+
* ChefSolo Provisioner supports Windows paths and PowerShell commands and works with the WinRM Transport (default behavior for Platform names starting with `/^win/`). ([Provisioner::ChefSolo](https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/provisioner/chef_solo.rb)) ([@fnichol][])
|
19
|
+
* Shell Provisioner supports PowerShell scripts in addition to Bourne shell scripts ([Provisioner::Shell](https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/provisioner/shell.rb)) ([@fnichol][])
|
20
|
+
* Platform operating system and shell hinting: By default, Windows platform names (case insensitive platform names starting with `/^win/`) will have `:os_type` set to `"windows"` and `:shell_type` set to `"powershell"`. By default, non-Windows platform names will have `:os_type` set to `"unix"` and `:shell_type` set to `"bourne"`. The methods `#windows_os?`, `#unix_os?`, `#powershell_shell?`, `#bourne_shell?`, and `#remote_path_join` are available for all Driver, Provisioner, Verifier, and Transport authors. ([@fnichol][])
|
21
|
+
* New plugin type: Transport, which executes commands and transfers files to remote instances. ([Transport::Base](https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/transport/base.rb)) ([@afiune][], [@mwrock][], [@fnichol][])
|
22
|
+
* New Transport: WinRM: which re-uses a remote shell to execute commands and upload files over WinRM. Currently non-SSL/plaintext authentication only. ([Transport::Winrm](https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/transport/winrm.rb)) ([@afiune][], [@mwrock][], [@fnichol][])
|
23
|
+
* New Transport: SSH, which re-uses one SSH connection where possible. Improvements such as keepalive, retries, and further configuration attributes are included. This replaces the more general `Kitchen:SSH` class, which remains in the codebase for plugins that call this class directly. ([Transport::Ssh](https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/transport/ssh.rb)) ([@fnichol][])
|
24
|
+
* New plugin type: Verifier, which executes post-convergence tests on the instance. Busser is now a Verifier. ([Verifier::Base](https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/verifier/base.rb)) ([@fnichol][])
|
25
|
+
|
26
|
+
#### Improvements
|
27
|
+
|
28
|
+
* In addition to supporting setting `http_proxy` and `https_proxy` environment variables when `:http_proxy` and `:https_proxy` are set in Provisioner and Verifier blocks, `HTTP_PROXY` and `HTTPS_PROXY` environment variables will also be set/exported in ChefZero/ChefSolo Provisioners and Busser Verifier. ([@fnichol][])
|
29
|
+
* Pull request [#600][], pull request [#633][], issue [#85][]: Add `--log-overwrite` flag to CLI anywhere `--log-level` is accepted. By default it is true and will clear out the log every time Test Kitchen runs. To disable this behavior pass `--log-overwrite=false` or `--no-log-overwrite`. You can also configure this with the environment variable `KITCHEN_LOG_OVERWRITE`. ([@tyler-ball][])
|
30
|
+
* Refactor "non-trivial" (i.e. more than a line or two) Bourne and PowerShell code bodies into static files under support/ for better code review by domain experts. ([@fnichol][])
|
31
|
+
* Pull request [#530][], issue [#429][]: Stop uploading empty directories. ([@whiteley][])
|
32
|
+
* Pull request [#588][]: Change getchef.com to chef.io in ChefZero and ChefSolo Provisioners. ([@jdmundrawala][])
|
33
|
+
|
34
|
+
|
1
35
|
## 1.3.1 / 2015-01-16
|
2
36
|
|
3
37
|
### Bug fixes
|
@@ -437,6 +471,7 @@ The initial release.
|
|
437
471
|
[#81]: https://github.com/test-kitchen/test-kitchen/issues/81
|
438
472
|
[#82]: https://github.com/test-kitchen/test-kitchen/issues/82
|
439
473
|
[#84]: https://github.com/test-kitchen/test-kitchen/issues/84
|
474
|
+
[#85]: https://github.com/test-kitchen/test-kitchen/issues/85
|
440
475
|
[#90]: https://github.com/test-kitchen/test-kitchen/issues/90
|
441
476
|
[#92]: https://github.com/test-kitchen/test-kitchen/issues/92
|
442
477
|
[#94]: https://github.com/test-kitchen/test-kitchen/issues/94
|
@@ -545,6 +580,7 @@ The initial release.
|
|
545
580
|
[#399]: https://github.com/test-kitchen/test-kitchen/issues/399
|
546
581
|
[#416]: https://github.com/test-kitchen/test-kitchen/issues/416
|
547
582
|
[#427]: https://github.com/test-kitchen/test-kitchen/issues/427
|
583
|
+
[#429]: https://github.com/test-kitchen/test-kitchen/issues/429
|
548
584
|
[#431]: https://github.com/test-kitchen/test-kitchen/issues/431
|
549
585
|
[#433]: https://github.com/test-kitchen/test-kitchen/issues/433
|
550
586
|
[#450]: https://github.com/test-kitchen/test-kitchen/issues/450
|
@@ -564,6 +600,7 @@ The initial release.
|
|
564
600
|
[#524]: https://github.com/test-kitchen/test-kitchen/issues/524
|
565
601
|
[#526]: https://github.com/test-kitchen/test-kitchen/issues/526
|
566
602
|
[#527]: https://github.com/test-kitchen/test-kitchen/issues/527
|
603
|
+
[#530]: https://github.com/test-kitchen/test-kitchen/issues/530
|
567
604
|
[#531]: https://github.com/test-kitchen/test-kitchen/issues/531
|
568
605
|
[#543]: https://github.com/test-kitchen/test-kitchen/issues/543
|
569
606
|
[#549]: https://github.com/test-kitchen/test-kitchen/issues/549
|
@@ -575,9 +612,13 @@ The initial release.
|
|
575
612
|
[#579]: https://github.com/test-kitchen/test-kitchen/issues/579
|
576
613
|
[#580]: https://github.com/test-kitchen/test-kitchen/issues/580
|
577
614
|
[#581]: https://github.com/test-kitchen/test-kitchen/issues/581
|
615
|
+
[#588]: https://github.com/test-kitchen/test-kitchen/issues/588
|
616
|
+
[#600]: https://github.com/test-kitchen/test-kitchen/issues/600
|
617
|
+
[#633]: https://github.com/test-kitchen/test-kitchen/issues/633
|
578
618
|
[@ChrisLundquist]: https://github.com/ChrisLundquist
|
579
619
|
[@MarkGibbons]: https://github.com/MarkGibbons
|
580
620
|
[@adamhjk]: https://github.com/adamhjk
|
621
|
+
[@afiune]: https://github.com/afiune
|
581
622
|
[@arangamani]: https://github.com/arangamani
|
582
623
|
[@arunthampi]: https://github.com/arunthampi
|
583
624
|
[@benlangfeld]: https://github.com/benlangfeld
|
@@ -598,6 +639,7 @@ The initial release.
|
|
598
639
|
[@hollow]: https://github.com/hollow
|
599
640
|
[@jaimegildesagredo]: https://github.com/jaimegildesagredo
|
600
641
|
[@jasonroelofs]: https://github.com/jasonroelofs
|
642
|
+
[@jdmundrawala]: https://github.com/jdmundrawala
|
601
643
|
[@jgoldschrafe]: https://github.com/jgoldschrafe
|
602
644
|
[@jochenseeber]: https://github.com/jochenseeber
|
603
645
|
[@jonsmorrow]: https://github.com/jonsmorrow
|
@@ -620,6 +662,7 @@ The initial release.
|
|
620
662
|
[@michaelkirk]: https://github.com/michaelkirk
|
621
663
|
[@miketheman]: https://github.com/miketheman
|
622
664
|
[@mthssdrbrg]: https://github.com/mthssdrbrg
|
665
|
+
[@mwrock]: https://github.com/mwrock
|
623
666
|
[@oferrigni]: https://github.com/oferrigni
|
624
667
|
[@patcon]: https://github.com/patcon
|
625
668
|
[@portertech]: https://github.com/portertech
|
@@ -643,4 +686,6 @@ The initial release.
|
|
643
686
|
[@stevendanna]: https://github.com/stevendanna
|
644
687
|
[@thommay]: https://github.com/thommay
|
645
688
|
[@tknerr]: https://github.com/tknerr
|
689
|
+
[@tyler-ball]: https://github.com/tyler-ball
|
690
|
+
[@whiteley]: https://github.com/whiteley
|
646
691
|
[@zts]: https://github.com/zts
|
data/Rakefile
CHANGED
@@ -50,3 +50,18 @@ require "yard"
|
|
50
50
|
YARD::Rake::YardocTask.new
|
51
51
|
|
52
52
|
task :default => [:test, :quality]
|
53
|
+
|
54
|
+
task :deploy_over_dk do
|
55
|
+
if RUBY_PLATFORM =~ /mswin|mingw|windows/
|
56
|
+
dk_path = File.join(ENV["SYSTEMDRIVE"], "opscode", "chefdk")
|
57
|
+
else
|
58
|
+
dk_path = "/opt/chefdk"
|
59
|
+
end
|
60
|
+
|
61
|
+
dk_app_path = File.join(dk_path, %w[embedded apps test-kitchen])
|
62
|
+
FileUtils.copy_entry(File.dirname(__FILE__), dk_app_path)
|
63
|
+
git_dir = File.join(dk_app_path, ".git")
|
64
|
+
FileUtils.rm_rf(git_dir) if Dir.exist?(git_dir)
|
65
|
+
end
|
66
|
+
|
67
|
+
task :dk_install => [:deploy_over_dk, :install]
|
@@ -13,6 +13,9 @@ Feature: Running instance actions
|
|
13
13
|
provisioner:
|
14
14
|
name: dummy
|
15
15
|
|
16
|
+
verifier:
|
17
|
+
name: dummy
|
18
|
+
|
16
19
|
platforms:
|
17
20
|
- name: cool
|
18
21
|
- name: beans
|
@@ -64,8 +67,8 @@ Feature: Running instance actions
|
|
64
67
|
Given a file named ".kitchen.local.yml" with:
|
65
68
|
"""
|
66
69
|
---
|
67
|
-
|
68
|
-
|
70
|
+
provisioner:
|
71
|
+
fail: true
|
69
72
|
"""
|
70
73
|
When I successfully run `kitchen create client-beans`
|
71
74
|
And I successfully run `kitchen list client-beans`
|
@@ -92,17 +95,17 @@ Feature: Running instance actions
|
|
92
95
|
Given a file named ".kitchen.local.yml" with:
|
93
96
|
"""
|
94
97
|
---
|
95
|
-
|
96
|
-
|
98
|
+
verifier:
|
99
|
+
fail: true
|
97
100
|
"""
|
98
101
|
When I successfully run `kitchen converge client-beans`
|
99
102
|
And I successfully run `kitchen list client-beans`
|
100
103
|
Then the stdout should match /^client-beans\s+.+\s+Converged\Z/
|
101
|
-
When I run `kitchen
|
102
|
-
Then the output should contain "
|
104
|
+
When I run `kitchen verify client-beans`
|
105
|
+
Then the output should contain "Verify failed on instance <client-beans>"
|
103
106
|
And the exit status should not be 0
|
104
107
|
When I successfully run `kitchen list client-beans`
|
105
|
-
Then the stdout should match /^client-beans\s+.+\s+
|
108
|
+
Then the stdout should match /^client-beans\s+.+\s+Set Up\Z/
|
106
109
|
|
107
110
|
@spawn
|
108
111
|
Scenario: Verifying a single instance
|
@@ -120,8 +123,8 @@ Feature: Running instance actions
|
|
120
123
|
Given a file named ".kitchen.local.yml" with:
|
121
124
|
"""
|
122
125
|
---
|
123
|
-
|
124
|
-
|
126
|
+
verifier:
|
127
|
+
fail: true
|
125
128
|
"""
|
126
129
|
When I successfully run `kitchen setup client-beans`
|
127
130
|
And I successfully run `kitchen list client-beans`
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Feature: Test Kitchen defaults
|
2
|
+
In order to have a more pleasant out of the box experience
|
3
|
+
As a user of Test Kitchen
|
4
|
+
I want to have some common defaults handled for me
|
5
|
+
|
6
|
+
Scenario: Windows platforms get the Winrm Transport by default
|
7
|
+
Given a file named ".kitchen.yml" with:
|
8
|
+
"""
|
9
|
+
---
|
10
|
+
driver: dummy
|
11
|
+
provisioner: dummy
|
12
|
+
verifier: dummy
|
13
|
+
|
14
|
+
platforms:
|
15
|
+
- name: win-8.1
|
16
|
+
|
17
|
+
suites:
|
18
|
+
- name: default
|
19
|
+
"""
|
20
|
+
When I successfully run `kitchen list`
|
21
|
+
Then the output should match /^default-win-81\s+Dummy\s+Dummy\s+Dummy\s+Winrm\s+\<Not Created\>$/
|
22
|
+
|
23
|
+
Scenario: Non-Windows platforms get the Ssh Transport by default
|
24
|
+
Given a file named ".kitchen.yml" with:
|
25
|
+
"""
|
26
|
+
---
|
27
|
+
driver: dummy
|
28
|
+
provisioner: dummy
|
29
|
+
verifier: dummy
|
30
|
+
|
31
|
+
platforms:
|
32
|
+
- name: ubuntu-14.04
|
33
|
+
|
34
|
+
suites:
|
35
|
+
- name: default
|
36
|
+
"""
|
37
|
+
When I successfully run `kitchen list`
|
38
|
+
Then the output should match /^default-ubuntu-1404\s+Dummy\s+Dummy\s+Dummy\s+Ssh\s+\<Not Created\>$/
|
@@ -19,7 +19,6 @@ Feature: Add Test Kitchen support to an existing project
|
|
19
19
|
And I have a git repository
|
20
20
|
When I run `kitchen init`
|
21
21
|
Then the exit status should be 0
|
22
|
-
And a directory named ".kitchen" should exist
|
23
22
|
And a directory named "test/integration/default" should exist
|
24
23
|
And the file ".gitignore" should contain ".kitchen/"
|
25
24
|
And the file ".gitignore" should contain ".kitchen.local.yml"
|
@@ -22,8 +22,8 @@ Feature: Listing Test Kitchen instances
|
|
22
22
|
Scenario: Listing instances
|
23
23
|
When I run `kitchen list`
|
24
24
|
Then the exit status should be 0
|
25
|
-
And the output should match /^foobar-ubuntu-1304\s+Dummy\s+ChefSolo\s+\<Not Created\>$/
|
26
|
-
And the output should match /^foobar-centos-64\s+Dummy\s+ChefSolo\s+\<Not Created\>$/
|
25
|
+
And the output should match /^foobar-ubuntu-1304\s+Dummy\s+ChefSolo\s+Busser\s+Ssh\s+\<Not Created\>$/
|
26
|
+
And the output should match /^foobar-centos-64\s+Dummy\s+ChefSolo\s+Busser\s+Ssh\s+\<Not Created\>$/
|
27
27
|
|
28
28
|
Scenario: Listing instances with the --bare option
|
29
29
|
When I run `kitchen list --bare`
|
@@ -10,6 +10,9 @@ Feature: Logging into a Kitchen instance
|
|
10
10
|
driver:
|
11
11
|
name: dummy
|
12
12
|
|
13
|
+
transport:
|
14
|
+
name: dummy
|
15
|
+
|
13
16
|
provisioner:
|
14
17
|
name: dummy
|
15
18
|
|
@@ -25,7 +28,10 @@ Feature: Logging into a Kitchen instance
|
|
25
28
|
@spawn
|
26
29
|
Scenario: Logging in to an instance
|
27
30
|
When I run `kitchen login default-flebian`
|
28
|
-
Then the output should contain
|
31
|
+
Then the output should contain:
|
32
|
+
"""
|
33
|
+
Remote login not supported in Kitchen::Transport::Dummy::Connection.
|
34
|
+
"""
|
29
35
|
And the exit status should not be 0
|
30
36
|
|
31
37
|
@spawn
|
@@ -43,8 +43,8 @@ Feature: Running a full test instance test
|
|
43
43
|
Given a file named ".kitchen.local.yml" with:
|
44
44
|
"""
|
45
45
|
---
|
46
|
-
|
47
|
-
|
46
|
+
provisioner:
|
47
|
+
fail: true
|
48
48
|
"""
|
49
49
|
When I run `kitchen test client-beans --destroy=always`
|
50
50
|
Then the exit status should not be 0
|
@@ -56,8 +56,8 @@ Feature: Running a full test instance test
|
|
56
56
|
Given a file named ".kitchen.local.yml" with:
|
57
57
|
"""
|
58
58
|
---
|
59
|
-
|
60
|
-
|
59
|
+
provisioner:
|
60
|
+
fail: true
|
61
61
|
"""
|
62
62
|
When I run `kitchen test client-beans --destroy=passing`
|
63
63
|
Then the exit status should not be 0
|
data/lib/kitchen.rb
CHANGED
@@ -28,7 +28,6 @@ require "kitchen/util"
|
|
28
28
|
|
29
29
|
require "kitchen/provisioner"
|
30
30
|
require "kitchen/provisioner/base"
|
31
|
-
require "kitchen/busser"
|
32
31
|
require "kitchen/color"
|
33
32
|
require "kitchen/collection"
|
34
33
|
require "kitchen/config"
|
@@ -38,12 +37,16 @@ require "kitchen/driver/base"
|
|
38
37
|
require "kitchen/driver/ssh_base"
|
39
38
|
require "kitchen/driver/proxy"
|
40
39
|
require "kitchen/instance"
|
40
|
+
require "kitchen/transport"
|
41
|
+
require "kitchen/transport/base"
|
41
42
|
require "kitchen/loader/yaml"
|
42
43
|
require "kitchen/metadata_chopper"
|
43
44
|
require "kitchen/platform"
|
44
45
|
require "kitchen/state_file"
|
45
46
|
require "kitchen/ssh"
|
46
47
|
require "kitchen/suite"
|
48
|
+
require "kitchen/verifier"
|
49
|
+
require "kitchen/verifier/base"
|
47
50
|
require "kitchen/version"
|
48
51
|
|
49
52
|
# Test Kitchen base module.
|
@@ -70,16 +73,27 @@ module Kitchen
|
|
70
73
|
#
|
71
74
|
# @return [Logger] a logger
|
72
75
|
def default_logger
|
73
|
-
Logger.new(:stdout => $stdout, :level => env_log)
|
76
|
+
Logger.new(:stdout => $stdout, :level => Util.to_logger_level(env_log))
|
74
77
|
end
|
75
78
|
|
76
79
|
# Returns a default file logger which emits on standard output and to a
|
77
80
|
# log file.
|
78
81
|
#
|
82
|
+
# @param [Symbol] level logging level
|
83
|
+
# @param [Boolean] log_overwrite logging level
|
79
84
|
# @return [Logger] a logger
|
80
|
-
def default_file_logger
|
81
|
-
|
82
|
-
|
85
|
+
def default_file_logger(level = nil, log_overwrite = nil)
|
86
|
+
level ||= env_log
|
87
|
+
log_overwrite = log_overwrite.nil? ? env_log_overwrite : log_overwrite
|
88
|
+
log_location = File.expand_path(File.join(DEFAULT_LOG_DIR, "kitchen.log"))
|
89
|
+
log_location = log_location.to_s
|
90
|
+
|
91
|
+
Logger.new(
|
92
|
+
:stdout => $stdout,
|
93
|
+
:logdev => log_location,
|
94
|
+
:level => Util.to_logger_level(level),
|
95
|
+
:log_overwrite => log_overwrite
|
96
|
+
)
|
83
97
|
end
|
84
98
|
|
85
99
|
# Returns whether or not standard output is associated with a terminal
|
@@ -90,23 +104,38 @@ module Kitchen
|
|
90
104
|
$stdout.tty?
|
91
105
|
end
|
92
106
|
|
93
|
-
private
|
94
|
-
|
95
107
|
# Determine the default log level from an environment variable, if it is
|
96
108
|
# set.
|
97
109
|
#
|
98
|
-
# @return [
|
110
|
+
# @return [Symbol,nil] a log level or nil if not set
|
99
111
|
# @api private
|
100
112
|
def env_log
|
101
|
-
|
102
|
-
|
103
|
-
|
113
|
+
ENV["KITCHEN_LOG"] && ENV["KITCHEN_LOG"].downcase.to_sym
|
114
|
+
end
|
115
|
+
|
116
|
+
# Determine the log overwriting logic from an environment variable,
|
117
|
+
# if it is set.
|
118
|
+
#
|
119
|
+
# @return [Boolean,nil]
|
120
|
+
# @api private
|
121
|
+
def env_log_overwrite
|
122
|
+
case ENV["KITCHEN_LOG_OVERWRITE"] && ENV["KITCHEN_LOG_OVERWRITE"].downcase
|
123
|
+
when nil, ""
|
124
|
+
nil
|
125
|
+
when "false", "f", "no"
|
126
|
+
false
|
127
|
+
else
|
128
|
+
true
|
129
|
+
end
|
104
130
|
end
|
105
131
|
end
|
106
132
|
|
107
133
|
# Default log level verbosity
|
108
134
|
DEFAULT_LOG_LEVEL = :info
|
109
135
|
|
136
|
+
# Overwrite the log file when Test Kitchen runs
|
137
|
+
DEFAULT_LOG_OVERWRITE = true
|
138
|
+
|
110
139
|
# Default base directory for integration tests, fixtures, etc.
|
111
140
|
DEFAULT_TEST_DIR = "test/integration".freeze
|
112
141
|
|
data/lib/kitchen/cli.rb
CHANGED
@@ -64,20 +64,33 @@ module Kitchen
|
|
64
64
|
# high
|
65
65
|
MAX_CONCURRENCY = 9999
|
66
66
|
|
67
|
+
attr_reader :config
|
68
|
+
|
67
69
|
# Constructs a new instance.
|
68
70
|
def initialize(*args)
|
69
71
|
super
|
70
72
|
$stdout.sync = true
|
71
|
-
Kitchen.logger = Kitchen.default_file_logger
|
72
73
|
@loader = Kitchen::Loader::YAML.new(
|
73
74
|
:project_config => ENV["KITCHEN_YAML"],
|
74
75
|
:local_config => ENV["KITCHEN_LOCAL_YAML"],
|
75
76
|
:global_config => ENV["KITCHEN_GLOBAL_YAML"]
|
76
77
|
)
|
77
78
|
@config = Kitchen::Config.new(
|
78
|
-
:loader => @loader
|
79
|
-
:log_level => ENV.fetch("KITCHEN_LOG", "info").downcase.to_sym
|
79
|
+
:loader => @loader
|
80
80
|
)
|
81
|
+
@config.log_level = Kitchen.env_log unless Kitchen.env_log.nil?
|
82
|
+
@config.log_overwrite = Kitchen.env_log_overwrite unless Kitchen.env_log_overwrite.nil?
|
83
|
+
end
|
84
|
+
|
85
|
+
# Sets the logging method_options
|
86
|
+
# @api private
|
87
|
+
def self.log_options
|
88
|
+
method_option :log_level,
|
89
|
+
:aliases => "-l",
|
90
|
+
:desc => "Set the log level (debug, info, warn, error, fatal)"
|
91
|
+
method_option :log_overwrite,
|
92
|
+
:desc => "Set to false to prevent log overwriting each time Test Kitchen runs",
|
93
|
+
:type => :boolean
|
81
94
|
end
|
82
95
|
|
83
96
|
desc "list [INSTANCE|REGEXP|all]", "Lists one or more instances"
|
@@ -89,18 +102,13 @@ module Kitchen
|
|
89
102
|
:aliases => "-d",
|
90
103
|
:type => :boolean,
|
91
104
|
:desc => "[Deprecated] Please use `kitchen diagnose'"
|
92
|
-
|
93
|
-
:aliases => "-l",
|
94
|
-
:desc => "Set the log level (debug, info, warn, error, fatal)"
|
105
|
+
log_options
|
95
106
|
def list(*args)
|
96
107
|
update_config!
|
97
108
|
perform("list", "list", args)
|
98
109
|
end
|
99
110
|
|
100
111
|
desc "diagnose [INSTANCE|REGEXP|all]", "Show computed diagnostic configuration"
|
101
|
-
method_option :log_level,
|
102
|
-
:aliases => "-l",
|
103
|
-
:desc => "Set the log level (debug, info, warn, error, fatal)"
|
104
112
|
method_option :loader,
|
105
113
|
:type => :boolean,
|
106
114
|
:desc => "Include data loader diagnostics"
|
@@ -111,6 +119,7 @@ module Kitchen
|
|
111
119
|
method_option :all,
|
112
120
|
:type => :boolean,
|
113
121
|
:desc => "Include all diagnostics"
|
122
|
+
log_options
|
114
123
|
def diagnose(*args)
|
115
124
|
update_config!
|
116
125
|
perform("diagnose", "diagnose", args, :loader => @loader)
|
@@ -153,9 +162,7 @@ module Kitchen
|
|
153
162
|
[Future DEPRECATION, use --concurrency]
|
154
163
|
Run a #{action} against all matching instances concurrently.
|
155
164
|
DESC
|
156
|
-
|
157
|
-
:aliases => "-l",
|
158
|
-
:desc => "Set the log level (debug, info, warn, error, fatal)"
|
165
|
+
log_options
|
159
166
|
define_method(action) do |*args|
|
160
167
|
update_config!
|
161
168
|
perform(action, "action", args)
|
@@ -192,9 +199,6 @@ module Kitchen
|
|
192
199
|
[Future DEPRECATION, use --concurrency]
|
193
200
|
Run a test against all matching instances concurrently.
|
194
201
|
DESC
|
195
|
-
method_option :log_level,
|
196
|
-
:aliases => "-l",
|
197
|
-
:desc => "Set the log level (debug, info, warn, error, fatal)"
|
198
202
|
method_option :destroy,
|
199
203
|
:aliases => "-d",
|
200
204
|
:default => "passing",
|
@@ -203,6 +207,7 @@ module Kitchen
|
|
203
207
|
:type => :boolean,
|
204
208
|
:default => false,
|
205
209
|
:desc => "Invoke init command if .kitchen.yml is missing"
|
210
|
+
log_options
|
206
211
|
def test(*args)
|
207
212
|
update_config!
|
208
213
|
ensure_initialized
|
@@ -210,9 +215,7 @@ module Kitchen
|
|
210
215
|
end
|
211
216
|
|
212
217
|
desc "login INSTANCE|REGEXP", "Log in to one instance"
|
213
|
-
|
214
|
-
:aliases => "-l",
|
215
|
-
:desc => "Set the log level (debug, info, warn, error, fatal)"
|
218
|
+
log_options
|
216
219
|
def login(*args)
|
217
220
|
update_config!
|
218
221
|
perform("login", "login", args)
|
@@ -220,12 +223,10 @@ module Kitchen
|
|
220
223
|
|
221
224
|
desc "exec INSTANCE|REGEXP -c REMOTE_COMMAND",
|
222
225
|
"Execute command on one or more instance"
|
223
|
-
method_option :log_level,
|
224
|
-
:aliases => "-l",
|
225
|
-
:desc => "Set the log level (debug, info, warn, error, fatal)"
|
226
226
|
method_option :command,
|
227
227
|
:aliases => "-c",
|
228
228
|
:desc => "execute via ssh"
|
229
|
+
log_options
|
229
230
|
def exec(*args)
|
230
231
|
update_config!
|
231
232
|
perform("exec", "exec", args)
|
@@ -330,9 +331,24 @@ module Kitchen
|
|
330
331
|
if options[:log_level]
|
331
332
|
level = options[:log_level].downcase.to_sym
|
332
333
|
@config.log_level = level
|
333
|
-
Kitchen.logger.level = Util.to_logger_level(level)
|
334
334
|
end
|
335
|
+
unless options[:log_overwrite].nil?
|
336
|
+
@config.log_overwrite = options[:log_overwrite]
|
337
|
+
end
|
338
|
+
|
339
|
+
# Now that we have required configs, lets create our file logger
|
340
|
+
Kitchen.logger = Kitchen.default_file_logger(
|
341
|
+
level,
|
342
|
+
options[:log_overwrite]
|
343
|
+
)
|
335
344
|
|
345
|
+
update_parallel!
|
346
|
+
end
|
347
|
+
|
348
|
+
# Set parallel concurrency options for Thor
|
349
|
+
#
|
350
|
+
# @api private
|
351
|
+
def update_parallel!
|
336
352
|
if options[:parallel]
|
337
353
|
# warn here in a future release when option is used
|
338
354
|
@options = Thor::CoreExt::HashWithIndifferentAccess.new(options.to_hash)
|