test-kitchen 0.7.0 → 1.0.0.alpha.0

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.
Files changed (95) hide show
  1. data/.gitignore +20 -0
  2. data/.travis.yml +11 -0
  3. data/.yardopts +3 -0
  4. data/Gemfile +13 -0
  5. data/Guardfile +11 -0
  6. data/LICENSE +15 -0
  7. data/README.md +131 -0
  8. data/Rakefile +69 -0
  9. data/bin/kitchen +9 -4
  10. data/features/cli.feature +17 -0
  11. data/features/cli_init.feature +156 -0
  12. data/features/support/env.rb +14 -0
  13. data/lib/kitchen/busser.rb +166 -0
  14. data/lib/kitchen/chef_data_uploader.rb +156 -0
  15. data/lib/kitchen/cli.rb +540 -0
  16. data/lib/kitchen/collection.rb +55 -0
  17. data/lib/kitchen/color.rb +46 -0
  18. data/lib/kitchen/config.rb +223 -0
  19. data/lib/kitchen/driver/base.rb +180 -0
  20. data/lib/kitchen/driver/dummy.rb +81 -0
  21. data/lib/kitchen/driver/ssh_base.rb +192 -0
  22. data/lib/kitchen/driver.rb +42 -0
  23. data/lib/kitchen/errors.rb +52 -0
  24. data/lib/kitchen/instance.rb +327 -0
  25. data/lib/kitchen/instance_actor.rb +42 -0
  26. data/lib/kitchen/loader/yaml.rb +105 -0
  27. data/lib/kitchen/logger.rb +145 -0
  28. data/{cookbooks/test-kitchen/libraries/helpers.rb → lib/kitchen/logging.rb} +13 -9
  29. data/lib/kitchen/manager.rb +45 -0
  30. data/lib/kitchen/metadata_chopper.rb +52 -0
  31. data/lib/kitchen/platform.rb +61 -0
  32. data/lib/kitchen/rake_tasks.rb +59 -0
  33. data/lib/kitchen/shell_out.rb +65 -0
  34. data/lib/kitchen/state_file.rb +88 -0
  35. data/lib/kitchen/suite.rb +76 -0
  36. data/lib/kitchen/thor_tasks.rb +62 -0
  37. data/lib/kitchen/util.rb +79 -0
  38. data/{cookbooks/test-kitchen/recipes/erlang.rb → lib/kitchen/version.rb} +9 -6
  39. data/lib/kitchen.rb +98 -0
  40. data/lib/vendor/hash_recursive_merge.rb +74 -0
  41. data/spec/kitchen/collection_spec.rb +80 -0
  42. data/spec/kitchen/color_spec.rb +54 -0
  43. data/spec/kitchen/config_spec.rb +201 -0
  44. data/spec/kitchen/driver/dummy_spec.rb +191 -0
  45. data/spec/kitchen/instance_spec.rb +162 -0
  46. data/spec/kitchen/loader/yaml_spec.rb +243 -0
  47. data/spec/kitchen/platform_spec.rb +48 -0
  48. data/spec/kitchen/state_file_spec.rb +122 -0
  49. data/spec/kitchen/suite_spec.rb +64 -0
  50. data/spec/spec_helper.rb +47 -0
  51. data/templates/plugin/driver.rb.erb +23 -0
  52. data/templates/plugin/license_apachev2.erb +15 -0
  53. data/templates/plugin/license_gplv2.erb +18 -0
  54. data/templates/plugin/license_gplv3.erb +16 -0
  55. data/templates/plugin/license_mit.erb +22 -0
  56. data/templates/plugin/license_reserved.erb +5 -0
  57. data/templates/plugin/version.rb.erb +12 -0
  58. data/test-kitchen.gemspec +44 -0
  59. metadata +290 -82
  60. data/config/Cheffile +0 -47
  61. data/config/Kitchenfile +0 -39
  62. data/config/Vagrantfile +0 -114
  63. data/cookbooks/test-kitchen/attributes/default.rb +0 -25
  64. data/cookbooks/test-kitchen/metadata.rb +0 -27
  65. data/cookbooks/test-kitchen/recipes/chef.rb +0 -19
  66. data/cookbooks/test-kitchen/recipes/compat.rb +0 -39
  67. data/cookbooks/test-kitchen/recipes/default.rb +0 -51
  68. data/cookbooks/test-kitchen/recipes/ruby.rb +0 -29
  69. data/lib/test-kitchen/cli/destroy.rb +0 -36
  70. data/lib/test-kitchen/cli/init.rb +0 -37
  71. data/lib/test-kitchen/cli/platform_list.rb +0 -37
  72. data/lib/test-kitchen/cli/project_info.rb +0 -44
  73. data/lib/test-kitchen/cli/ssh.rb +0 -36
  74. data/lib/test-kitchen/cli/status.rb +0 -36
  75. data/lib/test-kitchen/cli/test.rb +0 -68
  76. data/lib/test-kitchen/cli.rb +0 -282
  77. data/lib/test-kitchen/dsl.rb +0 -63
  78. data/lib/test-kitchen/environment.rb +0 -166
  79. data/lib/test-kitchen/platform.rb +0 -79
  80. data/lib/test-kitchen/project/base.rb +0 -159
  81. data/lib/test-kitchen/project/cookbook.rb +0 -97
  82. data/lib/test-kitchen/project/cookbook_copy.rb +0 -58
  83. data/lib/test-kitchen/project/ruby.rb +0 -37
  84. data/lib/test-kitchen/project/supported_platforms.rb +0 -75
  85. data/lib/test-kitchen/project.rb +0 -23
  86. data/lib/test-kitchen/runner/base.rb +0 -154
  87. data/lib/test-kitchen/runner/openstack/dsl.rb +0 -39
  88. data/lib/test-kitchen/runner/openstack/environment.rb +0 -141
  89. data/lib/test-kitchen/runner/openstack.rb +0 -147
  90. data/lib/test-kitchen/runner/vagrant.rb +0 -95
  91. data/lib/test-kitchen/runner.rb +0 -21
  92. data/lib/test-kitchen/scaffold.rb +0 -88
  93. data/lib/test-kitchen/ui.rb +0 -73
  94. data/lib/test-kitchen/version.rb +0 -21
  95. data/lib/test-kitchen.rb +0 -34
@@ -1,25 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- default['test-kitchen']['project'] = {
20
- 'test_root' => "/test-kitchen/test",
21
- 'source_root' => "/test-kitchen/source"
22
- }
23
-
24
- default['test-kitchen']['user'] = 'vagrant'
25
- default['test-kitchen']['group'] = 'vagrant'
@@ -1,27 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- maintainer "Opscode, Inc."
20
- maintainer_email "cookbooks@opscode.com"
21
- license "Apache 2.0"
22
- description "Support cookbook for the test-kitchen gem"
23
- version "1.0.0"
24
-
25
- depends "apt"
26
- depends "git"
27
- depends "yum"
@@ -1,19 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- include_recipe "test-kitchen::ruby"
@@ -1,39 +0,0 @@
1
-
2
- # stop strict host key checking on github.com
3
- execute 'no-github-key-checking' do
4
- command "echo '\nHost github.com\n\tStrictHostKeyChecking no' >> /etc/ssh/ssh_config"
5
- action :run
6
- not_if "cat /etc/ssh/ssh_config | grep github.com"
7
- end
8
-
9
- # ensure sudo inherits the SSH_AUTH_SOCK
10
- execute 'sudo-ssh-auth-sock' do
11
- command "echo '\nDefaults env_keep+=SSH_AUTH_SOCK' >> /etc/sudoers"
12
- action :run
13
- not_if "cat /etc/sudoers | grep SSH_AUTH_SOCK"
14
- end
15
-
16
- # ensure the current chef-solo process honors SSH_AUTH_SOCK
17
- # http://stackoverflow.com/questions/7211287/use-ssh-keys-with-passphrase-on-a-vagrantchef-setup
18
- ruby_block "Give root access to the forwarded ssh agent" do
19
- block do
20
- # find a parent process' ssh agent socket
21
- agents = {}
22
- ppid = Process.ppid
23
- Dir.glob('/tmp/ssh*/agent*').each do |fn|
24
- agents[fn.match(/agent\.(\d+)$/)[1]] = fn
25
- end
26
- while ppid != '1'
27
- if (agent = agents[ppid])
28
- ENV['SSH_AUTH_SOCK'] = agent
29
- break
30
- end
31
- File.open("/proc/#{ppid}/status", "r") do |file|
32
- ppid = file.read().match(/PPid:\s+(\d+)/)[1]
33
- end
34
- end
35
- # Uncomment to require that an ssh-agent be available
36
- # fail "Could not find running ssh agent - Is config.ssh.forward_agent enabled in Vagrantfile?" unless ENV['SSH_AUTH_SOCK']
37
- end
38
- action :create
39
- end
@@ -1,51 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- # Make sure that the package list is up to date
20
- case node['platform']
21
- when 'debian', 'ubuntu'
22
- include_recipe 'apt'
23
- # Force an update at compile-time to avoid failure when a cookbook attempts
24
- # a package install at compile-time.
25
- resources(:execute => "apt-get update").run_action(:run)
26
- when 'centos','redhat'
27
- include_recipe 'yum::epel'
28
- end
29
-
30
- include_recipe 'git'
31
- include_recipe 'test-kitchen::compat'
32
-
33
- project = node['test-kitchen']['project']
34
- source_root = project['source_root']
35
- test_root = project['test_root']
36
-
37
- package "rsync" do
38
- action :install
39
- end
40
-
41
- execute "stage project source to test root" do
42
- command "rsync -aHv --update --progress --checksum #{source_root}/ #{test_root} "
43
- end
44
-
45
- # make the project_root available to other recipes
46
- node.run_state['project'] = project
47
-
48
- language = project['language'] || 'chef'
49
-
50
- # ensure projects declared language toolchain is present
51
- include_recipe "test-kitchen::#{language}"
@@ -1,29 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- project = node.run_state['project']
20
-
21
- [File.join(project['test_root'], 'Gemfile'),
22
- File.join(project['test_root'], 'test', 'Gemfile')].each do |gemfile_path|
23
-
24
- # ensure we blow away Gemfile.lock
25
- file "#{gemfile_path}.lock" do
26
- action :delete
27
- end
28
-
29
- end
@@ -1,36 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'test-kitchen/cli'
20
- require 'test-kitchen/runner'
21
-
22
- module TestKitchen
23
- module CLI
24
- class Kitchen
25
- class Destroy < Kitchen
26
-
27
- banner "kitchen destroy (options)"
28
-
29
- def run
30
- runner.destroy
31
- end
32
-
33
- end
34
- end
35
- end
36
- end
@@ -1,37 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'test-kitchen/cli'
20
- require 'test-kitchen/scaffold'
21
-
22
- module TestKitchen
23
- module CLI
24
- class Kitchen
25
- class Init < Kitchen
26
-
27
- banner "kitchen init"
28
-
29
- def run
30
- scaffold = TestKitchen::Scaffold.new
31
- scaffold.generate(Dir.pwd)
32
- end
33
-
34
- end
35
- end
36
- end
37
- end
@@ -1,37 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'test-kitchen/cli'
20
-
21
- module TestKitchen
22
- module CLI
23
- class Kitchen
24
- class PlatformList < Kitchen
25
-
26
- banner "kitchen platform list (options)"
27
-
28
- def run
29
- env.platform_names.each do |platform|
30
- ui.info " #{platform}"
31
- end
32
- end
33
-
34
- end
35
- end
36
- end
37
- end
@@ -1,44 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'test-kitchen/cli'
20
-
21
- module TestKitchen
22
- module CLI
23
- class Kitchen
24
- class ProjectInfo < Kitchen
25
-
26
- banner "kitchen project info (options)"
27
-
28
- def run
29
- ui.info("Project: ", :green, :bold)
30
- ui.info(" #{env.project.name}\n")
31
- ui.info("Configurations: ", :yellow)
32
- if env.project.configurations.any?
33
- env.project.configurations.each_key do |config_name|
34
- ui.info(" #{config_name}")
35
- end
36
- else
37
- ui.info(" default")
38
- end
39
- end
40
-
41
- end
42
- end
43
- end
44
- end
@@ -1,36 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'test-kitchen/cli'
20
- require 'test-kitchen/runner'
21
-
22
- module TestKitchen
23
- module CLI
24
- class Kitchen
25
- class Ssh < Kitchen
26
-
27
- banner "kitchen ssh (options)"
28
-
29
- def run
30
- runner.ssh
31
- end
32
-
33
- end
34
- end
35
- end
36
- end
@@ -1,36 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'test-kitchen/cli'
20
- require 'test-kitchen/runner'
21
-
22
- module TestKitchen
23
- module CLI
24
- class Kitchen
25
- class Status < Kitchen
26
-
27
- banner "kitchen status (options)"
28
-
29
- def run
30
- runner.status
31
- end
32
-
33
- end
34
- end
35
- end
36
- end
@@ -1,68 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'test-kitchen/cli'
20
- require 'test-kitchen/runner'
21
-
22
- module TestKitchen
23
- module CLI
24
- class Kitchen
25
- class Test < Kitchen
26
-
27
- banner "kitchen test (options)"
28
-
29
- def run
30
- if config[:platform]
31
- test_platforms = [config[:platform]]
32
- else
33
- test_platforms = env.platform_names
34
- end
35
-
36
- warn_for_non_buildable_platforms(test_platforms)
37
- env.project.each_build(test_platforms,
38
- config[:configuration]) do |platform,configuration|
39
- runner = TestKitchen::Runner.for_platform(env,
40
- {:platform => platform, :configuration => configuration})
41
- runner.preflight_check
42
- runner.prepare
43
- begin
44
- runner.create
45
- runner.converge
46
- runner.test
47
- rescue
48
- raise
49
- ensure
50
- runner.destroy if config[:teardown]
51
- end
52
- end
53
- end
54
-
55
- private
56
-
57
- def warn_for_non_buildable_platforms(platform_names)
58
- if env.project.respond_to?(:non_buildable_platforms)
59
- env.project.non_buildable_platforms(platform_names).each do |platform|
60
- env.ui.info("Cookbook metadata specifies an unrecognized platform that will not be tested: #{platform}", :red)
61
- end
62
- end
63
- end
64
-
65
- end
66
- end
67
- end
68
- end