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,159 +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 'chef/mixin/params_validate'
20
-
21
- module TestKitchen
22
- module Project
23
- class Base
24
- include Chef::Mixin::ParamsValidate
25
-
26
- PROJECT_ROOT_INDICATORS = ["Gemfile", "metadata.rb"]
27
-
28
- attr_reader :name, :guest_source_root, :guest_test_root, :exclusions
29
- attr_writer :language, :runtimes, :install, :script, :configurations, :root_path, :memory
30
- attr_accessor :vm
31
-
32
- def initialize(name, parent=nil, &block)
33
- raise ArgumentError, "Project name must be specified" if name.nil? || name.empty?
34
- @name = name
35
- @parent = parent
36
- @runtimes = parent.runtimes if parent
37
- @configurations = {}
38
- @exclusions = []
39
- @guest_source_root = '/test-kitchen/source'
40
- @guest_test_root = '/test-kitchen/test'
41
- instance_eval(&block) if block_given?
42
- end
43
-
44
- def each_build(platforms, active_config=nil)
45
- raise ArgumentError if platforms.nil? || ! block_given?
46
- c = Array(active_config ?
47
- configurations[active_config] : configurations.values)
48
- platforms.to_a.product(c).each do |platform,configuration|
49
- yield [platform, configuration] unless exclusions.any? do |e|
50
- e[:platform] == platform.split('-').first &&
51
- ((! e[:configuration]) || e[:configuration] == configuration.name)
52
- end
53
- end
54
- end
55
-
56
- def configuration(name, &block)
57
- @configurations[name] = self.class.new(name, self, &block)
58
- end
59
-
60
- def configurations
61
- @configurations.empty? ? {:default => self} : @configurations
62
- end
63
-
64
- def tests_tag
65
- @parent.nil? ? 'default' : name
66
- end
67
-
68
- def exclude(exclusion)
69
- @exclusions << exclusion
70
- end
71
-
72
- def run_list
73
- ['test-kitchen::default'] + run_list_extras
74
- end
75
-
76
- def run_list_extras(arg=nil)
77
- set_or_return(:run_list_extras, arg, :default => [])
78
- end
79
-
80
- def runner(arg=nil)
81
- set_or_return(:runner, arg, nil)
82
- end
83
-
84
- def language(arg=nil)
85
- set_or_return(:language, arg, :default => 'ruby')
86
- end
87
-
88
- def runtimes(arg=nil)
89
- set_or_return(:runtimes, arg, :default => [])
90
- end
91
-
92
- def install(arg=nil)
93
- set_or_return(:install, arg,
94
- :default => language == 'ruby' ? 'bundle install' : '')
95
- end
96
-
97
- def script(arg=nil)
98
- set_or_return(:script, arg, :default => 'rspec spec')
99
- end
100
-
101
- def memory(arg=nil)
102
- set_or_return(:memory, arg, {})
103
- end
104
-
105
- def specs(arg=nil)
106
- set_or_return(:specs, arg, {:default => true})
107
- end
108
-
109
- def features(arg=nil)
110
- set_or_return(:features, arg, {:default => true})
111
- end
112
-
113
- def root_path
114
- return @root_path if defined?(@root_path)
115
-
116
- root_finder = lambda do |path|
117
- found = PROJECT_ROOT_INDICATORS.find do |rootfile|
118
- File.exist?(File.join(path.to_s, rootfile))
119
- end
120
-
121
- return path if found
122
- return nil if path.root? || !File.exist?(path)
123
- root_finder.call(path.parent)
124
- end
125
-
126
- @root_path = root_finder.call(Pathname.new(Dir.pwd))
127
- end
128
-
129
- def update_code_command
130
- "rsync -aHv --update --progress --checksum #{guest_source_root}/ #{guest_test_root}"
131
- end
132
-
133
- def preflight_command
134
- nil
135
- end
136
-
137
- def data_bags_path
138
- nil
139
- end
140
-
141
- def install_command(runtime=nil)
142
- raise NotImplementedError
143
- end
144
-
145
- def test_command(runtime=nil)
146
- raise NotImplementedError
147
- end
148
-
149
- def to_hash
150
- self.runtimes # hack
151
- hash = {}
152
- self.instance_variables.each do |var|
153
- hash[var[1..-1].to_sym] = self.instance_variable_get(var)
154
- end
155
- hash
156
- end
157
- end
158
- end
159
- end
@@ -1,97 +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
- module TestKitchen
20
- module Project
21
- class Cookbook < Ruby
22
-
23
- include CookbookCopy
24
- include SupportedPlatforms
25
-
26
- attr_writer :lint
27
- attr_writer :supported_platforms
28
- attr_writer :data_bags_path
29
-
30
- def lint(arg=nil)
31
- set_or_return(:lint, arg, {:default => true})
32
- end
33
-
34
- def run_list
35
- super + ['recipe[minitest-handler]']
36
- end
37
-
38
- def preflight_command(cmd = nil)
39
- return nil unless lint
40
- parent_dir = File.join(root_path, '..')
41
- ignore_tags = ''
42
- if lint.respond_to?(:has_key?) && lint[:ignore].respond_to?(:join)
43
- ignore_tags = " -t ~#{lint[:ignore].join(' -t ~')}"
44
- end
45
- set_or_return(:preflight_command, cmd, :default =>
46
- "knife cookbook test -o #{parent_dir} #{name}" +
47
- " && foodcritic -f ~FC007 -f correctness#{ignore_tags} #{root_path}")
48
- end
49
-
50
- def data_bags_path(path = nil)
51
- set_or_return(:data_bags_path, path,
52
- { :default => root_path.join('test/kitchen/data_bags').to_s })
53
- end
54
-
55
- def script(arg=nil)
56
- set_or_return(:script, arg, :default =>
57
- %Q{if [ -d "features" ]; then bundle exec cucumber -t @#{tests_tag} features; fi})
58
- end
59
-
60
- def install_command(runtime=nil)
61
- super(runtime, File.join(guest_test_root, 'test'))
62
- end
63
-
64
- def test_command(runtime=nil)
65
- super(runtime, File.join(guest_test_root, 'test'))
66
- end
67
-
68
- def supported_platforms
69
- @supported_platforms ||= extract_supported_platforms(
70
- File.read(File.join(root_path, 'metadata.rb')))
71
- end
72
-
73
- def non_buildable_platforms(platform_names)
74
- supported_platforms.sort - platform_names.map do |platform|
75
- platform.split('-').first
76
- end.sort.uniq
77
- end
78
-
79
- def each_build(platforms, active_config=nil, &block)
80
- if supported_platforms.empty?
81
- super(platforms, active_config, &block)
82
- else
83
- super(platforms.select do |platform|
84
- supported_platforms.any? do |supported|
85
- platform.start_with?("#{supported}-")
86
- end
87
- end, active_config, &block)
88
- end
89
- end
90
-
91
- def cookbook_path(root_path, tmp_path)
92
- @cookbook_path ||= copy_cookbook_under_test(root_path, tmp_path)
93
- end
94
-
95
- end
96
- end
97
- end
@@ -1,58 +0,0 @@
1
- #
2
- # Author:: Andrew Crump (<andrew@kotirisoftware.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
- module TestKitchen
20
- module Project
21
- module CookbookCopy
22
-
23
- # This is a workaround to allow the top-level containing cookbook
24
- # to be copied to the kitchen tmp subdirectory.
25
- def copy_cookbook_under_test(root_path, tmp_path)
26
- cookbook_path = root_path.parent.parent
27
- source_paths = source_paths_excluding_test_dir(cookbook_path)
28
- dest_path = File.join(tmp_path, 'cookbook_under_test')
29
- copy_paths(source_paths, dest_path,
30
- destination_paths(cookbook_path, source_paths, dest_path))
31
- dest_path
32
- end
33
-
34
- def source_paths_excluding_test_dir(cookbook_path)
35
- paths_from = Find.find(cookbook_path).reject do |path|
36
- Find.prune if ['.git', 'test'].map do |dir|
37
- File.join(cookbook_path, dir)
38
- end.include?(path)
39
- end.drop(1)
40
- end
41
-
42
- def destination_paths(cookbook_path, paths_from, dest_path)
43
- paths_from.map do |file|
44
- File.join(dest_path,
45
- file.to_s.sub(%r{^#{Regexp.escape(cookbook_path.to_s)}/}, ''))
46
- end
47
- end
48
-
49
- def copy_paths(source_paths, dest_path, dest_paths)
50
- FileUtils.mkdir_p(dest_path)
51
- source_paths.each_with_index do |from_path, index|
52
- FileUtils.cp_r(from_path, dest_paths[index])
53
- end
54
- end
55
-
56
- end
57
- end
58
- 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
- module TestKitchen
20
- module Project
21
- class Ruby < Base
22
-
23
- def install_command(runtime=nil, test_path=guest_test_root)
24
- cmd = "cd #{test_path}"
25
- cmd << " && rvm use #{runtime}" if runtime && ! runtime.empty?
26
- cmd << " && gem install bundler"
27
- cmd << " && #{install}"
28
- end
29
-
30
- def test_command(runtime=nil, test_path=guest_test_root)
31
- cmd = "cd #{test_path}"
32
- cmd << " && rvm use #{runtime}" if runtime && ! runtime.empty?
33
- cmd << " && #{script}"
34
- end
35
- end
36
- end
37
- end
@@ -1,75 +0,0 @@
1
- #
2
- # Author:: Andrew Crump (<andrew@kotirisoftware.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
- module TestKitchen
20
- module Project
21
- module SupportedPlatforms
22
-
23
- def extract_supported_platforms(metadata)
24
- raise ArgumentError, "Metadata must be provided" unless metadata
25
- ast = parse_ruby(metadata)
26
- supports = find_nodes(ast, [:command]).reject do |command|
27
- find_nodes(command, [:@ident, 'supports']).empty?
28
- end
29
- string_literals(supports) + word_list(ast, supports)
30
- end
31
-
32
- private
33
-
34
- def parse_ruby(ruby_str)
35
- Ripper::SexpBuilder.new(ruby_str).parse
36
- end
37
-
38
- def word_list(ast, nodes)
39
- nodes.map do |node|
40
- var_name = find_nodes(find_nodes(node, [:var_ref]), [:@ident]).flatten
41
- if var_name.length > 1
42
- add_block = find_nodes(ast, [:method_add_block]).reject do |n|
43
- find_nodes(n, [:@ident, "supports"]).empty?
44
- end
45
- unless find_nodes(find_nodes(add_block, [:do_block]),
46
- [:@ident, var_name[1]]).flatten.empty?
47
-
48
- find_nodes(find_nodes(add_block,
49
- [:qwords_add]), [:@tstring_content]).uniq.map do |str|
50
- str[1] if str.length > 1
51
- end
52
-
53
- end
54
- end
55
- end.flatten.compact
56
- end
57
-
58
- def string_literals(nodes)
59
- nodes.map do |node|
60
- tstring = find_nodes(node, [:@tstring_content]).find{|n| ! n.empty?}
61
- tstring && tstring.length > 1 ? tstring[1] : nil
62
- end.compact.flatten
63
- end
64
-
65
- def find_nodes(ast, node, result=[])
66
- if ast.respond_to?(:each)
67
- result << ast if ast.size > 1 and ast[0..(node.size - 1)] == node
68
- ast.each { |child| find_nodes(child, node, result) }
69
- end
70
- result
71
- end
72
-
73
- end
74
- end
75
- end
@@ -1,23 +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/project/base'
20
- require 'test-kitchen/project/ruby'
21
- require 'test-kitchen/project/supported_platforms'
22
- require 'test-kitchen/project/cookbook_copy'
23
- require 'test-kitchen/project/cookbook'
@@ -1,154 +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 'librarian/chef/cli'
20
-
21
- module TestKitchen
22
- module Runner
23
- class TestFailureError < StandardError; end
24
- class Base
25
-
26
- attr_accessor :platform
27
- attr_accessor :configuration
28
- attr_accessor :env
29
-
30
- def initialize(env, options={})
31
- raise ArgumentError, "Environment cannot be nil" if env.nil?
32
- @env = env
33
- @platform = options[:platform]
34
- @configuration = options[:configuration]
35
- end
36
-
37
- def prepare
38
- assemble_cookbooks!
39
- end
40
-
41
- def create
42
- raise NotImplementedError
43
- end
44
-
45
- def converge
46
- raise NotImplementedError
47
- end
48
-
49
- def run_list
50
- ['test-kitchen::default']
51
- end
52
-
53
- def preflight_check
54
- if env.project.preflight_command
55
- system(env.project.preflight_command)
56
- unless $?.success?
57
- env.ui.info('Your cookbook had lint failures.', :red)
58
- exit $?.exitstatus
59
- end
60
- end
61
- end
62
-
63
- def test
64
- runtimes = configuration.runtimes
65
- runtimes.each do |runtime|
66
- message = "Synchronizing latest code from source root => test root."
67
- execute_remote_command(platform, configuration.update_code_command, message)
68
-
69
- message = "Updating dependencies for [#{configuration.name}]"
70
- message << " under [#{runtime}]" if runtime
71
- execute_remote_command(platform, configuration.install_command(runtime), message)
72
-
73
- message = "Running tests for [#{configuration.name}]"
74
- message << " under [#{runtime}]" if runtime
75
- exit_code = execute_remote_command(platform, configuration.test_command(runtime), message)
76
- raise TestFailureError unless exit_code == 0
77
- end
78
- end
79
-
80
- def status
81
- raise NotImplementedError
82
- end
83
-
84
- def destroy
85
- raise NotImplementedError
86
- end
87
-
88
- def ssh
89
- raise NotImplementedError
90
- end
91
-
92
- def execute_remote_command(platform, command, mesage=nil)
93
- raise NotImplementedError
94
- end
95
-
96
- def self.inherited(subclass)
97
- key = subclass.to_s.split('::').last.downcase
98
- Runner.targets[key] = subclass
99
- end
100
-
101
- protected
102
-
103
- def assemble_cookbooks!
104
- # dump out a meta Cheffile
105
- env.create_tmp_file('Cheffile',
106
- IO.read(TestKitchen.source_root.join('config', 'Cheffile')))
107
-
108
- env.ui.info("Assembling required cookbooks at [#{env.tmp_path.join('cookbooks')}].", :yellow)
109
-
110
- # The following is a programatic version of `librarian-chef install`
111
- Librarian::Action::Clean.new(librarian_env).run
112
- Librarian::Action::Resolve.new(librarian_env).run
113
- Librarian::Action::Install.new(librarian_env).run
114
- end
115
-
116
- def librarian_env
117
- @librarian_env ||= Librarian::Chef::Environment.new(:project_path => env.tmp_path)
118
- end
119
-
120
- def test_recipe_name
121
- ["#{env.project.name}_test", env.project.name].map do |cookbook_name|
122
- if cookbook_exists?(cookbook_name)
123
- cookbook_name + '::' + (if ! configuration || env.project.name == configuration.name
124
- 'default'
125
- else
126
- configuration.name
127
- end)
128
- end
129
- end.compact.first
130
- end
131
-
132
- def cookbook_exists?(name)
133
- env.cookbook_paths.any?{|path| Dir.exists?(File.join(path, name)) }
134
- end
135
-
136
- end
137
-
138
- def self.targets
139
- @@targets ||= {}
140
- end
141
-
142
- def self.for_platform(env, options)
143
- desired_platform = env.all_platforms[options[:platform]]
144
- if desired_platform.box_url
145
- TestKitchen::Runner.targets['vagrant'].new(env, options)
146
- elsif desired_platform.image_id
147
- TestKitchen::Runner.targets['openstack'].new(env, options)
148
- else
149
- raise ArgumentError,
150
- "No runner available for platform: #{desired_platform.name}"
151
- end
152
- end
153
- end
154
- end
@@ -1,39 +0,0 @@
1
- require 'test-kitchen/runner/openstack/environment'
2
-
3
- module TestKitchen
4
- class Openstack
5
- include Chef::Mixin::ParamsValidate
6
-
7
- attr_writer :username, :password, :tenant, :auth_url
8
-
9
- def initialize(&block)
10
- instance_eval(&block) if block_given?
11
- end
12
-
13
- def username(arg=nil)
14
- set_or_return(:username, arg, {})
15
- end
16
-
17
- def password(arg=nil)
18
- set_or_return(:password, arg, {})
19
- end
20
-
21
- def tenant(arg=nil)
22
- set_or_return(:tenant, arg, {})
23
- end
24
-
25
- def auth_url(arg=nil)
26
- set_or_return(:auth_url, arg, {})
27
- end
28
- end
29
- end
30
-
31
- module TestKitchen
32
- module DSL
33
- module BasicDSL
34
- def openstack(&block)
35
- TestKitchen::Environment::Openstack.config = TestKitchen::Openstack.new(&block)
36
- end
37
- end
38
- end
39
- end